summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-simulators
diff options
context:
space:
mode:
authorrameshiyer27 <ramesh.murugan.iyer@est.tech>2024-01-29 09:23:58 +0000
committerRamesh Murugan Iyer <ramesh.murugan.iyer@est.tech>2024-02-08 14:29:41 +0000
commit49f07db935d114b72a44e446867b16262dd552aa (patch)
treef6867985541acb76f1e5279ed4104c86dc7adffb /models-interactions/model-simulators
parent71be21fd5b9b52c613bb855f00a79a51e81906dd (diff)
Remove dmaap from models
Issue-ID: POLICY-4402 Change-Id: Icead1601984f463e557b969f2792f0f0aa05f060 Signed-off-by: rameshiyer27 <ramesh.murugan.iyer@est.tech>
Diffstat (limited to 'models-interactions/model-simulators')
-rw-r--r--models-interactions/model-simulators/pom.xml7
-rw-r--r--models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AppcLcmTopicServer.java9
-rw-r--r--models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java51
-rw-r--r--models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/dmaap/AuthDmaapParameters.json12
-rw-r--r--models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/dmaap/DmaapParameters.json8
-rw-r--r--models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLcmTopicServerTest.java3
-rw-r--r--models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/DmaapSimulatorTest.java193
-rw-r--r--models-interactions/model-simulators/src/test/resources/org/onap/policy/simulators/dmaap/TopicParameters.json44
8 files changed, 9 insertions, 318 deletions
diff --git a/models-interactions/model-simulators/pom.xml b/models-interactions/model-simulators/pom.xml
index 98f00b6db..a3c3dea19 100644
--- a/models-interactions/model-simulators/pom.xml
+++ b/models-interactions/model-simulators/pom.xml
@@ -3,7 +3,7 @@
ONAP
================================================================================
Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
- Modifications Copyright (C) 2019, 2023 Nordix Foundation.
+ Modifications Copyright (C) 2019, 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.
@@ -96,11 +96,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.onap.policy.models.sim</groupId>
- <artifactId>policy-models-sim-dmaap</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>compile</scope>
diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AppcLcmTopicServer.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AppcLcmTopicServer.java
index a8ec6e5e9..62e1acc9c 100644
--- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AppcLcmTopicServer.java
+++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AppcLcmTopicServer.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -20,7 +21,7 @@
package org.onap.policy.simulators;
-import org.onap.policy.appclcm.AppcLcmDmaapWrapper;
+import org.onap.policy.appclcm.AppcLcmMessageWrapper;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -29,14 +30,14 @@ import org.onap.policy.common.utils.resources.ResourceUtils;
/**
* APPC-LCM topic server.
*/
-public class AppcLcmTopicServer extends TopicServer<AppcLcmDmaapWrapper> {
+public class AppcLcmTopicServer extends TopicServer<AppcLcmMessageWrapper> {
public AppcLcmTopicServer(TopicSink sink, TopicSource source) {
- super(sink, source, new StandardCoder(), AppcLcmDmaapWrapper.class);
+ super(sink, source, new StandardCoder(), AppcLcmMessageWrapper.class);
}
@Override
- protected String process(AppcLcmDmaapWrapper request) {
+ protected String process(AppcLcmMessageWrapper request) {
/*
* In case the request and response are on the same topic, this may be invoked
* with a request or with a response object. If the "output" is not null, then we
diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java
index bbe1a3604..37c1b0c2c 100644
--- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java
+++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java
@@ -3,7 +3,7 @@
* simulators
* ================================================================================
* Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019, 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 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.
@@ -26,14 +26,7 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
-import org.onap.policy.common.parameters.ParameterRuntimeException;
-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.resources.ResourceUtils;
-import org.onap.policy.models.sim.dmaap.parameters.DmaapSimParameterGroup;
-import org.onap.policy.models.sim.dmaap.provider.DmaapSimProvider;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class Util {
@@ -49,7 +42,6 @@ public final class Util {
public static final int XACMLSIM_SERVER_PORT = 6669;
public static final int SDNCSIM_SERVER_PORT = 6670;
public static final int CDSSIM_SERVER_PORT = 6671;
- public static final int DMAAPSIM_SERVER_PORT = 3904;
private static final String CANNOT_PROCESS_PARAMETERS = "cannot parse parameters ";
private static final String CANNOT_CONNECT = "cannot connect to port ";
@@ -155,47 +147,6 @@ public final class Util {
return testServer;
}
- /**
- * Builds an unauthenticated HTTP DMaaP simulator.
- *
- * @return the simulator
- * @throws InterruptedException if a thread is interrupted
- */
- public static HttpServletServer buildDmaapSim() throws InterruptedException {
- return buildDmaapSim("org/onap/policy/simulators/dmaap/DmaapParameters.json");
- }
-
- /**
- * Build a DMaaP simulator from a properties file.
- *
- * @param resourceName the name of the properties file
- * @return the simulator
- * @throws InterruptedException if a thread is interrupted
- */
- public static HttpServletServer buildDmaapSim(String resourceName) throws InterruptedException {
- var json = ResourceUtils.getResourceAsString(resourceName);
- DmaapSimParameterGroup params;
- try {
- params = new StandardCoder().decode(json, DmaapSimParameterGroup.class);
- } catch (CoderException ce) {
- throw new ParameterRuntimeException(
- CANNOT_PROCESS_PARAMETERS + resourceName, ce);
- }
-
- DmaapSimProvider.setInstance(new DmaapSimProvider(params));
-
- var props = params.getRestServerParameters().getServerProperties();
-
- final String svcpfx = PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
- + params.getRestServerParameters().getName();
- props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX, "true");
-
- HttpServletServer testServer = HttpServletServerFactoryInstance.getServerFactory().build(props).get(0);
- testServer.waitedStart(5000);
- waitForServerToListen(testServer.getPort());
- return testServer;
- }
-
private static void waitForServerToListen(int port) throws InterruptedException {
if (!NetworkUtil.isTcpPortOpen(LOCALHOST, port, 200, 250L)) {
throw new IllegalStateException(CANNOT_CONNECT + port);
diff --git a/models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/dmaap/AuthDmaapParameters.json b/models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/dmaap/AuthDmaapParameters.json
deleted file mode 100644
index cd84faf1e..000000000
--- a/models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/dmaap/AuthDmaapParameters.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "name": "AuthDMaapSim",
- "topicSweepSec": 300,
- "restServerParameters": {
- "host": "0.0.0.0",
- "port": 3903,
- "sniHostCheck": false,
- "useHttps": true,
- "userName": "my-username",
- "password": "my-password"
- }
-}
diff --git a/models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/dmaap/DmaapParameters.json b/models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/dmaap/DmaapParameters.json
deleted file mode 100644
index b704f6f14..000000000
--- a/models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/dmaap/DmaapParameters.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "name": "DMaapSim",
- "topicSweepSec": 300,
- "restServerParameters": {
- "host": "0.0.0.0",
- "port": 3904
- }
-}
diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLcmTopicServerTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLcmTopicServerTest.java
index 9560658a8..c1badf67b 100644
--- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLcmTopicServerTest.java
+++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLcmTopicServerTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -57,7 +58,7 @@ public class AppcLcmTopicServerTest {
}
@Test
- public void testProcessAppcLcmDmaapWrapper() {
+ public void testProcessAppcLcmMessageWrapper() {
String request = ResourceUtils.getResourceAsString("org/onap/policy/simulators/appclcm/appc.lcm.request.json");
assertNotNull(request);
diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/DmaapSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/DmaapSimulatorTest.java
deleted file mode 100644
index 5687e2197..000000000
--- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/DmaapSimulatorTest.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019, 2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2022 Bell Canada. 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.
- * 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.simulators;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.util.HashMap;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-import org.junit.After;
-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.bus.DmaapTopicSink;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.endpoints.http.server.internal.JettyJerseyServer;
-import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
-import org.onap.policy.common.utils.coder.StandardCoder;
-
-public class DmaapSimulatorTest {
- private static final int MAX_WAIT_SEC = 10;
- private static final String TOPIC = "my-topic";
- private static final String AUTH_TOPIC = "my-auth-topic";
- private static final String AUTH_PORT = "3903";
-
- private static final HashMap<String, String> savedValuesMap = new HashMap<>();
-
- /**
- * Messages from the topic are placed here by the endpoint.
- */
- private BlockingQueue<String> queue;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- TopicEndpointManager.getManager().shutdown();
- }
-
- /**
- * Starts the simulator and the topic.
- *
- * @throws Exception if an error occurs
- */
- @Before
- public void setUp() throws Exception {
- assertNotNull(Util.buildDmaapSim());
- setSystemProperties();
- assertNotNull(Util.buildDmaapSim("org/onap/policy/simulators/dmaap/AuthDmaapParameters.json"));
-
- String topicJson = Files.readString(
- new File("src/test/resources/org/onap/policy/simulators/dmaap/TopicParameters.json").toPath());
- topicJson = topicJson
- .replace("${port}", String.valueOf(Util.DMAAPSIM_SERVER_PORT))
- .replace("${authPort}", AUTH_PORT);
-
- TopicParameterGroup topicConfig = new StandardCoder().decode(topicJson, TopicParameterGroup.class);
-
- TopicEndpointManager.getManager().addTopics(topicConfig);
- TopicEndpointManager.getManager().start();
-
- queue = new LinkedBlockingQueue<>();
- }
-
- @AfterClass
- public static void tearDownAfterClass() {
- clearSystemProperties();
- }
-
- @After
- public void tearDown() {
- TopicEndpointManager.getManager().shutdown();
- HttpServletServerFactoryInstance.getServerFactory().destroy();
- }
-
- @Test
- public void test() throws InterruptedException {
- // test basic DMaaP simulator (default port, http, no auth)
- sendAndPoll(TOPIC);
- // test custom DMaaP simulator (custom port, https, basic auth)
- sendAndPoll(AUTH_TOPIC);
- }
-
- /**
- * Sets up keystore and truststore for https test server.
- */
- private static void setSystemProperties() {
- String keyStoreSystemProperty = System.getProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME);
- if (keyStoreSystemProperty != null) {
- savedValuesMap.put(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME, keyStoreSystemProperty);
- }
-
- String keyStorePasswordSystemProperty =
- System.getProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME);
- if (keyStorePasswordSystemProperty != null) {
- savedValuesMap.put(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME,
- keyStorePasswordSystemProperty);
- }
-
- String trustStoreSystemProperty = System.getProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME);
- if (trustStoreSystemProperty != null) {
- savedValuesMap.put(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME, trustStoreSystemProperty);
- }
-
- String trustStorePasswordSystemProperty =
- System.getProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME);
- if (trustStorePasswordSystemProperty != null) {
- savedValuesMap.put(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME,
- trustStorePasswordSystemProperty);
- }
-
- 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_TRUSTSTORE_PROPERTY_NAME, "src/test/resources/keystore-test");
- System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME, "kstest");
- }
-
- /**
- * Clears the keystore/truststore properties.
- */
- private static void clearSystemProperties() {
- if (savedValuesMap.containsKey(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME)) {
- System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME,
- savedValuesMap.get(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME));
- savedValuesMap.remove(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME);
- } else {
- System.clearProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME);
- }
-
- if (savedValuesMap.containsKey(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME)) {
- System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME,
- savedValuesMap.get(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME));
- savedValuesMap.remove(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME);
- } else {
- System.clearProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME);
- }
-
- if (savedValuesMap.containsKey(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME)) {
- System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME,
- savedValuesMap.get(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME));
- savedValuesMap.remove(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME);
- } else {
- System.clearProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME);
- }
-
- if (savedValuesMap.containsKey(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME)) {
- System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME,
- savedValuesMap.get(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME));
- savedValuesMap.remove(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME);
- } else {
- System.clearProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME);
- }
- }
-
- private void sendAndPoll(String topicName) throws InterruptedException {
- TopicEndpointManager.getManager().getDmaapTopicSource(topicName)
- .register((infra, topic, event) -> queue.add(event));
-
- DmaapTopicSink sink = TopicEndpointManager.getManager().getDmaapTopicSink(topicName);
- assertThat(queue.poll(1, TimeUnit.SECONDS)).isNull();
-
- sink.send("hello");
- assertEquals("hello", queue.poll(MAX_WAIT_SEC, TimeUnit.SECONDS));
-
- sink.send("world");
- assertEquals("world", queue.poll(MAX_WAIT_SEC, TimeUnit.SECONDS));
- }
-
-}
diff --git a/models-interactions/model-simulators/src/test/resources/org/onap/policy/simulators/dmaap/TopicParameters.json b/models-interactions/model-simulators/src/test/resources/org/onap/policy/simulators/dmaap/TopicParameters.json
deleted file mode 100644
index 03531918b..000000000
--- a/models-interactions/model-simulators/src/test/resources/org/onap/policy/simulators/dmaap/TopicParameters.json
+++ /dev/null
@@ -1,44 +0,0 @@
-{
- "topicSources": [
- {
- "topic": "MY-TOPIC",
- "servers": [
- "localhost:${port}"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 100
- },
- {
- "topic": "MY-AUTH-TOPIC",
- "servers": [
- "localhost:${authPort}"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 100,
- "useHttps": true,
- "allowSelfSignedCerts": true,
- "userName": "my-username",
- "password": "my-password"
- }
- ],
- "topicSinks": [
- {
- "topic": "MY-TOPIC",
- "servers": [
- "localhost:${port}"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "MY-AUTH-TOPIC",
- "servers": [
- "localhost:${authPort}"
- ],
- "topicCommInfrastructure": "dmaap",
- "useHttps": true,
- "allowSelfSignedCerts": true,
- "userName": "my-username",
- "password": "my-password"
- }
- ]
-} \ No newline at end of file