From 318a9895ddf5a08f0a0f13e3fe634b099707f5cf Mon Sep 17 00:00:00 2001 From: "Henry.Sun" Date: Wed, 9 Oct 2019 18:02:56 +0800 Subject: replace grizzly server with policy common endpoint Issue-ID: POLICY-1915 Change-Id: I8702a8b54e158dfd0ac08140ca083f14f23963a2 Signed-off-by: Henry.Sun --- examples/examples-onap-vcpe/pom.xml | 12 ++--- .../policy/apex/domains/onap/vcpe/OnapVCpeSim.java | 33 +++++++------ .../plugins-event-carrier-restrequestor/pom.xml | 12 +++++ .../carrier/restrequestor/RestRequestorTest.java | 55 ++++++++++++---------- pom.xml | 5 ++ .../integration/integration-uservice-test/pom.xml | 6 --- .../restclient/TestExecutionPropertyRest.java | 46 +++++++++++------- .../uservice/adapt/restclient/TestFile2Rest.java | 53 ++++++++++++--------- .../uservice/adapt/restclient/TestRest2File.java | 51 +++++++++++--------- 9 files changed, 162 insertions(+), 111 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 @@ -49,12 +49,6 @@ ${project.version} test - - org.glassfish.jersey.containers - jersey-container-grizzly2-http - ${version.jersey} - test - org.glassfish.jersey.inject jersey-hk2 @@ -96,6 +90,12 @@ events ${version.policy.models} + + org.onap.policy.common + policy-endpoints + ${version.policy.common} + test + 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(); + } } /** 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 @@