X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=models-sim%2Fpolicy-models-simulators%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fmodels%2Fsimulators%2FMainTest.java;h=09064f472e2363756ec0379006f5c606b9141e52;hb=49f07db935d114b72a44e446867b16262dd552aa;hp=bb4fa7c5a554d251cbf5becede3aa65acab8de6d;hpb=b2e63077887295b402a327692b2ab91cdecd3ef6;p=policy%2Fmodels.git diff --git a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java index bb4fa7c5a..09064f472 100644 --- a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java +++ b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java @@ -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 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); - } }