summaryrefslogtreecommitdiffstats
path: root/models-sim/models-sim-dmaap/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-07-12 15:25:53 -0400
committerJim Hahn <jrh3@att.com>2021-07-12 17:04:14 -0400
commit6be3c1abaf5c3eea0b353675835b6d2ce4584fe7 (patch)
treead5376e94d48eb518670939823702d18c49b3f11 /models-sim/models-sim-dmaap/src/test
parent886406e003934b83da7a2b538a0574a76fd5dd4d (diff)
Delete extra simulator docker images
The policy-models-simulator docker image, built from models-sim/packages, subsumes the functionality of the other simulator images. Deleted the other images. This simulator still needs some of the code from the dmaap-sim modules, so only deleted the code from the latter that is not needed by this simulator. Also modified the simulator launch script to use sh instead of bash. Issue-ID: POLICY-3474 Change-Id: Ie7f69b327a18c3e07f154124ae38975d5e6924f0 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-sim/models-sim-dmaap/src/test')
-rw-r--r--models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/DmaapSimXxxExceptionTest.java37
-rw-r--r--models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/CommonRestServer.java114
-rw-r--r--models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/e2e/EndToEndTest.java273
-rw-r--r--models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/parameters/CommonTestData.java89
-rw-r--r--models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/parameters/DmaapSimParameterHandlerTest.java71
-rw-r--r--models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/startstop/DmaapSimActivatorTest.java98
-rw-r--r--models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/startstop/MainTest.java115
-rw-r--r--models-sim/models-sim-dmaap/src/test/resources/parameters/EmptyParameterFile.json0
-rw-r--r--models-sim/models-sim-dmaap/src/test/resources/parameters/EmptyParameters.json1
-rw-r--r--models-sim/models-sim-dmaap/src/test/resources/parameters/InvalidParameters.json3
-rw-r--r--models-sim/models-sim-dmaap/src/test/resources/parameters/MinimumParameters.json8
-rw-r--r--models-sim/models-sim-dmaap/src/test/resources/parameters/NoParameters.json2
-rw-r--r--models-sim/models-sim-dmaap/src/test/resources/parameters/Parameters_InvalidName.json10
-rw-r--r--models-sim/models-sim-dmaap/src/test/resources/parameters/TopicParameters.json36
14 files changed, 0 insertions, 857 deletions
diff --git a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/DmaapSimXxxExceptionTest.java b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/DmaapSimXxxExceptionTest.java
deleted file mode 100644
index ac72e5ee8..000000000
--- a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/DmaapSimXxxExceptionTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.sim.dmaap;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-import org.onap.policy.common.utils.test.ExceptionsTester;
-
-public class DmaapSimXxxExceptionTest {
-
- @Test
- public void testDmaapSimException() {
- assertEquals(3, new ExceptionsTester().test(DmaapSimException.class));
- }
-
- @Test
- public void testDmaapSimRuntimeException() {
- assertEquals(3, new ExceptionsTester().test(DmaapSimRuntimeException.class));
- }
-}
diff --git a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/CommonRestServer.java b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/CommonRestServer.java
deleted file mode 100644
index 7b72e9250..000000000
--- a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/CommonRestServer.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.sim.dmaap.rest;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.nio.charset.StandardCharsets;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import lombok.Getter;
-import org.glassfish.jersey.client.ClientProperties;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.gson.GsonMessageBodyHandler;
-import org.onap.policy.common.utils.network.NetworkUtil;
-import org.onap.policy.sim.dmaap.parameters.CommonTestData;
-
-/**
- * Common base class for rest server tests.
- */
-public class CommonRestServer {
- public static final String NOT_ALIVE = "not alive";
- public static final String ALIVE = "alive";
- public static final String SELF = "self";
- public static final String NAME = "DMaaP Simulator";
- public static final String ENDPOINT_PREFIX = "events/";
-
- protected static final String CONFIG_FILE = "src/test/resources/parameters/TestConfigParams.json";
-
- @Getter
- private static int port;
-
- protected static String httpPrefix;
-
- /**
- * Allocates a port for the server, writes a config file.
- *
- * @throws Exception if an error occurs
- */
- public static void reconfigure() throws Exception {
- port = NetworkUtil.allocPort();
-
- httpPrefix = "http://localhost:" + port + "/";
-
- String json = new CommonTestData().getParameterGroupAsString(port);
- makeConfigFile(CONFIG_FILE, json);
-
- HttpServletServerFactoryInstance.getServerFactory().destroy();
- }
-
- /**
- * Makes a parameter configuration file.
- * @param fileName name of the config file to be created
- * @param json json to be written to the file
- *
- * @throws Exception if an error occurs
- */
- protected static void makeConfigFile(String fileName, String json) throws Exception {
- File file = new File(fileName);
- file.deleteOnExit();
-
- try (FileOutputStream output = new FileOutputStream(file)) {
- output.write(json.getBytes(StandardCharsets.UTF_8));
- }
- }
-
- /**
- * Sends a request to an endpoint.
- *
- * @param endpoint the target endpoint
- * @return a request builder
- * @throws Exception if an error occurs
- */
- protected Invocation.Builder sendRequest(final String endpoint) throws Exception {
- return sendFqeRequest(httpPrefix + ENDPOINT_PREFIX + endpoint);
- }
-
- /**
- * Sends a request to a fully qualified endpoint.
- *
- * @param fullyQualifiedEndpoint the fully qualified target endpoint
- * @return a request builder
- */
- protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint) {
- final Client client = ClientBuilder.newBuilder().build();
-
- client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
- client.register(GsonMessageBodyHandler.class);
-
- final WebTarget webTarget = client.target(fullyQualifiedEndpoint);
-
- return webTarget.request(MediaType.APPLICATION_JSON);
- }
-}
diff --git a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/e2e/EndToEndTest.java b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/e2e/EndToEndTest.java
deleted file mode 100644
index 5a83b4693..000000000
--- a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/e2e/EndToEndTest.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.sim.dmaap.e2e;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import com.att.nsa.cambria.client.CambriaClientBuilders;
-import com.att.nsa.cambria.client.CambriaClientBuilders.ConsumerBuilder;
-import com.att.nsa.cambria.client.CambriaConsumer;
-import java.io.File;
-import java.io.PrintWriter;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.security.GeneralSecurityException;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-import java.util.function.BiConsumer;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.common.utils.network.NetworkUtil;
-import org.onap.policy.common.utils.services.Registry;
-import org.onap.policy.models.sim.dmaap.DmaapSimException;
-import org.onap.policy.models.sim.dmaap.rest.CommonRestServer;
-import org.onap.policy.models.sim.dmaap.startstop.Main;
-
-/**
- * This tests the simulator using dmaap endpoints to verify that it works from publisher
- * to subscriber.
- */
-public class EndToEndTest extends CommonRestServer {
- private static final int MAX_WAIT_SEC = 5;
- private static final String TOPIC = "MY-TOPIC";
- private static final String TOPIC2 = "MY-TOPIC-B";
- private static final String TOPIC3 = "MY-TOPIC-C";
- private static final int MAX_MSG = 200;
-
- private static Main main;
-
- /**
- * Messages from the topic are placed here by the endpoint.
- */
- private static BlockingQueue<String> queue;
-
- /**
- * Messages from topic 2 are placed here by the endpoint.
- */
- private static BlockingQueue<String> queue2;
-
- /**
- * Topic configuration parameters.
- */
- private static TopicParameterGroup topicConfig;
-
- /**
- * The "host:port", extracted from <i>httpPrefix</i>.
- */
- private static String hostPort;
-
- /**
- * Unique consumer name used by a single test case.
- */
- private int consumerName;
-
- /**
- * Starts the rest server.
- *
- * @throws Exception if an error occurs
- */
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- TopicEndpointManager.getManager().shutdown();
-
- CommonRestServer.reconfigure();
-
- startMain();
-
- queue = new LinkedBlockingQueue<>();
- queue2 = new LinkedBlockingQueue<>();
-
- String json = new String(
- Files.readAllBytes(new File("src/test/resources/parameters/TopicParameters.json").toPath()),
- StandardCharsets.UTF_8);
- json = json.replace("${port}", String.valueOf(getPort()));
-
- topicConfig = new StandardCoder().decode(json, TopicParameterGroup.class);
-
- TopicEndpointManager.getManager().addTopics(topicConfig);
- TopicEndpointManager.getManager().start();
-
- TopicEndpointManager.getManager().getDmaapTopicSource(TOPIC)
- .register((infra, topic, event) -> queue.add(event));
- TopicEndpointManager.getManager().getDmaapTopicSource(TOPIC2)
- .register((infra, topic, event) -> queue2.add(event));
-
- hostPort = httpPrefix.substring(httpPrefix.indexOf("http://"), httpPrefix.length() - 1);
- }
-
- /**
- * Stops the topics and clears the queues.
- */
- @AfterClass
- public static void tearDownAfterClass() throws DmaapSimException {
- TopicEndpointManager.getManager().shutdown();
-
- queue = null;
- queue2 = null;
-
- main.shutdown();
- }
-
- /**
- * Starts the topics.
- *
- * @throws CoderException if the parameters cannot be decoded
- */
- @Before
- public void setUp() {
- ++consumerName;
-
- queue.clear();
- queue2.clear();
- }
-
- @Test
- public void testWithTopicEndpointAtEachEnd() throws InterruptedException {
- // publish events
- TopicSink sink = TopicEndpointManager.getManager().getDmaapTopicSink(TOPIC);
- TopicSink sink2 = TopicEndpointManager.getManager().getDmaapTopicSink(TOPIC2);
- for (int x = 0; x < MAX_MSG; ++x) {
- sink.send("hello-" + x);
- sink2.send("world-" + x);
- }
-
- // verify events where received
- for (int x = 0; x < MAX_MSG; ++x) {
- assertEquals("message " + x, "hello-" + x, queue.poll(MAX_WAIT_SEC, TimeUnit.SECONDS));
- assertEquals("message " + x, "world-" + x, queue2.poll(MAX_WAIT_SEC, TimeUnit.SECONDS));
- }
- }
-
- @Test
- public void testCambriaFormat() throws Exception {
- // @formatter:off
- test("testCambriaFormat", "application/cambria",
- (wtr, messages) -> messages.forEach(msg -> wtr.write("0." + msg.length() + "." + msg + "\n")));
- // @formatter:on
- }
-
- @Test
- public void testJson() throws Exception {
- test("testJson", "application/json", (wtr, messages) -> wtr.write("[" + String.join(", ", messages) + "]"));
- }
-
- @Test
- public void testText() throws Exception {
- test("testText", "text/plain", (wtr, messages) -> messages.forEach(wtr::println));
- }
-
- /**
- * Uses a raw URL connection to ensure the server can process messages of the given
- * media type.
- *
- * @param testName name of the test
- * @param mediaType media type
- * @param writeMessages function that writes messages to a PrintWriter
- * @throws Exception if an error occurs
- */
- private void test(String testName, String mediaType, BiConsumer<PrintWriter, List<String>> writeMessages)
- throws Exception {
-
- /*
- * Force consumer name to be registered with the server by attempting to fetch a message.
- */
- buildConsumer(0).fetch();
-
- String msg1 = "{'abc':10.0}".replace('\'', '"');
- String msg2 = "{'def':20.0}".replace('\'', '"');
-
- URL url = new URL(httpPrefix + "events/" + TOPIC3);
-
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("POST");
- conn.setRequestProperty("Content-type", mediaType);
- conn.setDoOutput(true);
- conn.connect();
-
- try (PrintWriter wtr = new PrintWriter(conn.getOutputStream())) {
- writeMessages.accept(wtr, Arrays.asList(msg1, msg2));
- }
-
- assertEquals(testName + " response code", HttpURLConnection.HTTP_OK, conn.getResponseCode());
-
- // fetch the messages
- Iterator<String> iter = buildConsumer(1000).fetch().iterator();
-
- assertTrue(testName + " have message 1", iter.hasNext());
- assertEquals(testName + " message 1", msg1, iter.next());
-
- assertTrue(testName + " have message 2", iter.hasNext());
- assertEquals(testName + " message 2", msg2, iter.next());
-
- // no more messages
- assertFalse(testName + " extra message", iter.hasNext());
- }
-
- private CambriaConsumer buildConsumer(int timeoutMs) throws MalformedURLException, GeneralSecurityException {
- ConsumerBuilder builder = new CambriaClientBuilders.ConsumerBuilder();
-
- builder.knownAs(String.valueOf(consumerName), "my-consumer-id")
- .usingHosts(hostPort).onTopic(TOPIC3)
- .waitAtServer(timeoutMs).receivingAtMost(5);
-
- builder.withSocketTimeout(timeoutMs + 2000);
-
- return builder.build();
- }
-
- /**
- * Starts the "Main".
- *
- * @throws Exception if an error occurs
- */
- private static void startMain() throws Exception {
- Registry.newRegistry();
-
- int port = CommonRestServer.getPort();
-
- // make sure port is available
- if (NetworkUtil.isTcpPortOpen("localhost", port, 1, 1L)) {
- throw new IllegalStateException("port " + port + " is still in use");
- }
-
- final String[] simConfigParameters = {"-c", "src/test/resources/parameters/TestConfigParams.json"};
-
- main = new Main(simConfigParameters);
-
- if (!NetworkUtil.isTcpPortOpen("localhost", port, 300, 200L)) {
- throw new IllegalStateException("server is not listening on port " + port);
- }
- }
-}
diff --git a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/parameters/CommonTestData.java b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/parameters/CommonTestData.java
deleted file mode 100644
index 21d9ed604..000000000
--- a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/parameters/CommonTestData.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.sim.dmaap.parameters;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import org.onap.policy.common.utils.coder.Coder;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.models.sim.dmaap.DmaapSimRuntimeException;
-import org.onap.policy.models.sim.dmaap.parameters.DmaapSimParameterGroup;
-
-/**
- * Class to hold/create all parameters for test cases.
- */
-public class CommonTestData {
- public static final String SIM_GROUP_NAME = "DMaapSim";
-
- private static final Coder coder = new StandardCoder();
-
- /**
- * Gets the standard simulator parameters.
- *
- * @param port port to be inserted into the parameters
- * @return the standard simulator parameters
- */
- public DmaapSimParameterGroup getParameterGroup(int port) {
- try {
- return coder.decode(getParameterGroupAsString(port), DmaapSimParameterGroup.class);
-
- } catch (CoderException e) {
- throw new DmaapSimRuntimeException("cannot read simulator parameters", e);
- }
- }
-
- /**
- * Gets the standard simulator parameters, as a String.
- *
- * @param port port to be inserted into the parameters
- * @return the standard simulator parameters
- */
- public String getParameterGroupAsString(int port) {
-
- try {
- File file = new File("src/test/resources/parameters/NormalParameters.json");
- String json = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
-
- json = json.replace("6845", String.valueOf(port));
-
- return json;
-
- } catch (IOException e) {
- throw new DmaapSimRuntimeException("cannot read simulator parameters", e);
- }
- }
-
- /**
- * Nulls out a field within a JSON string. It does it by adding a field with the same
- * name, having a null value, and then prefixing the original field name with "Xxx",
- * thus causing the original field and value to be ignored.
- *
- * @param json JSON string
- * @param field field to be nulled out
- * @return a new JSON string with the field nulled out
- */
- public String nullifyField(String json, String field) {
- return json.replace(field + "\"", field + "\":null, \"" + field + "Xxx\"");
- }
-}
diff --git a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/parameters/DmaapSimParameterHandlerTest.java b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/parameters/DmaapSimParameterHandlerTest.java
deleted file mode 100644
index ca6712388..000000000
--- a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/parameters/DmaapSimParameterHandlerTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.sim.dmaap.parameters;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.common.utils.cmd.CommandLineException;
-import org.onap.policy.models.sim.dmaap.DmaapSimException;
-import org.onap.policy.models.sim.dmaap.parameters.DmaapSimParameterGroup;
-import org.onap.policy.models.sim.dmaap.parameters.DmaapSimParameterHandler;
-import org.onap.policy.models.sim.dmaap.startstop.DmaapSimCommandLineArguments;
-
-public class DmaapSimParameterHandlerTest {
-
- private static final String RESOURCE_DIR = "src/test/resources/parameters/";
-
- private DmaapSimParameterHandler handler;
-
- @Before
- public void setUp() {
- handler = new DmaapSimParameterHandler();
- }
-
- @Test
- public void testGetParameters() throws DmaapSimException, CommandLineException {
- final DmaapSimCommandLineArguments args = new DmaapSimCommandLineArguments();
-
- args.parse(new String[] {"-c", RESOURCE_DIR + "NormalParameters.json"});
- DmaapSimParameterGroup params = handler.getParameters(args);
- assertNotNull(params);
- assertEquals("DMaapSim", params.getName());
- assertEquals(300L, params.getTopicSweepSec());
- assertEquals(6845, params.getRestServerParameters().getPort());
-
-
- args.parse(new String[] {"-c", "FileNotFound.json"});
- assertThatThrownBy(() -> handler.getParameters(args)).isInstanceOf(DmaapSimException.class)
- .hasMessageStartingWith("error reading parameters");
-
-
- args.parse(new String[] {"-c", RESOURCE_DIR + "EmptyParameterFile.json"});
- assertThatThrownBy(() -> handler.getParameters(args)).isInstanceOf(DmaapSimException.class)
- .hasMessageStartingWith("no parameters found");
-
-
- args.parse(new String[] {"-c", RESOURCE_DIR + "Parameters_InvalidName.json"});
- assertThatThrownBy(() -> handler.getParameters(args)).isInstanceOf(DmaapSimException.class)
- .hasMessageContaining("validation error");
- }
-}
diff --git a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/startstop/DmaapSimActivatorTest.java b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/startstop/DmaapSimActivatorTest.java
deleted file mode 100644
index 810c16bc6..000000000
--- a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/startstop/DmaapSimActivatorTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.sim.dmaap.startstop;
-
-import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.utils.services.Registry;
-import org.onap.policy.models.sim.dmaap.parameters.DmaapSimParameterGroup;
-import org.onap.policy.models.sim.dmaap.parameters.DmaapSimParameterHandler;
-import org.onap.policy.models.sim.dmaap.rest.CommonRestServer;
-import org.onap.policy.models.sim.dmaap.startstop.DmaapSimActivator;
-import org.onap.policy.models.sim.dmaap.startstop.DmaapSimCommandLineArguments;
-
-
-/**
- * Class to perform unit test of {@link DmaapSimActivator}}.
- */
-public class DmaapSimActivatorTest extends CommonRestServer {
-
- private DmaapSimActivator activator;
-
- /**
- * Initializes an activator.
- *
- * @throws Exception if an error occurs
- */
- @Before
- public void setUp() throws Exception {
- Registry.newRegistry();
- HttpServletServerFactoryInstance.getServerFactory().destroy();
-
- CommonRestServer.reconfigure();
-
- final String[] papConfigParameters = {"-c", CONFIG_FILE};
- final DmaapSimCommandLineArguments arguments = new DmaapSimCommandLineArguments(papConfigParameters);
- final DmaapSimParameterGroup parGroup = new DmaapSimParameterHandler().getParameters(arguments);
-
- activator = new DmaapSimActivator(parGroup);
- }
-
- /**
- * Method for cleanup after each test.
- *
- * @throws Exception if an error occurs
- */
- @After
- public void teardown() throws Exception {
- if (activator != null && activator.isAlive()) {
- activator.stop();
- }
- }
-
- @Test
- public void testDmaapSimActivator() {
- assertFalse(activator.isAlive());
- activator.start();
- assertTrue(activator.isAlive());
-
- // repeat - should throw an exception
- assertThatIllegalStateException().isThrownBy(() -> activator.start());
- assertTrue(activator.isAlive());
- }
-
- @Test
- public void testTerminate() {
- activator.start();
- activator.stop();
- assertFalse(activator.isAlive());
-
- // repeat - should throw an exception
- assertThatIllegalStateException().isThrownBy(() -> activator.stop());
- assertFalse(activator.isAlive());
- }
-}
diff --git a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/startstop/MainTest.java b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/startstop/MainTest.java
deleted file mode 100644
index 1d6c68a49..000000000
--- a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/startstop/MainTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property.
- * Modifications Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.sim.dmaap.startstop;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.models.sim.dmaap.rest.CommonRestServer;
-import org.onap.policy.models.sim.dmaap.startstop.DmaapSimCommandLineArguments;
-import org.onap.policy.models.sim.dmaap.startstop.Main;
-import org.onap.policy.sim.dmaap.parameters.CommonTestData;
-
-/**
- * Class to perform unit test of {@link Main}}.
- *
- * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
- */
-public class MainTest extends CommonRestServer {
- private Main main;
-
- /**
- * Sets up.
- */
- @Before
- public void setUp() {
- main = null;
- HttpServletServerFactoryInstance.getServerFactory().destroy();
- }
-
- /**
- * Shuts "main" down.
- *
- * @throws Exception if an error occurs
- */
- @After
- public void tearDown() throws Exception {
- if (main != null) {
- main.shutdown();
- }
- }
-
- @Test
- public void testMain() throws Exception {
- CommonRestServer.reconfigure();
- final String[] NormalParameters = {"-c", CONFIG_FILE};
- main = new Main(NormalParameters);
- assertTrue(main.getParameters().isValid());
- assertEquals(CommonTestData.SIM_GROUP_NAME, main.getParameters().getName());
-
- main.shutdown();
- }
-
- @Test
- public void testMain_NoArguments() {
- final String[] NormalParameters = {};
- main = new Main(NormalParameters);
- assertNull(main.getParameters());
- }
-
- @Test
- public void testMain_InvalidArguments() throws Exception {
- CommonRestServer.reconfigure();
-
- // note: this is missing the "-c" argument, thus the ARGUMENTS are invalid
- final String[] NormalParameters = {CONFIG_FILE};
- main = new Main(NormalParameters);
- assertNull(main.getParameters());
- }
-
- @Test
- public void testMain_Help() {
- final String[] NormalParameters = {"-h"};
- assertThatCode(() -> Main.main(NormalParameters)).doesNotThrowAnyException();
- }
-
- @Test
- public void testMain_InvalidParameters() {
- final String[] NormalParameters = {"-c", "parameters/InvalidParameters.json"};
- main = new Main(NormalParameters);
- assertNull(main.getParameters());
- }
-
- @Test
- public void testDmaapSimVersion() {
- String[] testArgs = {"-v"};
- DmaapSimCommandLineArguments sutArgs = new DmaapSimCommandLineArguments(testArgs);
- assertThat(sutArgs.version()).startsWith("ONAP DMaaP simulator Service");
- }
-}
diff --git a/models-sim/models-sim-dmaap/src/test/resources/parameters/EmptyParameterFile.json b/models-sim/models-sim-dmaap/src/test/resources/parameters/EmptyParameterFile.json
deleted file mode 100644
index e69de29bb..000000000
--- a/models-sim/models-sim-dmaap/src/test/resources/parameters/EmptyParameterFile.json
+++ /dev/null
diff --git a/models-sim/models-sim-dmaap/src/test/resources/parameters/EmptyParameters.json b/models-sim/models-sim-dmaap/src/test/resources/parameters/EmptyParameters.json
deleted file mode 100644
index 0637a088a..000000000
--- a/models-sim/models-sim-dmaap/src/test/resources/parameters/EmptyParameters.json
+++ /dev/null
@@ -1 +0,0 @@
-[] \ No newline at end of file
diff --git a/models-sim/models-sim-dmaap/src/test/resources/parameters/InvalidParameters.json b/models-sim/models-sim-dmaap/src/test/resources/parameters/InvalidParameters.json
deleted file mode 100644
index de2040cc8..000000000
--- a/models-sim/models-sim-dmaap/src/test/resources/parameters/InvalidParameters.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "name" : []
-} \ No newline at end of file
diff --git a/models-sim/models-sim-dmaap/src/test/resources/parameters/MinimumParameters.json b/models-sim/models-sim-dmaap/src/test/resources/parameters/MinimumParameters.json
deleted file mode 100644
index a1c98a5b1..000000000
--- a/models-sim/models-sim-dmaap/src/test/resources/parameters/MinimumParameters.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "name":"DMaapSim",
- "topicSweepSec": 1,
- "restServerParameters":{
- "host":"0.0.0.0",
- "port":6845
- }
-}
diff --git a/models-sim/models-sim-dmaap/src/test/resources/parameters/NoParameters.json b/models-sim/models-sim-dmaap/src/test/resources/parameters/NoParameters.json
deleted file mode 100644
index 7a73a41bf..000000000
--- a/models-sim/models-sim-dmaap/src/test/resources/parameters/NoParameters.json
+++ /dev/null
@@ -1,2 +0,0 @@
-{
-} \ No newline at end of file
diff --git a/models-sim/models-sim-dmaap/src/test/resources/parameters/Parameters_InvalidName.json b/models-sim/models-sim-dmaap/src/test/resources/parameters/Parameters_InvalidName.json
deleted file mode 100644
index 51e9458b0..000000000
--- a/models-sim/models-sim-dmaap/src/test/resources/parameters/Parameters_InvalidName.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "name":" ",
- "topicSweepSec": 1,
- "restServerParameters":{
- "host":"0.0.0.0",
- "port":6969,
- "userName":"dmaapsim",
- "password":"zb!XztG34"
- }
-}
diff --git a/models-sim/models-sim-dmaap/src/test/resources/parameters/TopicParameters.json b/models-sim/models-sim-dmaap/src/test/resources/parameters/TopicParameters.json
deleted file mode 100644
index 77a320f6d..000000000
--- a/models-sim/models-sim-dmaap/src/test/resources/parameters/TopicParameters.json
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "topicSources": [
- {
- "topic": "MY-TOPIC",
- "servers": [
- "localhost:${port}"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 100
- },
- {
- "topic": "MY-TOPIC-B",
- "servers": [
- "localhost:${port}"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 100
- }
- ],
- "topicSinks": [
- {
- "topic": "MY-TOPIC",
- "servers": [
- "localhost:${port}"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "MY-TOPIC-B",
- "servers": [
- "localhost:${port}"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
-} \ No newline at end of file