summaryrefslogtreecommitdiffstats
path: root/common/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/test')
-rw-r--r--common/src/test/java/org/onap/so/client/HttpClientTest.java17
-rw-r--r--common/src/test/java/org/onap/so/client/RestClientTest.java10
2 files changed, 14 insertions, 13 deletions
diff --git a/common/src/test/java/org/onap/so/client/HttpClientTest.java b/common/src/test/java/org/onap/so/client/HttpClientTest.java
index 221005cb7c..75ce5f322f 100644
--- a/common/src/test/java/org/onap/so/client/HttpClientTest.java
+++ b/common/src/test/java/org/onap/so/client/HttpClientTest.java
@@ -30,22 +30,21 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.verify;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
import java.net.MalformedURLException;
import java.net.URL;
-
import org.junit.Rule;
import org.junit.Test;
import org.onap.so.utils.TargetEntity;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-
public class HttpClientTest{
+ private final HttpClientFactory httpClientFactory = new HttpClientFactory();
@Rule
public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicHttpsPort());
- @Test(expected = Test.None.class)
+ @Test
public void testPost_success() throws MalformedURLException{
stubFor(post(urlEqualTo("/services/sdnc/post"))
@@ -54,7 +53,7 @@ public class HttpClientTest{
.withBody("")));
URL url = new URL("http://localhost:" + wireMockConfig().portNumber() + "/services/sdnc/post");
- HttpClient client = new HttpClient(url, "application/json", TargetEntity.BPMN);
+ HttpClient client = httpClientFactory.newJsonClient(url, TargetEntity.BPMN);
client.addBasicAuthHeader("97FF88AB352DA16E00DDD81E3876431DEF8744465DACA489EB3B3BE1F10F63EDA1715E626D0A4827A3E19CD88421BF", "123");
client.addAdditionalHeader("Accept", "application/json");
@@ -64,7 +63,7 @@ public class HttpClientTest{
verify(exactly(1), postRequestedFor(urlEqualTo("/services/sdnc/post")));
}
- @Test(expected = Test.None.class)
+ @Test
public void testPost_nullHeader() throws MalformedURLException{
stubFor(post(urlEqualTo("/services/sdnc/post"))
@@ -73,7 +72,7 @@ public class HttpClientTest{
.withBody("")));
URL url = new URL("http://localhost:" + wireMockConfig().portNumber() + "/services/sdnc/post");
- HttpClient client = new HttpClient(url, "application/json", TargetEntity.BPMN);
+ HttpClient client = httpClientFactory.newJsonClient(url, TargetEntity.BPMN);
client.addAdditionalHeader("Accept", "application/json");
client.addAdditionalHeader("id", null);
@@ -84,7 +83,7 @@ public class HttpClientTest{
.withHeader("Accept", equalTo("application/json")));
}
- @Test(expected = Test.None.class)
+ @Test
public void testPost_nullBasicAuth() throws MalformedURLException{
stubFor(post(urlEqualTo("/services/sdnc/post"))
@@ -93,7 +92,7 @@ public class HttpClientTest{
.withBody("")));
URL url = new URL("http://localhost:" + wireMockConfig().portNumber() + "/services/sdnc/post");
- HttpClient client = new HttpClient(url, "application/json", TargetEntity.BPMN);
+ HttpClient client = httpClientFactory.newJsonClient(url, TargetEntity.BPMN);
client.addBasicAuthHeader("", "12345");
client.addAdditionalHeader("Accept", "application/json");
diff --git a/common/src/test/java/org/onap/so/client/RestClientTest.java b/common/src/test/java/org/onap/so/client/RestClientTest.java
index 6fca4a1820..06196fd73e 100644
--- a/common/src/test/java/org/onap/so/client/RestClientTest.java
+++ b/common/src/test/java/org/onap/so/client/RestClientTest.java
@@ -47,11 +47,12 @@ import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class RestClientTest {
-
+
+ private final HttpClientFactory httpClientFactory = new HttpClientFactory();
@Mock
private RestProperties props;
-
-
+
+
@Test
public void retries() throws Exception {
RestClient spy = buildSpy();
@@ -82,7 +83,8 @@ public class RestClientTest {
}
private RestClient buildSpy() throws MalformedURLException, IllegalArgumentException, UriBuilderException {
- RestClient client = new HttpClient(UriBuilder.fromUri("http://localhost/test").build().toURL(), "application/json", TargetEntity.BPMN);
+ RestClient client = httpClientFactory
+ .newJsonClient(UriBuilder.fromUri("http://localhost/test").build().toURL(), TargetEntity.BPMN);
return spy(client);
}