Remove dmaap from models
[policy/models.git] / models-sim / policy-models-simulators / src / test / java / org / onap / policy / models / simulators / MainTest.java
index bb4fa7c..09064f4 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023-2024 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,7 +31,9 @@ import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import jakarta.ws.rs.core.Response;
 import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -38,7 +41,6 @@ import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
-import javax.ws.rs.core.Response;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -52,6 +54,7 @@ import org.onap.policy.common.endpoints.http.server.internal.JettyJerseyServer;
 import org.onap.policy.common.utils.coder.Coder;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.network.NetworkUtil;
+import org.onap.policy.common.utils.security.SelfSignedKeyStore;
 
 public class MainTest {
     private static final String PARAMETER_FILE = "simParameters.json";
@@ -64,7 +67,7 @@ public class MainTest {
      * Saves system properties.
      */
     @BeforeClass
-    public static void setUpBeforeClass() {
+    public static void setUpBeforeClass() throws IOException, InterruptedException {
         savedValues = new HashMap<>();
 
         for (String prop : List.of(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME,
@@ -75,11 +78,14 @@ public class MainTest {
             savedValues.put(prop, System.getProperty(prop));
         }
 
-        System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME, "src/test/resources/keystore-test");
-        System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME, "kstest");
+        System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME, new SelfSignedKeyStore().getKeystoreName());
+        System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME,
+                        SelfSignedKeyStore.KEYSTORE_PASSWORD);
 
-        System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME, "src/test/resources/keystore-test");
-        System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME, "kstest");
+        System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME,
+                        "src/main/resources/ssl/policy-truststore");
+        System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME,
+                        SelfSignedKeyStore.KEYSTORE_PASSWORD);
     }
 
     /**
@@ -107,14 +113,8 @@ public class MainTest {
         }
     }
 
-    @Test
-    public void testConstructor() throws Exception {
-        assertThatIllegalArgumentException().isThrownBy(() -> new Main("invalidDmaapProvider.json"))
-                        .withMessage("invalid simulator parameters");
-    }
-
     /**
-     * Verifies that all of the simulators are brought up and that HTTPS works with at
+     * Verifies that all the simulators are brought up and that HTTPS works with at
      * least one of them.
      */
     @Test
@@ -218,7 +218,7 @@ public class MainTest {
             }
         };
 
-        // run in another thread so we don't interrupt this thread
+        // run in another thread, so we don't interrupt this thread
         LinkedBlockingQueue<RuntimeException> queue = new LinkedBlockingQueue<>();
         Thread thread = new Thread(() -> {
             try {
@@ -237,30 +237,5 @@ public class MainTest {
         assertThat(ex.getCause()).hasMessageStartingWith("interrupted while building");
     }
 
-    /**
-     * Tests buildTopicServer() when the provider class is invalid.
-     */
-    @Test
-    public void testBuildTopicServerInvalidProvider() {
-        assertThatThrownBy(() -> new Main("invalidTopicServer.json").start())
-                        .hasCauseInstanceOf(IllegalArgumentException.class);
-    }
-
-    /**
-     * Tests buildTopicServer() when the sink is missing.
-     */
-    @Test
-    public void testBuildTopicServerNoSink() {
-        assertThatThrownBy(() -> new Main("missingSink.json").start())
-                        .hasCauseInstanceOf(IllegalArgumentException.class);
-    }
 
-    /**
-     * Tests buildTopicServer() when the sink is missing.
-     */
-    @Test
-    public void testBuildTopicServerNoSource() {
-        assertThatThrownBy(() -> new Main("missingSource.json").start())
-                        .hasCauseInstanceOf(IllegalArgumentException.class);
-    }
 }