summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorHenry.Sun <henry.a.sun@est.tech>2019-10-09 18:02:56 +0800
committerHenry.Sun <henry.a.sun@est.tech>2019-10-16 18:02:51 +0800
commit318a9895ddf5a08f0a0f13e3fe634b099707f5cf (patch)
treece0643b3dc16adec4c0fe452c4d36d3f7d707441 /plugins
parente578dc0239328dd7e318dbd05616a90bac45cd20 (diff)
replace grizzly server with policy common endpoint
Issue-ID: POLICY-1915 Change-Id: I8702a8b54e158dfd0ac08140ca083f14f23963a2 Signed-off-by: Henry.Sun <henry.a.sun@est.tech>
Diffstat (limited to 'plugins')
-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();