aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'policy-endpoints/src/test')
-rw-r--r--policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpClientTest.java14
-rw-r--r--policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpServerTest.java30
-rw-r--r--policy-endpoints/src/test/resources/logback-test.xml15
3 files changed, 34 insertions, 25 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 cd149f7a..df57fcfc 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
@@ -31,12 +31,16 @@ import org.junit.Test;
import org.openecomp.policy.drools.http.client.HttpClient;
import org.openecomp.policy.drools.http.server.HttpServletServer;
import org.openecomp.policy.drools.properties.PolicyProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class HttpClientTest {
+ private static Logger logger = LoggerFactory.getLogger(HttpClientTest.class);
+
@Test
public void testHttpNoAuthClient() throws Exception {
- System.out.println("-- testHttpNoAuthClient() --");
+ logger.info("-- testHttpNoAuthClient() --");
HttpServletServer server = HttpServletServer.factory.build("echo", "localhost", 6666, "/", false, true);
server.addServletPackage("/*", this.getClass().getPackage().getName());
@@ -57,7 +61,7 @@ public class HttpClientTest {
@Test
public void testHttpAuthClient() throws Exception {
- System.out.println("-- testHttpAuthClient() --");
+ logger.info("-- testHttpAuthClient() --");
HttpServletServer server = HttpServletServer.factory.build("echo", "localhost", 6666, "/", false, true);
server.setBasicAuthentication("x", "y", null);
@@ -79,7 +83,7 @@ public class HttpClientTest {
@Test
public void testHttpAuthClient401() throws Exception {
- System.out.println("-- testHttpAuthClient401() --");
+ logger.info("-- testHttpAuthClient401() --");
HttpServletServer server = HttpServletServer.factory.build("echo", "localhost", 6666, "/", false, true);
server.setBasicAuthentication("x", "y", null);
@@ -98,7 +102,7 @@ public class HttpClientTest {
//@Test
public void testHttpAuthClientHttps() throws Exception {
- System.out.println("-- testHttpAuthClientHttps() --");
+ logger.info("-- testHttpAuthClientHttps() --");
HttpClient client = HttpClient.factory.build("testHttpAuthClientHttps", true, true, "somehost.somewhere.com",
9091, "pap/test", "testpap", "alpha123", true);
@@ -116,7 +120,7 @@ public class HttpClientTest {
//@Test
public void testHttpAuthClientProps() throws Exception {
- System.out.println("-- testHttpAuthClientProps() --");
+ logger.info("-- testHttpAuthClientProps() --");
Properties httpProperties = new Properties();
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 6a369814..931d968b 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
@@ -29,15 +29,19 @@ import java.util.UUID;
import org.junit.Test;
import org.openecomp.policy.drools.http.server.HttpServletServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* HttpServletServer JUNIT tests
*/
public class HttpServerTest {
+
+ private static Logger logger = LoggerFactory.getLogger(HttpServerTest.class);
@Test
public void testSingleServer() throws Exception {
- System.out.println("-- testSingleServer() --");
+ logger.info("-- testSingleServer() --");
HttpServletServer server = HttpServletServer.factory.build("echo", "localhost", 5678, "/", false, true);
server.addServletPackage("/*", this.getClass().getPackage().getName());
@@ -48,7 +52,6 @@ public class HttpServerTest {
String echo = "hello";
URL url = new URL("http://localhost:5678/junit/echo/" + echo);
String response = response(url);
- System.out.println("Received .. " + response);
assertTrue(response.equals(echo));
String responseSwagger = null;
@@ -67,7 +70,7 @@ public class HttpServerTest {
@Test
public void testMultipleServers() throws Exception {
- System.out.println("-- testMultipleServers() --");
+ logger.info("-- testMultipleServers() --");
HttpServletServer server1 = HttpServletServer.factory.build("echo-1", "localhost", 5678, "/", true, true);
server1.addServletPackage("/*", this.getClass().getPackage().getName());
@@ -84,18 +87,14 @@ public class HttpServerTest {
URL url1 = new URL("http://localhost:5678/junit/echo/" + echo);
String response1 = response(url1);
- System.out.println("Received .. " + response1);
assertTrue(response1.equals(echo));
URL urlSwagger = new URL("http://localhost:5678/swagger.json");
- String responseSwagger = response(urlSwagger);
-
- System.out.println("Received .. " + responseSwagger);
+ String responseSwagger = response(urlSwagger);
assertTrue(responseSwagger != null);
URL url2 = new URL("http://localhost:5679/junit/echo/" + echo);
String response2 = response(url2);
- System.out.println("Received .. " + response2);
assertTrue(response2.equals(echo));
String responseSwagger2 = null;
@@ -105,8 +104,6 @@ public class HttpServerTest {
} catch(IOException ioe) {
// Expected
}
-
- System.out.println("Received .. " + responseSwagger2);
assertTrue(responseSwagger2 == null);
HttpServletServer.factory.destroy();
@@ -115,7 +112,7 @@ public class HttpServerTest {
@Test
public void testMultiServicePackage() throws Exception {
- System.out.println("-- testMultiServicePackage() --");
+ logger.info("-- testMultiServicePackage() --");
String randomName = UUID.randomUUID().toString();
@@ -128,12 +125,10 @@ public class HttpServerTest {
String echo = "hello";
URL urlService1 = new URL("http://localhost:5678/junit/echo/" + echo);
String responseService1 = response(urlService1);
- System.out.println("Received .. " + responseService1);
assertTrue(responseService1.equals(echo));
URL urlService2 = new URL("http://localhost:5678/junit/endpoints/http/servers");
String responseService2 = response(urlService2);
- System.out.println("Received .. " + responseService2);
assertTrue(responseService2.contains(randomName));
HttpServletServer.factory.destroy();
@@ -142,7 +137,7 @@ public class HttpServerTest {
@Test
public void testServiceClass() throws Exception {
- System.out.println("-- testServiceClass() --");
+ logger.info("-- testServiceClass() --");
String randomName = UUID.randomUUID().toString();
HttpServletServer server = HttpServletServer.factory.build(randomName, "localhost", 5678, "/", false, true);
@@ -154,7 +149,6 @@ public class HttpServerTest {
String echo = "hello";
URL urlService1 = new URL("http://localhost:5678/junit/echo/" + echo);
String responseService1 = response(urlService1);
- System.out.println("Received .. " + responseService1);
assertTrue(responseService1.equals(echo));
HttpServletServer.factory.destroy();
@@ -163,7 +157,7 @@ public class HttpServerTest {
@Test
public void testMultiServiceClass() throws Exception {
- System.out.println("-- testMultiServiceClass() --");
+ logger.info("-- testMultiServiceClass() --");
String randomName = UUID.randomUUID().toString();
@@ -177,12 +171,10 @@ public class HttpServerTest {
String echo = "hello";
URL urlService1 = new URL("http://localhost:5678/junit/echo/" + echo);
String responseService1 = response(urlService1);
- System.out.println("Received .. " + responseService1);
assertTrue(responseService1.equals(echo));
URL urlService2 = new URL("http://localhost:5678/junit/endpoints/http/servers");
String responseService2 = response(urlService2);
- System.out.println("Received .. " + responseService2);
assertTrue(responseService2.contains(randomName));
HttpServletServer.factory.destroy();
@@ -200,8 +192,6 @@ public class HttpServerTest {
while ((line = ioReader.readLine()) != null) {
response += line;
}
-
- System.out.println("R is " + response);
ioReader.close();
return response;
}
diff --git a/policy-endpoints/src/test/resources/logback-test.xml b/policy-endpoints/src/test/resources/logback-test.xml
new file mode 100644
index 00000000..9e0dd9ba
--- /dev/null
+++ b/policy-endpoints/src/test/resources/logback-test.xml
@@ -0,0 +1,15 @@
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+ <Pattern>
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
+ </Pattern>
+ </encoder>
+ </appender>
+
+ <root level="warn">
+ <appender-ref ref="STDOUT"/>
+ </root>
+
+</configuration> \ No newline at end of file