diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-03-20 14:12:06 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-04-01 09:45:03 -0400 |
commit | aaa93d4351b712762d6951a8c82bbe84c2077795 (patch) | |
tree | 69dab8e5203fe3aa6afb0a26b4da101213a3bf9f /adapters/mso-sdnc-adapter | |
parent | 24117e55159518d2e3599fd7cf6705d476cfda81 (diff) |
replace all fixed wiremock ports
trying to get the tests that can be threaded to pass
started to remove fixed port references
Change-Id: I7bfe067a8f36c908039700646571681321e9a6f5
Issue-ID: SO-1676
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'adapters/mso-sdnc-adapter')
6 files changed, 72 insertions, 16 deletions
diff --git a/adapters/mso-sdnc-adapter/pom.xml b/adapters/mso-sdnc-adapter/pom.xml index 8e94db1aa0..7f03879507 100644 --- a/adapters/mso-sdnc-adapter/pom.xml +++ b/adapters/mso-sdnc-adapter/pom.xml @@ -67,6 +67,24 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <executions> + <execution> + <id>default-test</id> + <goals> + <goal>test</goal> + </goals> + <configuration> + <includes> + <include>**/AllTestsTestSuite.java</include> + </includes> + <parallel>suites</parallel> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> <dependencyManagement> diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/AllTestsTestSuite.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/AllTestsTestSuite.java new file mode 100644 index 0000000000..50a661a695 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/AllTestsTestSuite.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.sdnc; +import org.junit.runner.RunWith; + +import com.googlecode.junittoolbox.SuiteClasses; +import com.googlecode.junittoolbox.WildcardPatternSuite; + +@RunWith(WildcardPatternSuite.class) +@SuiteClasses("**/*Test.class") +public class AllTestsTestSuite { + // the class remains empty, + // used only as a holder for the above annotations +} diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/BaseTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/BaseTest.java index 9716bb624a..29921934dd 100644 --- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/BaseTest.java +++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/BaseTest.java @@ -24,6 +24,7 @@ import org.junit.After; import org.junit.Rule; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; @@ -31,6 +32,8 @@ import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; +import com.github.tomakehurst.wiremock.WireMockServer; + @RunWith(SpringRunner.class) @SpringBootTest(classes = SDNCAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") @@ -38,7 +41,10 @@ import org.springframework.test.context.junit4.SpringRunner; public abstract class BaseTest { @Rule public ExpectedException expectedException = ExpectedException.none(); - + + @Autowired + protected WireMockServer wireMockServer; + protected TestRestTemplate restTemplate = new TestRestTemplate("test", "test"); @Value("${wiremock.server.port}") diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java index 01fa3db960..76dd003883 100644 --- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java +++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java @@ -26,13 +26,12 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import org.apache.http.HttpStatus; import org.junit.Test; import org.onap.so.adapters.sdnc.BaseTest; import org.springframework.beans.factory.annotation.Autowired; -import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static org.junit.Assert.assertTrue; public class SDNCRestClientTest extends BaseTest { @@ -48,7 +47,7 @@ public class SDNCRestClientTest extends BaseTest { rt.setReqMethod("POST"); rt.setSdncUrl("http://localhost:" + wireMockPort + "/sdnc"); - stubFor(post(urlPathEqualTo("/sdnc")) + wireMockServer.stubFor(post(urlPathEqualTo("/sdnc")) .willReturn(aResponse().withHeader("Content-Type", "application/xml").withBody("").withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); SDNCResponse response = sdncClient.getSdncResp("", rt); diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java index 849374838a..f8685738e0 100644 --- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java +++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java @@ -20,15 +20,17 @@ package org.onap.so.adapters.sdnc.sdncrest; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import org.apache.http.HttpStatus; import org.junit.Test; import org.onap.so.adapters.sdnc.BaseTest; import org.springframework.beans.factory.annotation.Autowired; -import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - public class BPRestCallbackTest extends BaseTest { @Autowired @@ -44,7 +46,7 @@ public class BPRestCallbackTest extends BaseTest { "\t\t// </error>\n" + "\t\t// </errors>"; - stubFor(post(urlPathEqualTo("/sdnc")) + wireMockServer.stubFor(post(urlPathEqualTo("/sdnc")) .willReturn(aResponse().withHeader("Content-Type", "application/xml").withBody(response).withStatus(HttpStatus.SC_MULTIPLE_CHOICES))); boolean responseCommon = bpRestCallback.send("http://localhost:" + wireMockPort + "/sdnc", "Test"); diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnectorTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnectorTest.java index 23830ae3f3..1de281bde4 100644 --- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnectorTest.java +++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnectorTest.java @@ -20,18 +20,17 @@ package org.onap.so.adapters.sdnc.sdncrest; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static org.junit.Assert.assertNotNull; + import org.apache.http.HttpStatus; import org.junit.Test; import org.onap.so.adapters.sdnc.BaseTest; import org.onap.so.adapters.sdncrest.SDNCResponseCommon; import org.springframework.beans.factory.annotation.Autowired; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static org.junit.Assert.assertNotNull; -import static com.github.tomakehurst.wiremock.client.WireMock.*; - public class SDNCConnectorTest extends BaseTest { @Autowired @@ -54,7 +53,7 @@ public class SDNCConnectorTest extends BaseTest { rt.setReqMethod("POST"); rt.setSdncUrl("http://localhost:" + wireMockPort + "/sdnc"); - stubFor(post(urlPathEqualTo("/sdnc")) + wireMockServer.stubFor(post(urlPathEqualTo("/sdnc")) .willReturn(aResponse().withHeader("Content-Type", "application/xml").withBody(response).withStatus(HttpStatus.SC_MULTIPLE_CHOICES))); SDNCResponseCommon responseCommon = sdncConnector.send(content, rt); |