aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event/plugins-event-carrier
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier')
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml12
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java55
2 files changed, 43 insertions, 24 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml
index f56cfd2ac..47aa8d45f 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml
@@ -1,6 +1,7 @@
<!--
============LICENSE_START=======================================================
Copyright (C) 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.
@@ -58,6 +59,17 @@
<scope>test</scope>
<version>${version.jersey}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>policy-endpoints</artifactId>
+ <version>${version.policy.common}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.containers</groupId>
+ <artifactId>jersey-container-servlet-core</artifactId>
+ <version>${version.jersey}</version>
+ </dependency>
</dependencies>
<profiles>
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java
index a9dfd8dc5..85027cc5b 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.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,25 +21,7 @@
package org.onap.policy.apex.plugins.event.carrier.restrequestor;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
import com.google.gson.Gson;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-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;
@@ -47,13 +30,30 @@ 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 javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.core.Response;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+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 TestRestRequestor.
*/
public class RestRequestorTest {
private static final String BASE_URI = "http://localhost:32801/TestRESTRequestor";
- private static HttpServer server;
+ private static final int PORT = 32801;
+ private static HttpServletServer server;
private ByteArrayOutputStream outContent = new ByteArrayOutputStream();
private ByteArrayOutputStream errContent = new ByteArrayOutputStream();
@@ -68,11 +68,16 @@ public class RestRequestorTest {
*/
@BeforeClass
public static void setUp() throws Exception {
- final ResourceConfig rc = new ResourceConfig(SupportRestRequestorEndpoint.class);
- server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
+ server = HttpServletServerFactoryInstance.getServerFactory().build(
+ null, false, null, PORT, "/TestRESTRequestor", false, false);
- while (!server.isStarted()) {
- ThreadUtilities.sleep(50);
+ server.addServletClass(null, SupportRestRequestorEndpoint.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");
}
}
@@ -83,7 +88,9 @@ public class RestRequestorTest {
*/
@AfterClass
public static void tearDown() throws Exception {
- server.shutdownNow();
+ if (server != null) {
+ server.stop();
+ }
new File("src/test/resources/events/EventsOut.json").delete();
new File("src/test/resources/events/EventsOutMulti0.json").delete();