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=abc27f428f56975061b4301e3bf7cc52d12d1b1b;hpb=9591e2dd26eacd9fd44ac72c325b83ca3d3534f9;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 abc27f428..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 @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * 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("invalidDmaapParameters.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 @@ -145,11 +145,11 @@ public class MainTest { .allowSelfSignedCerts(true).basePath("aai").build(); HttpClient client = HttpClientFactoryInstance.getClientFactory().build(params); - Response response = client.get("/v8/network/generic-vnfs/generic-vnf/my-vnf"); + Response response = client.get("/v21/network/pnfs/pnf/demo-pnf"); assertEquals(200, response.getStatus()); String result = response.readEntity(String.class); - assertThat(result).contains("USUCP0PCOIL0110UJZZ01-vsrx"); + assertThat(result).contains("model-123456"); } /** @@ -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,27 +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()); - } - - /** - * Tests buildTopicServer() when the sink is missing. - */ - @Test - public void testBuildTopicServerNoSink() { - assertThatThrownBy(() -> new Main("missingSink.json").start()); - } - /** - * Tests buildTopicServer() when the sink is missing. - */ - @Test - public void testBuildTopicServerNoSource() { - assertThatThrownBy(() -> new Main("missingSource.json").start()); - } }