aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http
diff options
context:
space:
mode:
Diffstat (limited to 'policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http')
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java69
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpExceptionsTest.java33
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java96
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java14
4 files changed, 132 insertions, 80 deletions
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java
index f559b112..2aaf1367 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java
@@ -25,8 +25,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -40,7 +38,10 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClient;
+import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
+import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.common.endpoints.http.server.internal.JettyJerseyServer;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.common.utils.network.NetworkUtil;
@@ -72,7 +73,7 @@ public class HttpClientTest {
/* echo server - http + no auth */
final HttpServletServer echoServerNoAuth =
- HttpServletServer.factory.build("echo", LOCALHOST, 6666, "/", false, true);
+ HttpServletServerFactoryInstance.getServerFactory().build("echo", LOCALHOST, 6666, "/", false, true);
echoServerNoAuth.addServletPackage("/*", HttpClientTest.class.getPackage().getName());
echoServerNoAuth.waitedStart(5000);
@@ -112,8 +113,8 @@ public class HttpClientTest {
/* echo server - https + basic auth */
- final HttpServletServer echoServerAuth =
- HttpServletServer.factory.build("echo", true, LOCALHOST, 6667, "/", false, true);
+ final HttpServletServer echoServerAuth = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", true, LOCALHOST, 6667, "/", false, true);
echoServerAuth.setBasicAuthentication("x", "y", null);
echoServerAuth.addServletPackage("/*", HttpClientTest.class.getPackage().getName());
echoServerAuth.addFilterClass("/*", TestFilter.class.getName());
@@ -132,7 +133,7 @@ public class HttpClientTest {
*/
@Before
public void setUp() {
- HttpClient.factory.destroy();
+ HttpClientFactoryInstance.getClientFactory().destroy();
MyGsonProvider.resetSome();
MyJacksonProvider.resetSome();
@@ -143,8 +144,8 @@ public class HttpClientTest {
*/
@AfterClass
public static void tearDownAfterClass() {
- HttpServletServer.factory.destroy();
- HttpClient.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ HttpClientFactoryInstance.getClientFactory().destroy();
if (savedValuesMap.containsKey(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME)) {
System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME,
@@ -254,10 +255,11 @@ public class HttpClientTest {
@Test
public void testHttpPutAuthClient_JacksonProvider() throws Exception {
- final HttpClient client = HttpClient.factory.build(BusTopicParams.builder().clientName(TEST_HTTP_AUTH_CLIENT)
- .useHttps(true).allowSelfSignedCerts(true).hostname(LOCALHOST).port(6667)
- .basePath(JUNIT_ECHO).userName("x").password("y").managed(true)
- .serializationProvider(MyJacksonProvider.class.getName()).build());
+ final HttpClient client = HttpClientFactoryInstance.getClientFactory()
+ .build(BusTopicParams.builder().clientName(TEST_HTTP_AUTH_CLIENT).useHttps(true)
+ .allowSelfSignedCerts(true).hostname(LOCALHOST).port(6667).basePath(JUNIT_ECHO)
+ .userName("x").password("y").managed(true)
+ .serializationProvider(MyJacksonProvider.class.getName()).build());
Entity<MyEntity> entity = Entity.entity(new MyEntity(MY_VALUE), MediaType.APPLICATION_JSON);
final Response response = client.put(HELLO, entity, Collections.emptyMap());
@@ -273,10 +275,11 @@ public class HttpClientTest {
@Test
public void testHttpPutAuthClient_GsonProvider() throws Exception {
- final HttpClient client = HttpClient.factory.build(BusTopicParams.builder().clientName(TEST_HTTP_AUTH_CLIENT)
- .useHttps(true).allowSelfSignedCerts(true).hostname(LOCALHOST).port(6667)
- .basePath(JUNIT_ECHO).userName("x").password("y").managed(true)
- .serializationProvider(MyGsonProvider.class.getName()).build());
+ final HttpClient client = HttpClientFactoryInstance.getClientFactory()
+ .build(BusTopicParams.builder().clientName(TEST_HTTP_AUTH_CLIENT).useHttps(true)
+ .allowSelfSignedCerts(true).hostname(LOCALHOST).port(6667).basePath(JUNIT_ECHO)
+ .userName("x").password("y").managed(true)
+ .serializationProvider(MyGsonProvider.class.getName()).build());
Entity<MyEntity> entity = Entity.entity(new MyEntity(MY_VALUE), MediaType.APPLICATION_JSON);
final Response response = client.put(HELLO, entity, Collections.emptyMap());
@@ -368,21 +371,22 @@ public class HttpClientTest {
httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + DOT_PDP
+ PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX, "true");
- final List<HttpServletServer> servers = HttpServletServer.factory.build(httpProperties);
+ final List<HttpServletServer> servers =
+ HttpServletServerFactoryInstance.getServerFactory().build(httpProperties);
assertEquals(2, servers.size());
- final List<HttpClient> clients = HttpClient.factory.build(httpProperties);
+ final List<HttpClient> clients = HttpClientFactoryInstance.getClientFactory().build(httpProperties);
assertEquals(2, clients.size());
for (final HttpServletServer server : servers) {
server.waitedStart(10000);
}
- final HttpClient clientPap = HttpClient.factory.get("PAP");
+ final HttpClient clientPap = HttpClientFactoryInstance.getClientFactory().get("PAP");
final Response response = clientPap.get();
assertEquals(200, response.getStatus());
- final HttpClient clientPdp = HttpClient.factory.get("PDP");
+ final HttpClient clientPdp = HttpClientFactoryInstance.getClientFactory().get("PDP");
final Response response2 = clientPdp.get("test");
assertEquals(500, response2.getStatus());
@@ -425,7 +429,7 @@ public class HttpClientTest {
+ PolicyEndPointProperties.PROPERTY_HTTP_SERIALIZATION_PROVIDER,
MyJacksonProvider.class.getName());
- final List<HttpClient> clients = HttpClient.factory.build(httpProperties);
+ final List<HttpClient> clients = HttpClientFactoryInstance.getClientFactory().build(httpProperties);
assertEquals(2, clients.size());
Entity<MyEntity> entity = Entity.entity(new MyEntity(MY_VALUE), MediaType.APPLICATION_JSON);
@@ -433,7 +437,7 @@ public class HttpClientTest {
// use gson client
MyGsonProvider.resetSome();
MyJacksonProvider.resetSome();
- HttpClient client = HttpClient.factory.get("GSON");
+ HttpClient client = HttpClientFactoryInstance.getClientFactory().get("GSON");
Response response = client.put(HELLO, entity, Collections.emptyMap());
String body = HttpClient.getBody(response, String.class);
@@ -447,7 +451,7 @@ public class HttpClientTest {
// use jackson client
MyGsonProvider.resetSome();
MyJacksonProvider.resetSome();
- client = HttpClient.factory.get("JACKSON");
+ client = HttpClientFactoryInstance.getClientFactory().get("JACKSON");
response = client.put(HELLO, entity, Collections.emptyMap());
body = HttpClient.getBody(response, String.class);
@@ -459,18 +463,19 @@ public class HttpClientTest {
assertFalse(MyGsonProvider.hasWrittenSome());
}
- private HttpClient getAuthHttpClient()
- throws KeyManagementException, NoSuchAlgorithmException, ClassNotFoundException {
- return HttpClient.factory.build(BusTopicParams.builder().clientName(TEST_HTTP_AUTH_CLIENT)
- .useHttps(true).allowSelfSignedCerts(true).hostname(LOCALHOST).port(6667).basePath(JUNIT_ECHO)
- .userName("x").password("y").managed(true).build());
+ private HttpClient getAuthHttpClient() throws HttpClientConfigException {
+ return HttpClientFactoryInstance.getClientFactory()
+ .build(BusTopicParams.builder().clientName(TEST_HTTP_AUTH_CLIENT).useHttps(true)
+ .allowSelfSignedCerts(true).hostname(LOCALHOST).port(6667).basePath(JUNIT_ECHO)
+ .userName("x").password("y").managed(true).build());
}
private HttpClient getNoAuthHttpClient(String clientName, boolean https, int port)
- throws KeyManagementException, NoSuchAlgorithmException, ClassNotFoundException {
- return HttpClient.factory.build(BusTopicParams.builder().clientName(clientName)
- .useHttps(https).allowSelfSignedCerts(https).hostname(LOCALHOST).port(port).basePath(JUNIT_ECHO)
- .userName(null).password(null).managed(true).build());
+ throws HttpClientConfigException {
+ return HttpClientFactoryInstance.getClientFactory()
+ .build(BusTopicParams.builder().clientName(clientName).useHttps(https)
+ .allowSelfSignedCerts(https).hostname(LOCALHOST).port(port).basePath(JUNIT_ECHO)
+ .userName(null).password(null).managed(true).build());
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpExceptionsTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpExceptionsTest.java
new file mode 100644
index 00000000..85135759
--- /dev/null
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpExceptionsTest.java
@@ -0,0 +1,33 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2019 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.policy.common.endpoints.http.server.test;
+
+import org.junit.Test;
+import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
+import org.onap.policy.common.utils.test.ExceptionsTester;
+
+public class HttpExceptionsTest extends ExceptionsTester {
+
+ @Test
+ public void testHttpClientConfigException() {
+ test(HttpClientConfigException.class);
+ }
+}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
index c6ff2f32..f2b53648 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
@@ -39,6 +39,7 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.common.utils.gson.GsonTestUtils;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.slf4j.Logger;
@@ -79,7 +80,7 @@ public class HttpServerTest {
incrementPort();
portUrl = LOCALHOST_PREFIX + port;
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
MyJacksonProvider.resetSome();
MyGsonProvider.resetSome();
@@ -91,19 +92,20 @@ public class HttpServerTest {
@AfterClass
public static void tearDownAfterClass() {
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
}
@Test
public void testDefaultPackageServer() throws Exception {
logger.info("-- testDefaultPackageServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.addServletPackage("/*", this.getClass().getPackage().getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -118,14 +120,15 @@ public class HttpServerTest {
public void testJacksonPackageServer() throws Exception {
logger.info("-- testJacksonPackageServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.setSerializationProvider(MyJacksonProvider.class.getName());
server.addServletPackage("/*", this.getClass().getPackage().getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -146,14 +149,15 @@ public class HttpServerTest {
public void testGsonPackageServer() throws Exception {
logger.info("-- testGsonPackageServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.setSerializationProvider(MyGsonProvider.class.getName());
server.addServletPackage("/*", this.getClass().getPackage().getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -174,12 +178,13 @@ public class HttpServerTest {
public void testDefaultClassServer() throws Exception {
logger.info("-- testDefaultClassServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.addServletClass("/*", RestEchoService.class.getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -194,13 +199,14 @@ public class HttpServerTest {
public void testJacksonClassServer() throws Exception {
logger.info("-- testJacksonClassServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.setSerializationProvider(MyJacksonProvider.class.getName());
server.addServletClass("/*", RestEchoService.class.getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -221,13 +227,14 @@ public class HttpServerTest {
public void testGsonClassServer() throws Exception {
logger.info("-- testGsonClassServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.setSerializationProvider(MyGsonProvider.class.getName());
server.addServletClass("/*", RestEchoService.class.getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -246,7 +253,8 @@ public class HttpServerTest {
@Test
public void testSerialize() {
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.addServletPackage("/*", this.getClass().getPackage().getName());
server.addFilterClass("/*", TestFilter.class.getName());
@@ -258,13 +266,14 @@ public class HttpServerTest {
public void testSingleServer() throws Exception {
logger.info("-- testSingleServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.addServletPackage("/*", this.getClass().getPackage().getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
- assertFalse(HttpServletServer.factory.get(port).isAaf());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
+ assertFalse(HttpServletServerFactoryInstance.getServerFactory().get(port).isAaf());
String response = http(portUrl + JUNIT_ECHO_HELLO);
assertEquals(HELLO, response);
@@ -274,32 +283,34 @@ public class HttpServerTest {
response = http(portUrl + "/junit/echo/hello?block=true");
assertEquals("FILTERED", response);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
- assertEquals(1, HttpServletServer.factory.inventory().size());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
+ assertEquals(1, HttpServletServerFactoryInstance.getServerFactory().inventory().size());
server.setAafAuthentication("/*");
- assertTrue(HttpServletServer.factory.get(port).isAaf());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAaf());
- HttpServletServer.factory.destroy(port);
- assertEquals(0, HttpServletServer.factory.inventory().size());
+ HttpServletServerFactoryInstance.getServerFactory().destroy(port);
+ assertEquals(0, HttpServletServerFactoryInstance.getServerFactory().inventory().size());
}
@Test
public void testMultipleServers() throws Exception {
logger.info("-- testMultipleServers() --");
- HttpServletServer server1 = HttpServletServer.factory.build("echo-1", false,LOCALHOST, port, "/", true, true);
+ HttpServletServer server1 = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo-1", false,LOCALHOST, port, "/", true, true);
server1.addServletPackage("/*", this.getClass().getPackage().getName());
server1.waitedStart(5000);
int port2 = port + 1;
- HttpServletServer server2 = HttpServletServer.factory.build("echo-2", LOCALHOST, port2, "/", false, true);
+ HttpServletServer server2 = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo-2", LOCALHOST, port2, "/", false, true);
server2.addServletPackage("/*", this.getClass().getPackage().getName());
server2.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
- assertTrue(HttpServletServer.factory.get(port2).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port2).isAlive());
String response = http(portUrl + JUNIT_ECHO_HELLO);
assertTrue(HELLO.equals(response));
@@ -312,8 +323,8 @@ public class HttpServerTest {
assertThatThrownBy(() -> http(LOCALHOST_PREFIX + port2 + SWAGGER_JSON)).isInstanceOf(IOException.class);
- HttpServletServer.factory.destroy();
- assertTrue(HttpServletServer.factory.inventory().isEmpty());
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().inventory().isEmpty());
}
@Test
@@ -322,11 +333,12 @@ public class HttpServerTest {
String randomName = UUID.randomUUID().toString();
- HttpServletServer server = HttpServletServer.factory.build(randomName, LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build(randomName, LOCALHOST, port, "/", false, true);
server.addServletPackage("/*", this.getClass().getPackage().getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
String response = http(portUrl + JUNIT_ECHO_HELLO);
assertTrue(HELLO.equals(response));
@@ -334,8 +346,8 @@ public class HttpServerTest {
response = http(portUrl + "/junit/endpoints/http/servers");
assertTrue(response.contains(randomName));
- HttpServletServer.factory.destroy();
- assertTrue(HttpServletServer.factory.inventory().isEmpty());
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().inventory().isEmpty());
}
@Test
@@ -343,17 +355,18 @@ public class HttpServerTest {
logger.info("-- testServiceClass() --");
String randomName = UUID.randomUUID().toString();
- HttpServletServer server = HttpServletServer.factory.build(randomName, LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build(randomName, LOCALHOST, port, "/", false, true);
server.addServletClass("/*", RestEchoService.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
String response = http(portUrl + JUNIT_ECHO_HELLO);
assertTrue(HELLO.equals(response));
- HttpServletServer.factory.destroy();
- assertTrue(HttpServletServer.factory.inventory().isEmpty());
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().inventory().isEmpty());
}
@Test
@@ -362,12 +375,13 @@ public class HttpServerTest {
String randomName = UUID.randomUUID().toString();
- HttpServletServer server = HttpServletServer.factory.build(randomName, LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build(randomName, LOCALHOST, port, "/", false, true);
server.addServletClass("/*", RestEchoService.class.getName());
server.addServletClass("/*", RestEndpoints.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
String response = http(portUrl + JUNIT_ECHO_HELLO);
assertTrue(HELLO.equals(response));
@@ -375,8 +389,8 @@ public class HttpServerTest {
response = http(portUrl + "/junit/endpoints/http/servers");
assertTrue(response.contains(randomName));
- HttpServletServer.factory.destroy();
- assertTrue(HttpServletServer.factory.inventory().isEmpty());
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().inventory().isEmpty());
}
/**
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java
index fe199645..6ada15c5 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 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.
@@ -28,23 +28,23 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
@Path("/junit/endpoints")
public class RestEndpoints {
/**
* Returns the http servers.
- *
+ *
* @return the list of servers as a string
*/
@GET
@Path("http/servers")
@Produces(MediaType.TEXT_PLAIN)
- public String httpServers() {
- List<HttpServletServer> servers =
- HttpServletServer.factory.inventory();
+ public String httpServers() {
+ List<HttpServletServer> servers = HttpServletServerFactoryInstance.getServerFactory().inventory();
return servers.toString();
}
-
-
+
+
}