aboutsummaryrefslogtreecommitdiffstats
path: root/examples
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 /examples
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 'examples')
-rw-r--r--examples/examples-onap-vcpe/pom.xml12
-rw-r--r--examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSim.java33
2 files changed, 25 insertions, 20 deletions
diff --git a/examples/examples-onap-vcpe/pom.xml b/examples/examples-onap-vcpe/pom.xml
index fd59094b5..b9a992e67 100644
--- a/examples/examples-onap-vcpe/pom.xml
+++ b/examples/examples-onap-vcpe/pom.xml
@@ -50,12 +50,6 @@
<scope>test</scope>
</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.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>${version.jersey}</version>
@@ -96,6 +90,12 @@
<artifactId>events</artifactId>
<version>${version.policy.models}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>policy-endpoints</artifactId>
+ <version>${version.policy.common}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSim.java b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSim.java
index 671f333d9..2a6a2e8d0 100644
--- a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSim.java
+++ b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSim.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,31 +21,33 @@
package org.onap.policy.apex.domains.onap.vcpe;
-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.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
+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;
/**
- * The Class AaiAndGuardSim.
+ * The Class OnapVCpeSim.
*/
public class OnapVCpeSim {
private static final int MAX_LOOPS = 100000;
- private HttpServer server;
+ private static HttpServletServer server;
/**
* Instantiates a new aai and guard sim.
*/
- public OnapVCpeSim(final String[] args) {
- final String baseUri = "http://" + args[0] + ':' + args[1] + "/OnapVCpeSim";
+ public OnapVCpeSim(final String[] args) throws Exception {
+ server = HttpServletServerFactoryInstance.getServerFactory().build(
+ "OnapVCpeSimEndpoint", false, args[0], Integer.valueOf(args[1]).intValue(), "/OnapVCpeSim", false, false);
+
+ server.addServletClass(null, OnapVCpeSimEndpoint.class.getName());
+ server.setSerializationProvider(GsonMessageBodyHandler.class.getName());
- final ResourceConfig rc = new ResourceConfig(OnapVCpeSimEndpoint.class);
- server = GrizzlyHttpServerFactory.createHttpServer(URI.create(baseUri), rc);
+ server.start();
- while (!server.isStarted()) {
- ThreadUtilities.sleep(50);
+ if (!NetworkUtil.isTcpPortOpen(args[0], Integer.valueOf(args[1]).intValue(), 2000, 1L)) {
+ throw new IllegalStateException("port " + args[1] + " is still not in use");
}
}
@@ -54,7 +57,9 @@ public class OnapVCpeSim {
* @throws Exception the exception
*/
public void tearDown() throws Exception {
- server.shutdown();
+ if (server != null) {
+ server.stop();
+ }
}
/**