Fix Simulator Builders 80/135880/1 java-17
authorFrancescoFioraEst <francesco.fiora@est.tech>
Wed, 30 Aug 2023 14:19:32 +0000 (15:19 +0100)
committerFrancesco Fiora <francesco.fiora@est.tech>
Wed, 30 Aug 2023 15:04:51 +0000 (15:04 +0000)
Simulator Builders have to return a HttpServletServer Object
because are used by drools-applications.

Issue-ID: POLICY-4814
Change-Id: If3dbe5db437464d291c7b3e14183159aa6b35cbb
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java
models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/XacmlSimulatorTest.java

index f4b6141..a88bb02 100644 (file)
@@ -76,7 +76,8 @@ public abstract class BasicSdncOperation extends BasicHttpOperation {
      * Starts the simulator.
      */
     protected static void initBeforeClass() throws Exception {
-        Util.buildSdncSim();
+        var testServer = Util.buildSdncSim();
+        assertNotNull(testServer);
 
         BusTopicParams clientParams = BusTopicParams.builder().clientName(MY_CLIENT).basePath("restconf/operations/")
                         .hostname("localhost").managed(true).port(Util.SDNCSIM_SERVER_PORT).build();
index bfbacc6..f5408c4 100644 (file)
@@ -60,12 +60,13 @@ public final class Util {
      *
      * @throws InterruptedException if a thread is interrupted
      */
-    public static void buildAaiSim() throws InterruptedException {
+    public static HttpServletServer buildAaiSim() throws InterruptedException {
         final HttpServletServer testServer = HttpServletServerFactoryInstance.getServerFactory()
                 .build(AAISIM_SERVER_NAME, LOCALHOST, AAISIM_SERVER_PORT, "/", false, true);
         testServer.addServletClass("/*", AaiSimulatorJaxRs.class.getName());
         testServer.waitedStart(5000);
         waitForServerToListen(testServer.getPort());
+        return testServer;
     }
 
     /**
@@ -87,12 +88,13 @@ public final class Util {
      *
      * @throws InterruptedException if a thread is interrupted
      */
-    public static void buildSdncSim() throws InterruptedException {
+    public static HttpServletServer buildSdncSim() throws InterruptedException {
         final HttpServletServer testServer = HttpServletServerFactoryInstance.getServerFactory()
                 .build(SDNCSIM_SERVER_NAME, LOCALHOST, SDNCSIM_SERVER_PORT, "/", false, true);
         testServer.addServletClass("/*", SdncSimulatorJaxRs.class.getName());
         testServer.waitedStart(5000);
         waitForServerToListen(testServer.getPort());
+        return testServer;
     }
 
 
@@ -101,12 +103,13 @@ public final class Util {
      *
      * @throws InterruptedException if a thread is interrupted
      */
-    public static void buildSoSim() throws InterruptedException {
+    public static HttpServletServer buildSoSim() throws InterruptedException {
         final HttpServletServer testServer = HttpServletServerFactoryInstance.getServerFactory()
                 .build(SOSIM_SERVER_NAME, LOCALHOST, SOSIM_SERVER_PORT, "/", false, true);
         testServer.addServletClass("/*", SoSimulatorJaxRs.class.getName());
         testServer.waitedStart(5000);
         waitForServerToListen(testServer.getPort());
+        return testServer;
     }
 
     /**
@@ -114,12 +117,13 @@ public final class Util {
      *
      * @throws InterruptedException if a thread is interrupted
      */
-    public static void buildVfcSim() throws InterruptedException {
+    public static HttpServletServer buildVfcSim() throws InterruptedException {
         final HttpServletServer testServer = HttpServletServerFactoryInstance.getServerFactory()
                 .build(VFCSIM_SERVER_NAME, LOCALHOST, VFCSIM_SERVER_PORT, "/", false, true);
         testServer.addServletClass("/*", VfcSimulatorJaxRs.class.getName());
         testServer.waitedStart(5000);
         waitForServerToListen(testServer.getPort());
+        return testServer;
     }
 
     /**
@@ -127,12 +131,13 @@ public final class Util {
      *
      * @throws InterruptedException if a thread is interrupted
      */
-    public static void buildXacmlSim() throws InterruptedException {
+    public static HttpServletServer buildXacmlSim() throws InterruptedException {
         HttpServletServer testServer = HttpServletServerFactoryInstance.getServerFactory().build(XACMLSIM_SERVER_NAME,
                 LOCALHOST, XACMLSIM_SERVER_PORT, "/", false, true);
         testServer.addServletClass("/*", XacmlSimulatorJaxRs.class.getName());
         testServer.waitedStart(5000);
         waitForServerToListen(testServer.getPort());
+        return testServer;
     }
 
     /**
index d5d93e0..a730d97 100644 (file)
@@ -42,7 +42,8 @@ public class AaiSimulatorTest {
     @BeforeClass
     public static void setUpSimulator() {
         try {
-            Util.buildAaiSim();
+            var testServer = Util.buildAaiSim();
+            assertNotNull(testServer);
         } catch (final Exception e) {
             fail(e.getMessage());
         }
index 31b7627..129f284 100644 (file)
@@ -57,7 +57,8 @@ public class SoSimulatorTest {
     @BeforeClass
     public static void setUpSimulator() {
         try {
-            Util.buildSoSim();
+            var testServer = Util.buildSoSim();
+            assertNotNull(testServer);
         } catch (final Exception e) {
             fail(e.getMessage());
         }
index dc48e75..643fadf 100644 (file)
@@ -43,7 +43,8 @@ public class VfcSimulatorTest {
     @BeforeClass
     public static void setUpSimulator() {
         try {
-            Util.buildVfcSim();
+            var testServer = Util.buildVfcSim();
+            assertNotNull(testServer);
         } catch (final Exception e) {
             fail(e.getMessage());
         }
index e188edc..417dcc9 100644 (file)
@@ -48,7 +48,8 @@ public class XacmlSimulatorTest {
     @BeforeClass
     public static void setupSimulator() {
         try {
-            org.onap.policy.simulators.Util.buildXacmlSim();
+            var testServer = Util.buildXacmlSim();
+            assertNotNull(testServer);
         } catch (Exception e) {
             fail(e.getMessage());
         }