summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpClientTest.java92
-rw-r--r--policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpServerTest.java7
-rw-r--r--policy-endpoints/src/test/resources/logback-test.xml2
3 files changed, 44 insertions, 57 deletions
diff --git a/policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpClientTest.java b/policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpClientTest.java
index df57fcfc..a7d309a1 100644
--- a/policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpClientTest.java
+++ b/policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpClientTest.java
@@ -27,6 +27,8 @@ import java.util.Properties;
import javax.ws.rs.core.Response;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.openecomp.policy.drools.http.client.HttpClient;
import org.openecomp.policy.drools.http.server.HttpServletServer;
@@ -38,14 +40,36 @@ public class HttpClientTest {
private static Logger logger = LoggerFactory.getLogger(HttpClientTest.class);
+ @BeforeClass
+ public static void setUp() {
+ logger.info("-- setup() --");
+
+ /* echo server */
+
+ HttpServletServer echoServerNoAuth = HttpServletServer.factory.build("echo", "localhost", 6666, "/", false, true);
+ echoServerNoAuth.addServletPackage("/*", HttpClientTest.class.getPackage().getName());
+ echoServerNoAuth.waitedStart(5000);
+
+ /* no auth echo server */
+
+ HttpServletServer echoServerAuth = HttpServletServer.factory.build("echo", "localhost", 6667, "/", false, true);
+ echoServerAuth.setBasicAuthentication("x", "y", null);
+ echoServerAuth.addServletPackage("/*", HttpClientTest.class.getPackage().getName());
+ echoServerAuth.waitedStart(5000);
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ logger.info("-- tearDown() --");
+
+ HttpServletServer.factory.destroy();
+ HttpClient.factory.destroy();
+ }
+
@Test
public void testHttpNoAuthClient() throws Exception {
logger.info("-- testHttpNoAuthClient() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", "localhost", 6666, "/", false, true);
- server.addServletPackage("/*", this.getClass().getPackage().getName());
- server.waitedStart(5000);
-
HttpClient client = HttpClient.factory.build("testHttpNoAuthClient", false, false,
"localhost", 6666, "junit/echo",
null, null, true);
@@ -54,71 +78,34 @@ public class HttpClientTest {
assertTrue(response.getStatus() == 200);
assertTrue(body.equals("hello"));
-
- HttpServletServer.factory.destroy();
- HttpClient.factory.destroy();
}
@Test
public void testHttpAuthClient() throws Exception {
logger.info("-- testHttpAuthClient() --");
-
- HttpServletServer server = HttpServletServer.factory.build("echo", "localhost", 6666, "/", false, true);
- server.setBasicAuthentication("x", "y", null);
- server.addServletPackage("/*", this.getClass().getPackage().getName());
- server.waitedStart(5000);
HttpClient client = HttpClient.factory.build("testHttpAuthClient",false, false,
- "localhost", 6666, "junit/echo",
+ "localhost", 6667, "junit/echo",
"x", "y", true);
Response response = client.get("hello");
String body = HttpClient.getBody(response, String.class);
assertTrue(response.getStatus() == 200);
assertTrue(body.equals("hello"));
-
- HttpServletServer.factory.destroy();
- HttpClient.factory.destroy();
}
@Test
public void testHttpAuthClient401() throws Exception {
logger.info("-- testHttpAuthClient401() --");
-
- HttpServletServer server = HttpServletServer.factory.build("echo", "localhost", 6666, "/", false, true);
- server.setBasicAuthentication("x", "y", null);
- server.addServletPackage("/*", this.getClass().getPackage().getName());
- server.waitedStart(5000);
HttpClient client = HttpClient.factory.build("testHttpAuthClient401",false, false,
- "localhost", 6666, "junit/echo",
+ "localhost", 6667, "junit/echo",
null, null, true);
Response response = client.get("hello");
assertTrue(response.getStatus() == 401);
-
- HttpServletServer.factory.destroy();
- HttpClient.factory.destroy();
}
-
- //@Test
- public void testHttpAuthClientHttps() throws Exception {
- logger.info("-- testHttpAuthClientHttps() --");
-
- HttpClient client = HttpClient.factory.build("testHttpAuthClientHttps", true, true, "somehost.somewhere.com",
- 9091, "pap/test", "testpap", "alpha123", true);
- Response response = client.get();
- assertTrue(response.getStatus() == 200);
-
- HttpClient client2 = HttpClient.factory.build("testHttpAuthClientHttps2", true, true, "somehost.somewhere.com",
- 8081, "pdp", "testpdp", "alpha123", true);
- Response response2 = client2.get("test");
- assertTrue(response2.getStatus() == 500);
-
- HttpServletServer.factory.destroy();
- HttpClient.factory.destroy();
- }
- //@Test
+ @Test
public void testHttpAuthClientProps() throws Exception {
logger.info("-- testHttpAuthClientProps() --");
@@ -130,7 +117,7 @@ public class HttpClientTest {
"localhost");
httpProperties.setProperty
(PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "PAP" + PolicyProperties.PROPERTY_HTTP_PORT_SUFFIX,
- "9091");
+ "7777");
httpProperties.setProperty
(PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "PAP" + PolicyProperties.PROPERTY_HTTP_AUTH_USERNAME_SUFFIX,
"testpap");
@@ -139,7 +126,7 @@ public class HttpClientTest {
"alpha123");
httpProperties.setProperty
(PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "PAP" + PolicyProperties.PROPERTY_HTTP_REST_CLASSES_SUFFIX,
- "org.openecomp.policy.drools.http.server.test.RestMockHealthCheck");
+ RestMockHealthCheck.class.getName());
httpProperties.setProperty
(PolicyProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "PAP" + PolicyProperties.PROPERTY_MANAGED_SUFFIX,
"true");
@@ -149,7 +136,7 @@ public class HttpClientTest {
"localhost");
httpProperties.setProperty
(PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "PDP" + PolicyProperties.PROPERTY_HTTP_PORT_SUFFIX,
- "8081");
+ "7778");
httpProperties.setProperty
(PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "PDP" + PolicyProperties.PROPERTY_HTTP_AUTH_USERNAME_SUFFIX,
"testpdp");
@@ -158,7 +145,7 @@ public class HttpClientTest {
"alpha123");
httpProperties.setProperty
(PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "PDP" + PolicyProperties.PROPERTY_HTTP_REST_CLASSES_SUFFIX,
- "org.openecomp.policy.drools.http.server.test.RestMockHealthCheck");
+ RestMockHealthCheck.class.getName());
httpProperties.setProperty
(PolicyProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "PAP" + PolicyProperties.PROPERTY_MANAGED_SUFFIX,
"true");
@@ -169,7 +156,7 @@ public class HttpClientTest {
"localhost");
httpProperties.setProperty
(PolicyProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "PAP" + PolicyProperties.PROPERTY_HTTP_PORT_SUFFIX,
- "9091");
+ "7777");
httpProperties.setProperty
(PolicyProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "PAP" + PolicyProperties.PROPERTY_HTTP_URL_SUFFIX,
"pap/test");
@@ -191,7 +178,7 @@ public class HttpClientTest {
"localhost");
httpProperties.setProperty
(PolicyProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "PDP" + PolicyProperties.PROPERTY_HTTP_PORT_SUFFIX,
- "8081");
+ "7778");
httpProperties.setProperty
(PolicyProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "PDP" + PolicyProperties.PROPERTY_HTTP_URL_SUFFIX,
"pdp");
@@ -224,10 +211,7 @@ public class HttpClientTest {
HttpClient clientPDP = HttpClient.factory.get("PDP");
Response response2 = clientPDP.get("test");
- assertTrue(response2.getStatus() == 500);
-
- HttpServletServer.factory.destroy();
- HttpClient.factory.destroy();
+ assertTrue(response2.getStatus() == 500);
}
diff --git a/policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpServerTest.java b/policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpServerTest.java
index 931d968b..02047008 100644
--- a/policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpServerTest.java
+++ b/policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpServerTest.java
@@ -62,9 +62,12 @@ public class HttpServerTest {
// Expected
}
- assertTrue(responseSwagger == null);
+ assertTrue(responseSwagger == null);
- HttpServletServer.factory.destroy();
+ assertTrue(HttpServletServer.factory.get(5678).isAlive());
+ assertTrue(HttpServletServer.factory.inventory().size() == 1);
+
+ HttpServletServer.factory.destroy(5678);
assertTrue(HttpServletServer.factory.inventory().size() == 0);
}
diff --git a/policy-endpoints/src/test/resources/logback-test.xml b/policy-endpoints/src/test/resources/logback-test.xml
index 9e0dd9ba..bc813ef7 100644
--- a/policy-endpoints/src/test/resources/logback-test.xml
+++ b/policy-endpoints/src/test/resources/logback-test.xml
@@ -8,7 +8,7 @@
</encoder>
</appender>
- <root level="warn">
+ <root level="info">
<appender-ref ref="STDOUT"/>
</root>