summaryrefslogtreecommitdiffstats
path: root/testsuites/integration/integration-uservice-test
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/integration/integration-uservice-test')
-rw-r--r--testsuites/integration/integration-uservice-test/pom.xml6
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java46
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java53
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java51
4 files changed, 89 insertions, 67 deletions
diff --git a/testsuites/integration/integration-uservice-test/pom.xml b/testsuites/integration/integration-uservice-test/pom.xml
index 73814306c..b1ab55061 100644
--- a/testsuites/integration/integration-uservice-test/pom.xml
+++ b/testsuites/integration/integration-uservice-test/pom.xml
@@ -178,12 +178,6 @@
<version>${version.jersey}</version>
</dependency>
<dependency>
- <groupId>org.glassfish.jersey.containers</groupId>
- <artifactId>jersey-container-grizzly2-http</artifactId>
- <version>${version.jersey}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>3.0.0</version>
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java
index 6adb3b007..b61c70961 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java
@@ -20,17 +20,6 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.restclient;
-import static org.junit.Assert.assertTrue;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.net.URI;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.core.Response;
-import org.glassfish.grizzly.http.server.HttpServer;
-import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
-import org.glassfish.jersey.server.ResourceConfig;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -38,10 +27,21 @@ import org.junit.Test;
import org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.service.engine.main.ApexMain;
+import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
+import org.onap.policy.common.gson.GsonMessageBodyHandler;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.core.Response;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import static org.junit.Assert.assertTrue;
+
/**
* This class runs integration tests for execution property in restClient.
*/
@@ -50,7 +50,8 @@ public class TestExecutionPropertyRest {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestExecutionPropertyRest.class);
private static final String BASE_URI = "http://localhost:32801/TestExecutionRest";
- private static HttpServer server;
+ private static HttpServletServer server;
+ private static final int PORT = 32801;
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
@@ -84,11 +85,20 @@ public class TestExecutionPropertyRest {
*/
@BeforeClass
public static void setUp() throws Exception {
- final ResourceConfig rc = new ResourceConfig(TestRestClientEndpoint.class);
- server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
+ if (NetworkUtil.isTcpPortOpen("localHost", PORT, 3, 50L)) {
+ throw new IllegalStateException("port " + PORT + " is still in use");
+ }
+
+ server = HttpServletServerFactoryInstance.getServerFactory().build(
+ "TestExecutionPropertyRest", false, null, PORT, "/TestExecutionRest", false, false);
+
+ server.addServletClass(null, TestRestClientEndpoint.class.getName());
+ server.setSerializationProvider(GsonMessageBodyHandler.class.getName());
- if (NetworkUtil.isTcpPortOpen(BASE_URI, 32801, 1, 1L)) {
- throw new IllegalStateException("port " + 32801 + " is still in use");
+ server.start();
+
+ if (!NetworkUtil.isTcpPortOpen("localHost", PORT, 2000, 1L)) {
+ throw new IllegalStateException("port " + PORT + " is still not in use");
}
}
@@ -100,7 +110,9 @@ public class TestExecutionPropertyRest {
*/
@AfterClass
public static void tearDown() throws Exception {
- server.shutdown();
+ if (server != null) {
+ server.stop();
+ }
}
/**
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java
index 69bcf8706..534d4bcf6 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,24 +21,7 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.restclient;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
import com.google.gson.Gson;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.net.URI;
-import java.util.Map;
-
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.core.Response;
-
-import org.glassfish.grizzly.http.server.HttpServer;
-import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
-import org.glassfish.jersey.server.ResourceConfig;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -46,9 +30,24 @@ import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
+import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
+import org.onap.policy.common.gson.GsonMessageBodyHandler;
+import org.onap.policy.common.utils.network.NetworkUtil;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.core.Response;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
/**
* The Class TestFile2Rest.
*/
@@ -56,7 +55,8 @@ public class TestFile2Rest {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestFile2Rest.class);
private static final String BASE_URI = "http://localhost:32801/TestFile2Rest";
- private static HttpServer server;
+ private static final int PORT = 32801;
+ private static HttpServletServer server;
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
@@ -71,11 +71,16 @@ public class TestFile2Rest {
*/
@BeforeClass
public static void setUp() throws Exception {
- final ResourceConfig rc = new ResourceConfig(TestRestClientEndpoint.class);
- server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
+ server = HttpServletServerFactoryInstance.getServerFactory().build(
+ "TestFile2Rest", false, null, PORT, "/TestFile2Rest", false, false);
- while (!server.isStarted()) {
- ThreadUtilities.sleep(50);
+ server.addServletClass(null, TestRestClientEndpoint.class.getName());
+ server.setSerializationProvider(GsonMessageBodyHandler.class.getName());
+
+ server.start();
+
+ if (!NetworkUtil.isTcpPortOpen("localHost", PORT, 2000, 1L)) {
+ throw new IllegalStateException("port " + PORT + " is still not in use");
}
}
@@ -86,7 +91,9 @@ public class TestFile2Rest {
*/
@AfterClass
public static void tearDown() throws Exception {
- server.shutdown();
+ if (server != null) {
+ server.stop();
+ }
}
/**
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java
index 216b566ff..c44950b9e 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,17 +21,6 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.restclient;
-import static org.junit.Assert.fail;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.net.URI;
-
-import org.glassfish.grizzly.http.server.HttpServer;
-import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
-import org.glassfish.jersey.server.ResourceConfig;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -40,9 +30,20 @@ import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.utilities.TextFileUtils;
import org.onap.policy.apex.service.engine.main.ApexMain;
+import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
+import org.onap.policy.common.gson.GsonMessageBodyHandler;
+import org.onap.policy.common.utils.network.NetworkUtil;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+
+import static org.junit.Assert.fail;
+
/**
* The Class TestRest2File.
*/
@@ -50,7 +51,8 @@ public class TestRest2File {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestRest2File.class);
private static final String BASE_URI = "http://localhost:32801/TestRest2File";
- private HttpServer server;
+ private static final int PORT = 32801;
+ private static HttpServletServer server;
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
@@ -73,11 +75,16 @@ public class TestRest2File {
*/
@Before
public void setUp() throws Exception {
- final ResourceConfig rc = new ResourceConfig(TestRestClientEndpoint.class);
- server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
+ server = HttpServletServerFactoryInstance.getServerFactory().build(
+ "TestRest2File", false, null, PORT, "/TestRest2File", false, false);
+
+ server.addServletClass(null, TestRestClientEndpoint.class.getName());
+ server.setSerializationProvider(GsonMessageBodyHandler.class.getName());
- while (!server.isStarted()) {
- ThreadUtilities.sleep(50);
+ server.start();
+
+ if (!NetworkUtil.isTcpPortOpen("localHost", PORT, 2000, 1L)) {
+ throw new IllegalStateException("port " + PORT + " is still not in use");
}
}
@@ -88,7 +95,9 @@ public class TestRest2File {
*/
@After
public void tearDown() throws Exception {
- server.shutdown();
+ if (server != null) {
+ server.stop();
+ }
}
/**
@@ -254,7 +263,7 @@ public class TestRest2File {
checkRequiredString(outString,
"reception of event from URL " + "\"http://localhost:32801/TestRest2File/apex/event/GetEventBadResponse\" "
- + "failed with status code 400 and message \"\"");
+ + "failed with status code 400 and message \"");
}
/**
@@ -263,9 +272,9 @@ public class TestRest2File {
* @param outputEventText the text to examine
* @param requiredString the string to search for
*/
- private void checkRequiredString(String outputText, String requiredString) {
- if (!outputText.contains(requiredString)) {
- LOGGER.error("\n***output text:\n" + outputText + "\n***");
+ private void checkRequiredString(String outputEventText, String requiredString) {
+ if (!outputEventText.contains(requiredString)) {
+ LOGGER.error("\n***output text:\n" + outputEventText + "\n***");
fail("\n***test output did not contain required string:\n" + requiredString + "\n***");
}
}