aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/test
diff options
context:
space:
mode:
authorrameshiyer27 <ramesh.murugan.iyer@est.tech>2024-01-25 14:25:37 +0000
committerrameshiyer27 <ramesh.murugan.iyer@est.tech>2024-02-07 14:59:50 +0000
commitbeeb5e3846c8457987711491bcb58a6567870591 (patch)
tree227cdd91b00f3889a1109d457f968472cb7ee596 /policy-endpoints/src/test
parent0241c0aa14447c99fccecc61e91b35051d6743be (diff)
Remove Dmaap references from policy-common
- updated dependencies for jakarta.* compabilities - other dependency updates for security fixes Issue-ID: POLICY-4881 Change-Id: I979d944fcd21279f618d1bcbfe12e914ba30077f Signed-off-by: rameshiyer27 <ramesh.murugan.iyer@est.tech>
Diffstat (limited to 'policy-endpoints/src/test')
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java101
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java133
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicPropertyBuilder.java154
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactoryTest.java170
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkTest.java34
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactoryTest.java207
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceTest.java34
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicPropertyBuilder.java22
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java124
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisherTest.java125
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.java83
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.java101
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java4
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java21
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java78
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafAuthFilter.java48
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafGranularAuthFilter.java47
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java8
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.json37
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.json15
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.json18
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/http/server/internal/HttpServerTest.json1
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_invalid.json3
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_valid.json3
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_all_params.json12
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_missing_mandatory.json10
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_valid.json24
27 files changed, 79 insertions, 1538 deletions
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java
index e47b2665..92dd6483 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2019-2020 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.
@@ -34,8 +35,6 @@ import java.util.Properties;
import org.junit.After;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicFactories;
-import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicPropertyBuilder;
import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicFactories;
import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicPropertyBuilder;
import org.onap.policy.common.endpoints.event.comm.bus.UebTopicFactories;
@@ -53,9 +52,6 @@ public class TopicEndpointProxyTest {
private static final String UEB_SOURCE_TOPIC = "ueb-source";
private static final String UEB_SINK_TOPIC = "ueb-sink";
- private static final String DMAAP_SOURCE_TOPIC = "dmaap-source";
- private static final String DMAAP_SINK_TOPIC = "dmaap-sink";
-
private Properties configuration = new Properties();
private TopicParameterGroup group = new TopicParameterGroup();
@@ -90,18 +86,6 @@ public class TopicEndpointProxyTest {
configuration.putAll(uebSinkBuilder.build());
group.getTopicSinks().add(uebSinkBuilder.getParams());
- DmaapTopicPropertyBuilder dmaapSourceBuilder =
- new DmaapTopicPropertyBuilder(PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS)
- .makeTopic(DMAAP_SOURCE_TOPIC);
- configuration.putAll(dmaapSourceBuilder.build());
- group.getTopicSources().add(dmaapSourceBuilder.getParams());
-
- DmaapTopicPropertyBuilder dmaapSinkBuilder =
- new DmaapTopicPropertyBuilder(PolicyEndPointProperties.PROPERTY_DMAAP_SINK_TOPICS)
- .makeTopic(DMAAP_SINK_TOPIC);
- configuration.putAll(dmaapSinkBuilder.build());
- group.getTopicSinks().add(dmaapSinkBuilder.getParams());
-
TopicParameters invalidCommInfraParams =
new NoopTopicPropertyBuilder(PolicyEndPointProperties.PROPERTY_NOOP_SOURCE_TOPICS)
.makeTopic(NOOP_SOURCE_TOPIC).getParams();
@@ -115,21 +99,19 @@ public class TopicEndpointProxyTest {
}
private <T extends Topic> boolean allSources(List<T> topics) {
- return exists(topics, NOOP_SOURCE_TOPIC) && exists(topics, UEB_SOURCE_TOPIC)
- && exists(topics, DMAAP_SOURCE_TOPIC);
+ return exists(topics, NOOP_SOURCE_TOPIC) && exists(topics, UEB_SOURCE_TOPIC);
}
private <T extends Topic> boolean allSinks(List<T> topics) {
- return exists(topics, NOOP_SINK_TOPIC) && exists(topics, UEB_SINK_TOPIC) && exists(topics, DMAAP_SINK_TOPIC);
+ return exists(topics, NOOP_SINK_TOPIC) && exists(topics, UEB_SINK_TOPIC);
}
private <T extends Topic> boolean anySource(List<T> topics) {
- return exists(topics, NOOP_SOURCE_TOPIC) || exists(topics, UEB_SOURCE_TOPIC)
- || exists(topics, DMAAP_SOURCE_TOPIC);
+ return exists(topics, NOOP_SOURCE_TOPIC) || exists(topics, UEB_SOURCE_TOPIC);
}
private <T extends Topic> boolean anySink(List<T> topics) {
- return exists(topics, NOOP_SINK_TOPIC) || exists(topics, UEB_SINK_TOPIC) || exists(topics, DMAAP_SINK_TOPIC);
+ return exists(topics, NOOP_SINK_TOPIC) || exists(topics, UEB_SINK_TOPIC);
}
/**
@@ -142,9 +124,6 @@ public class TopicEndpointProxyTest {
UebTopicFactories.getSinkFactory().destroy();
UebTopicFactories.getSourceFactory().destroy();
-
- DmaapTopicFactories.getSinkFactory().destroy();
- DmaapTopicFactories.getSourceFactory().destroy();
}
@Test
@@ -163,7 +142,7 @@ public class TopicEndpointProxyTest {
TopicEndpoint manager = new TopicEndpointProxy();
List<TopicSource> sources = manager.addTopicSources(group.getTopicSources());
- assertSame(3, sources.size());
+ assertSame(2, sources.size());
assertTrue(allSources(sources));
assertFalse(anySink(sources));
@@ -174,7 +153,7 @@ public class TopicEndpointProxyTest {
TopicEndpoint manager = new TopicEndpointProxy();
List<TopicSource> sources = manager.addTopicSources(configuration);
- assertSame(3, sources.size());
+ assertSame(2, sources.size());
assertTrue(allSources(sources));
assertFalse(anySink(sources));
@@ -185,7 +164,7 @@ public class TopicEndpointProxyTest {
TopicEndpoint manager = new TopicEndpointProxy();
List<TopicSink> sinks = manager.addTopicSinks(group.getTopicSinks());
- assertSame(3, sinks.size());
+ assertSame(2, sinks.size());
assertFalse(anySource(sinks));
assertTrue(allSinks(sinks));
@@ -196,7 +175,7 @@ public class TopicEndpointProxyTest {
TopicEndpoint manager = new TopicEndpointProxy();
List<TopicSink> sinks = manager.addTopicSinks(configuration);
- assertSame(3, sinks.size());
+ assertSame(2, sinks.size());
assertFalse(anySource(sinks));
assertTrue(allSinks(sinks));
@@ -207,7 +186,7 @@ public class TopicEndpointProxyTest {
TopicEndpoint manager = new TopicEndpointProxy();
List<Topic> topics = manager.addTopics(configuration);
- assertSame(6, topics.size());
+ assertSame(4, topics.size());
assertTrue(allSources(topics));
assertTrue(allSinks(topics));
@@ -218,7 +197,7 @@ public class TopicEndpointProxyTest {
TopicEndpoint manager = new TopicEndpointProxy();
List<Topic> topics = manager.addTopics(group);
- assertSame(6, topics.size());
+ assertSame(4, topics.size());
assertTrue(allSources(topics));
assertTrue(allSinks(topics));
@@ -257,7 +236,7 @@ public class TopicEndpointProxyTest {
manager.addTopicSinks(configuration);
List<TopicSource> sources = manager.getTopicSources();
- assertSame(3, sources.size());
+ assertSame(2, sources.size());
assertTrue(allSources(sources));
assertFalse(anySink(sources));
@@ -271,7 +250,7 @@ public class TopicEndpointProxyTest {
manager.addTopicSinks(configuration);
List<TopicSink> sinks = manager.getTopicSinks();
- assertSame(3, sinks.size());
+ assertSame(2, sinks.size());
assertFalse(anySource(sinks));
assertTrue(allSinks(sinks));
@@ -286,14 +265,6 @@ public class TopicEndpointProxyTest {
}
@Test
- public void testGetDmaapTopicSources() {
- TopicEndpoint manager = new TopicEndpointProxy();
-
- manager.addTopicSources(configuration);
- assertSame(1, manager.getDmaapTopicSources().size());
- }
-
- @Test
public void testGetNoopTopicSources() {
TopicEndpoint manager = new TopicEndpointProxy();
@@ -310,14 +281,6 @@ public class TopicEndpointProxyTest {
}
@Test
- public void testGetDmaapTopicSinks() {
- TopicEndpoint manager = new TopicEndpointProxy();
-
- manager.addTopicSinks(configuration);
- assertSame(1, manager.getDmaapTopicSinks().size());
- }
-
- @Test
public void testGetNoopTopicSinks() {
TopicEndpoint manager = new TopicEndpointProxy();
@@ -360,14 +323,11 @@ public class TopicEndpointProxyTest {
assertSame(NOOP_SOURCE_TOPIC, manager.getTopicSource(CommInfrastructure.NOOP, NOOP_SOURCE_TOPIC).getTopic());
assertSame(UEB_SOURCE_TOPIC, manager.getTopicSource(CommInfrastructure.UEB, UEB_SOURCE_TOPIC).getTopic());
- assertSame(DMAAP_SOURCE_TOPIC, manager.getTopicSource(CommInfrastructure.DMAAP, DMAAP_SOURCE_TOPIC).getTopic());
assertThatIllegalStateException()
.isThrownBy(() -> manager.getTopicSource(CommInfrastructure.NOOP, NOOP_SINK_TOPIC));
assertThatIllegalStateException()
.isThrownBy(() -> manager.getTopicSource(CommInfrastructure.UEB, UEB_SINK_TOPIC));
- assertThatIllegalStateException()
- .isThrownBy(() -> manager.getTopicSource(CommInfrastructure.DMAAP, DMAAP_SINK_TOPIC));
}
@Test
@@ -377,14 +337,11 @@ public class TopicEndpointProxyTest {
assertSame(NOOP_SINK_TOPIC, manager.getTopicSink(CommInfrastructure.NOOP, NOOP_SINK_TOPIC).getTopic());
assertSame(UEB_SINK_TOPIC, manager.getTopicSink(CommInfrastructure.UEB, UEB_SINK_TOPIC).getTopic());
- assertSame(DMAAP_SINK_TOPIC, manager.getTopicSink(CommInfrastructure.DMAAP, DMAAP_SINK_TOPIC).getTopic());
assertThatIllegalStateException()
.isThrownBy(() -> manager.getTopicSink(CommInfrastructure.NOOP, NOOP_SOURCE_TOPIC));
assertThatIllegalStateException()
.isThrownBy(() -> manager.getTopicSink(CommInfrastructure.UEB, UEB_SOURCE_TOPIC));
- assertThatIllegalStateException()
- .isThrownBy(() -> manager.getTopicSink(CommInfrastructure.DMAAP, DMAAP_SOURCE_TOPIC));
}
@Test
@@ -395,7 +352,6 @@ public class TopicEndpointProxyTest {
assertSame(UEB_SOURCE_TOPIC, manager.getUebTopicSource(UEB_SOURCE_TOPIC).getTopic());
assertThatIllegalStateException().isThrownBy(() -> manager.getUebTopicSource(NOOP_SOURCE_TOPIC));
- assertThatIllegalStateException().isThrownBy(() -> manager.getUebTopicSource(DMAAP_SOURCE_TOPIC));
assertThatIllegalArgumentException().isThrownBy(() -> manager.getUebTopicSource(null));
assertThatIllegalArgumentException().isThrownBy(() -> manager.getUebTopicSource(""));
@@ -409,48 +365,18 @@ public class TopicEndpointProxyTest {
assertSame(UEB_SINK_TOPIC, manager.getUebTopicSink(UEB_SINK_TOPIC).getTopic());
assertThatIllegalStateException().isThrownBy(() -> manager.getUebTopicSink(NOOP_SINK_TOPIC));
- assertThatIllegalStateException().isThrownBy(() -> manager.getUebTopicSink(DMAAP_SINK_TOPIC));
assertThatIllegalArgumentException().isThrownBy(() -> manager.getUebTopicSink(null));
assertThatIllegalArgumentException().isThrownBy(() -> manager.getUebTopicSink(""));
}
@Test
- public void testGetDmaapTopicSource() {
- TopicEndpoint manager = new TopicEndpointProxy();
- manager.addTopicSources(configuration);
-
- assertSame(DMAAP_SOURCE_TOPIC, manager.getDmaapTopicSource(DMAAP_SOURCE_TOPIC).getTopic());
-
- assertThatIllegalStateException().isThrownBy(() -> manager.getDmaapTopicSource(NOOP_SOURCE_TOPIC));
- assertThatIllegalStateException().isThrownBy(() -> manager.getDmaapTopicSource(UEB_SOURCE_TOPIC));
-
- assertThatIllegalArgumentException().isThrownBy(() -> manager.getDmaapTopicSource(null));
- assertThatIllegalArgumentException().isThrownBy(() -> manager.getDmaapTopicSource(""));
- }
-
- @Test
- public void testGetDmaapTopicSink() {
- TopicEndpoint manager = new TopicEndpointProxy();
- manager.addTopicSinks(configuration);
-
- assertSame(DMAAP_SINK_TOPIC, manager.getDmaapTopicSink(DMAAP_SINK_TOPIC).getTopic());
-
- assertThatIllegalStateException().isThrownBy(() -> manager.getDmaapTopicSink(NOOP_SINK_TOPIC));
- assertThatIllegalStateException().isThrownBy(() -> manager.getDmaapTopicSink(UEB_SINK_TOPIC));
-
- assertThatIllegalArgumentException().isThrownBy(() -> manager.getDmaapTopicSink(null));
- assertThatIllegalArgumentException().isThrownBy(() -> manager.getDmaapTopicSink(""));
- }
-
- @Test
public void testGetNoopTopicSource() {
TopicEndpoint manager = new TopicEndpointProxy();
manager.addTopicSources(configuration);
assertSame(NOOP_SOURCE_TOPIC, manager.getNoopTopicSource(NOOP_SOURCE_TOPIC).getTopic());
- assertThatIllegalStateException().isThrownBy(() -> manager.getNoopTopicSource(DMAAP_SOURCE_TOPIC));
assertThatIllegalStateException().isThrownBy(() -> manager.getNoopTopicSource(UEB_SOURCE_TOPIC));
assertThatIllegalArgumentException().isThrownBy(() -> manager.getNoopTopicSource(null));
@@ -464,7 +390,6 @@ public class TopicEndpointProxyTest {
assertSame(NOOP_SINK_TOPIC, manager.getNoopTopicSink(NOOP_SINK_TOPIC).getTopic());
- assertThatIllegalStateException().isThrownBy(() -> manager.getNoopTopicSink(DMAAP_SINK_TOPIC));
assertThatIllegalStateException().isThrownBy(() -> manager.getNoopTopicSink(UEB_SINK_TOPIC));
assertThatIllegalArgumentException().isThrownBy(() -> manager.getNoopTopicSink(null));
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java
deleted file mode 100644
index 92d5a865..00000000
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * policy-endpoints
- * ================================================================================
- * Copyright (C) 2018-2019 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.common.endpoints.event.comm.bus;
-
-import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertEquals;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_EP_CONN_TIMEOUT_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_EP_READ_TIMEOUT_MS_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ROUNDTRIP_TIMEOUT_MS_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_SESSION_STICKINESS_REQUIRED_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_SUB_CONTEXT_PATH_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_VERSION_SUFFIX;
-
-import java.util.Map;
-import org.onap.policy.common.endpoints.event.comm.Topic;
-import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
-import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
-
-/**
- * Base class for DmaapTopicXxxFactory tests.
- *
- * @param <T> type of topic managed by the factory
- */
-public abstract class DmaapTopicFactoryTestBase<T extends Topic> extends BusTopicFactoryTestBase<T> {
-
- public static final String MY_CONN_TIMEOUT = "200";
- public static final String MY_READ_TIMEOUT = "201";
- public static final String MY_ROUNDTRIP_TIMEOUT = "202";
- public static final String MY_STICKINESS = "true";
- public static final String MY_SUBCONTEXT = "my-subcontext";
- public static final String MY_DME_VERSION = "my-version";
-
- @Override
- public void testBuildProperties() {
-
- super.testBuildProperties();
-
- // check properties specific to DMaaP/DME2
- initFactory();
-
- assertEquals(1, buildTopics(makePropBuilder().makeTopic(MY_TOPIC).build()).size());
-
- BusTopicParams params = getLastParams();
- assertEquals(MY_ENV, params.getEnvironment());
- assertEquals(MY_LAT, params.getLatitude());
- assertEquals(MY_LONG, params.getLongitude());
- assertEquals(MY_PARTNER, params.getPartner());
-
- Map<String, String> add = params.getAdditionalProps();
- assertEquals(MY_CONN_TIMEOUT, add.get(PolicyEndPointProperties.DME2_EP_CONN_TIMEOUT_PROPERTY));
- assertEquals(MY_READ_TIMEOUT, add.get(PolicyEndPointProperties.DME2_READ_TIMEOUT_PROPERTY));
- assertEquals(MY_ROUNDTRIP_TIMEOUT, add.get(PolicyEndPointProperties.DME2_ROUNDTRIP_TIMEOUT_PROPERTY));
- assertEquals(MY_ROUTE, add.get(PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY));
- assertEquals(MY_STICKINESS, add.get(PolicyEndPointProperties.DME2_SESSION_STICKINESS_REQUIRED_PROPERTY));
- assertEquals(MY_SUBCONTEXT, add.get(PolicyEndPointProperties.DME2_SUBCONTEXT_PATH_PROPERTY));
- assertEquals(MY_DME_VERSION, add.get(PolicyEndPointProperties.DME2_VERSION_PROPERTY));
- }
-
- @Override
- public void testBuildProperties_Variations() {
- super.testBuildProperties_Variations();
-
- // check "additional" properties
- expectNullAddProp(PROPERTY_DMAAP_DME2_EP_CONN_TIMEOUT_SUFFIX,
- PolicyEndPointProperties.DME2_EP_CONN_TIMEOUT_PROPERTY);
-
- expectNullAddProp(PROPERTY_DMAAP_DME2_EP_READ_TIMEOUT_MS_SUFFIX,
- PolicyEndPointProperties.DME2_READ_TIMEOUT_PROPERTY);
-
- expectNullAddProp(PROPERTY_DMAAP_DME2_ROUNDTRIP_TIMEOUT_MS_SUFFIX,
- PolicyEndPointProperties.DME2_ROUNDTRIP_TIMEOUT_PROPERTY);
-
- expectNullAddProp(PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX, PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY);
-
- expectNullAddProp(PROPERTY_DMAAP_DME2_SESSION_STICKINESS_REQUIRED_SUFFIX,
- PolicyEndPointProperties.DME2_SESSION_STICKINESS_REQUIRED_PROPERTY);
-
- expectNullAddProp(PROPERTY_DMAAP_DME2_SUB_CONTEXT_PATH_SUFFIX,
- PolicyEndPointProperties.DME2_SUBCONTEXT_PATH_PROPERTY);
-
- expectNullAddProp(PROPERTY_DMAAP_DME2_VERSION_SUFFIX, PolicyEndPointProperties.DME2_VERSION_PROPERTY);
- }
-
- @Override
- public void testBuildListOfStringString() {
- super.testBuildListOfStringString();
-
- // check parameters that were used
- BusTopicParams params = getLastParams();
- assertEquals(false, params.isAllowSelfSignedCerts());
- }
-
- /**
- * Tests exception cases with get(topic). DMaaP topics are special in that they
- * throw IllegalArgumentException, even for an unknown topic name; all of the
- * other Topic Factory classes throw IllegalStateException, thus we override
- * the default test method.
- */
- @Override
- public void testGet_Ex() {
- // null topic
- assertThatIllegalArgumentException().as("null topic").isThrownBy(() -> getTopic(null));
-
- // empty topic
- assertThatIllegalArgumentException().as("empty topic").isThrownBy(() -> getTopic(""));
-
- // unknown topic
- initFactory();
- buildTopics(makePropBuilder().makeTopic(MY_TOPIC).build());
-
- assertThatIllegalStateException().as("unknown topic").isThrownBy(() -> getTopic(TOPIC2));
- }
-}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicPropertyBuilder.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicPropertyBuilder.java
deleted file mode 100644
index 2e9a6cd7..00000000
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicPropertyBuilder.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2018-2019 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.common.endpoints.event.comm.bus;
-
-import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_AFT_ENV;
-import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_API_KEY;
-import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_API_SECRET;
-import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_CONS_GROUP;
-import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_CONS_INST;
-import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_EFFECTIVE_TOPIC;
-import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_ENV;
-import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_FETCH_LIMIT;
-import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_FETCH_TIMEOUT;
-import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_LAT;
-import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_LONG;
-import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_PARTITION;
-import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_PARTNER;
-import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_ROUTE;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_AFT_ENVIRONMENT_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ENVIRONMENT_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_EP_CONN_TIMEOUT_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_EP_READ_TIMEOUT_MS_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_LATITUDE_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_LONGITUDE_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_PARTNER_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ROUNDTRIP_TIMEOUT_MS_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_SESSION_STICKINESS_REQUIRED_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_SUB_CONTEXT_PATH_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_VERSION_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_HTTP_HTTPS_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_AAF_MECHID_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_API_KEY_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_API_SECRET_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_CONSUMER_GROUP_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX;
-
-import java.util.Arrays;
-import lombok.Getter;
-import org.onap.policy.common.endpoints.parameters.TopicParameters;
-
-public class DmaapTopicPropertyBuilder extends TopicPropertyBuilder {
-
- public static final String SERVER = "my-server";
- public static final String TOPIC2 = "my-topic-2";
-
- public static final String MY_CONN_TIMEOUT = "200";
- public static final String MY_READ_TIMEOUT = "201";
- public static final String MY_ROUNDTRIP_TIMEOUT = "202";
- public static final String MY_STICKINESS = "true";
- public static final String MY_SUBCONTEXT = "my-subcontext";
- public static final String MY_DME_VERSION = "my-version";
- public static final String MY_AAF_MECHID = "my-aaf-mechid";
- public static final String MY_AAF_PASS = "my-aaf-passwd";
-
- @Getter
- private TopicParameters params = new TopicParameters();
-
- /**
- * Constructs the object.
- *
- * @param prefix the prefix for the properties to be built
- */
- public DmaapTopicPropertyBuilder(String prefix) {
- super(prefix);
- }
-
- /**
- * Adds a topic and configures it's properties with default values.
- *
- * @param topic the topic to be added
- * @return this builder
- */
- public DmaapTopicPropertyBuilder makeTopic(String topic) {
- addTopic(topic);
-
- setTopicProperty(PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX, MY_EFFECTIVE_TOPIC);
- setTopicProperty(PROPERTY_TOPIC_SOURCE_CONSUMER_GROUP_SUFFIX, MY_CONS_GROUP);
- setTopicProperty(PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX, MY_CONS_INST);
- setTopicProperty(PROPERTY_MANAGED_SUFFIX, "true");
- setTopicProperty(PROPERTY_HTTP_HTTPS_SUFFIX, "true");
- setTopicProperty(PROPERTY_TOPIC_AAF_MECHID_SUFFIX, MY_AAF_MECHID);
- setTopicProperty(PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX, MY_AAF_PASS);
- setTopicProperty(PROPERTY_DMAAP_DME2_AFT_ENVIRONMENT_SUFFIX, MY_AFT_ENV);
- setTopicProperty(PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX, "true");
- setTopicProperty(PROPERTY_TOPIC_API_KEY_SUFFIX, MY_API_KEY);
- setTopicProperty(PROPERTY_TOPIC_API_SECRET_SUFFIX, MY_API_SECRET);
- setTopicProperty(PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX, MY_FETCH_LIMIT);
- setTopicProperty(PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX, MY_FETCH_TIMEOUT);
- setTopicProperty(PROPERTY_DMAAP_DME2_EP_CONN_TIMEOUT_SUFFIX, MY_CONN_TIMEOUT);
- setTopicProperty(PROPERTY_DMAAP_DME2_ENVIRONMENT_SUFFIX, MY_ENV);
- setTopicProperty(PROPERTY_DMAAP_DME2_LATITUDE_SUFFIX, MY_LAT);
- setTopicProperty(PROPERTY_DMAAP_DME2_LONGITUDE_SUFFIX, MY_LONG);
- setTopicProperty(PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX, MY_PARTITION);
- setTopicProperty(PROPERTY_DMAAP_DME2_PARTNER_SUFFIX, MY_PARTNER);
- setTopicProperty(PROPERTY_DMAAP_DME2_EP_READ_TIMEOUT_MS_SUFFIX, MY_READ_TIMEOUT);
- setTopicProperty(PROPERTY_DMAAP_DME2_ROUNDTRIP_TIMEOUT_MS_SUFFIX, MY_ROUNDTRIP_TIMEOUT);
- setTopicProperty(PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX, MY_ROUTE);
- setTopicProperty(PROPERTY_TOPIC_SERVERS_SUFFIX, SERVER);
- setTopicProperty(PROPERTY_DMAAP_DME2_SESSION_STICKINESS_REQUIRED_SUFFIX, MY_STICKINESS);
- setTopicProperty(PROPERTY_DMAAP_DME2_SUB_CONTEXT_PATH_SUFFIX, MY_SUBCONTEXT);
- setTopicProperty(PROPERTY_DMAAP_DME2_VERSION_SUFFIX, MY_DME_VERSION);
-
- params.setTopicCommInfrastructure("dmaap");
- params.setTopic(topic);
- params.setEffectiveTopic(MY_EFFECTIVE_TOPIC);
- params.setConsumerGroup(MY_CONS_GROUP);
- params.setConsumerInstance(MY_CONS_INST);
- params.setManaged(true);
- params.setUseHttps(true);
- params.setUserName(MY_AAF_MECHID);
- params.setPassword(MY_AAF_PASS);
- params.setAftEnvironment(MY_AFT_ENV);
- params.setAllowSelfSignedCerts(true);
- params.setApiKey(MY_API_KEY);
- params.setApiSecret(MY_API_SECRET);
- params.setFetchLimit(MY_FETCH_LIMIT);
- params.setFetchTimeout(MY_FETCH_TIMEOUT);
- params.setEnvironment(MY_ENV);
- params.setLatitude(MY_LAT);
- params.setLongitude(MY_LONG);
- params.setPartitionId(MY_PARTITION);
- params.setPartner(MY_PARTNER);
- params.setServers(Arrays.asList(SERVER));
-
- return this;
- }
-}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactoryTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactoryTest.java
deleted file mode 100644
index 6c9dfcbd..00000000
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactoryTest.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * policy-endpoints
- * ================================================================================
- * Copyright (C) 2018-2019 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.common.endpoints.event.comm.bus;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_SINK_TOPICS;
-
-import java.util.Deque;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
-
-public class DmaapTopicSinkFactoryTest extends DmaapTopicFactoryTestBase<DmaapTopicSink> {
-
- private SinkFactory factory;
-
- /**
- * Creates the object to be tested.
- */
- @Before
- @Override
- public void setUp() {
- super.setUp();
-
- factory = new SinkFactory();
- }
-
- @After
- public void tearDown() {
- factory.destroy();
- }
-
- @Test
- @Override
- public void testBuildBusTopicParams() {
- super.testBuildBusTopicParams();
- super.testBuildBusTopicParams_Ex();
- }
-
- @Test
- @Override
- public void testBuildListOfStringString() {
- super.testBuildListOfStringString();
- }
-
- @Test
- @Override
- public void testBuildProperties() {
- super.testBuildProperties();
- super.testBuildProperties_Variations();
- super.testBuildProperties_Multiple();
-
- // check sink-specific parameters that were used
- BusTopicParams params = factory.params.getFirst();
- assertEquals(MY_PARTITION, params.getPartitionId());
- }
-
- @Test
- @Override
- public void testDestroyString_testGet_testInventory() {
- super.testDestroyString_testGet_testInventory();
- super.testDestroyString_Ex();
- }
-
- @Test
- @Override
- public void testDestroy() {
- super.testDestroy();
- }
-
- @Test
- public void testGet() {
- super.testGet_Ex();
- }
-
- @Test
- public void testToString() {
- assertTrue(factory.toString().startsWith("IndexedDmaapTopicSinkFactory ["));
- }
-
- @Override
- protected void initFactory() {
- if (factory != null) {
- factory.destroy();
- }
-
- factory = new SinkFactory();
- }
-
- @Override
- protected List<DmaapTopicSink> buildTopics(Properties properties) {
- return factory.build(properties);
- }
-
- @Override
- protected DmaapTopicSink buildTopic(BusTopicParams params) {
- return factory.build(params);
- }
-
- @Override
- protected DmaapTopicSink buildTopic(List<String> servers, String topic) {
- return factory.build(servers, topic);
- }
-
- @Override
- protected void destroyFactory() {
- factory.destroy();
- }
-
- @Override
- protected void destroyTopic(String topic) {
- factory.destroy(topic);
- }
-
- @Override
- protected List<DmaapTopicSink> getInventory() {
- return factory.inventory();
- }
-
- @Override
- protected DmaapTopicSink getTopic(String topic) {
- return factory.get(topic);
- }
-
- @Override
- protected BusTopicParams getLastParams() {
- return factory.params.getLast();
- }
-
- @Override
- protected TopicPropertyBuilder makePropBuilder() {
- return new DmaapTopicPropertyBuilder(PROPERTY_DMAAP_SINK_TOPICS);
- }
-
- /**
- * Factory that records the parameters of all of the sinks it creates.
- */
- private static class SinkFactory extends IndexedDmaapTopicSinkFactory {
- private Deque<BusTopicParams> params = new LinkedList<>();
-
- @Override
- protected DmaapTopicSink makeSink(BusTopicParams busTopicParams) {
- params.add(busTopicParams);
- return super.makeSink(busTopicParams);
- }
- }
-}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkTest.java
deleted file mode 100644
index 9136108a..00000000
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine - Common Modules
- * ================================================================================
- * Copyright (C) 2018-2019 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.common.endpoints.event.comm.bus;
-
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Test;
-
-public class DmaapTopicSinkTest {
-
- @Test
- public void test() {
- assertNotNull(DmaapTopicFactories.getSinkFactory());
- }
-
-}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactoryTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactoryTest.java
deleted file mode 100644
index b4c2f758..00000000
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactoryTest.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine - Common Modules
- * ================================================================================
- * Copyright (C) 2018-2019 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.common.endpoints.event.comm.bus;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX;
-
-import java.util.Deque;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
-import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
-
-public class DmaapTopicSourceFactoryTest extends DmaapTopicFactoryTestBase<DmaapTopicSource> {
-
- private SourceFactory factory;
-
- /**
- * Creates the object to be tested.
- */
- @Before
- @Override
- public void setUp() {
- super.setUp();
-
- factory = new SourceFactory();
- }
-
- @After
- public void tearDown() {
- factory.destroy();
- }
-
- @Test
- @Override
- public void testBuildBusTopicParams() {
- super.testBuildBusTopicParams();
- super.testBuildBusTopicParams_Ex();
- }
-
- @Test
- @Override
- public void testBuildProperties() {
- super.testBuildProperties();
-
- // check source-specific parameters that were used
- BusTopicParams params = factory.params.getFirst();
- assertEquals(MY_CONS_GROUP, params.getConsumerGroup());
- assertEquals(MY_CONS_INST, params.getConsumerInstance());
- assertEquals(MY_FETCH_LIMIT, params.getFetchLimit());
- assertEquals(MY_FETCH_TIMEOUT, params.getFetchTimeout());
-
- super.testBuildProperties_Variations();
- super.testBuildProperties_Multiple();
-
- // check default values for source-specific parameters
- checkDefault(PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX,
- params2 -> params2.getFetchLimit() == PolicyEndPointProperties.DEFAULT_LIMIT_FETCH,
- null, "", "invalid-limit-number");
-
- checkDefault(PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX,
- params2 -> params2.getFetchTimeout() == PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH,
- null, "", "invalid-timeout-number");
- }
-
- @Test
- public void testBuildListOfStringStringStringString() {
- DmaapTopicSource source1 = factory.build(servers, MY_TOPIC, MY_API_KEY, MY_API_SECRET);
- assertNotNull(source1);
-
- // check source-specific parameters that were used
- BusTopicParams params = factory.params.getFirst();
- assertEquals(MY_API_KEY, params.getApiKey());
- assertEquals(MY_API_SECRET, params.getApiSecret());
- assertEquals(PolicyEndPointProperties.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
- assertEquals(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
- }
-
- @Test
- @Override
- public void testBuildListOfStringString() {
- super.testBuildListOfStringString();
-
- // check source-specific parameters that were used
- BusTopicParams params = factory.params.getFirst();
- assertEquals(null, params.getApiKey());
- assertEquals(null, params.getApiSecret());
- assertEquals(PolicyEndPointProperties.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
- assertEquals(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
- }
-
- @Test
- @Override
- public void testDestroyString_testGet_testInventory() {
- super.testDestroyString_testGet_testInventory();
- super.testDestroyString_Ex();
- }
-
- @Test
- @Override
- public void testDestroy() {
- super.testDestroy();
- }
-
- @Test
- public void testGet() {
- super.testGet_Ex();
- }
-
- @Test
- public void testToString() {
- assertTrue(factory.toString().startsWith("IndexedDmaapTopicSourceFactory ["));
- }
-
- @Override
- protected void initFactory() {
- if (factory != null) {
- factory.destroy();
- }
-
- factory = new SourceFactory();
- }
-
- @Override
- protected List<DmaapTopicSource> buildTopics(Properties properties) {
- return factory.build(properties);
- }
-
- @Override
- protected DmaapTopicSource buildTopic(BusTopicParams params) {
- return factory.build(params);
- }
-
- @Override
- protected DmaapTopicSource buildTopic(List<String> servers, String topic) {
- return factory.build(servers, topic);
- }
-
- @Override
- protected void destroyFactory() {
- factory.destroy();
- }
-
- @Override
- protected void destroyTopic(String topic) {
- factory.destroy(topic);
- }
-
- @Override
- protected List<DmaapTopicSource> getInventory() {
- return factory.inventory();
- }
-
- @Override
- protected DmaapTopicSource getTopic(String topic) {
- return factory.get(topic);
- }
-
- @Override
- protected BusTopicParams getLastParams() {
- return factory.params.getLast();
- }
-
- @Override
- protected TopicPropertyBuilder makePropBuilder() {
- return new DmaapTopicPropertyBuilder(PROPERTY_DMAAP_SOURCE_TOPICS);
- }
-
- /**
- * Factory that records the parameters of all of the sources it creates.
- */
- private static class SourceFactory extends IndexedDmaapTopicSourceFactory {
- private Deque<BusTopicParams> params = new LinkedList<>();
-
- @Override
- protected DmaapTopicSource makeSource(BusTopicParams busTopicParams) {
- params.add(busTopicParams);
- return super.makeSource(busTopicParams);
- }
- }
-}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceTest.java
deleted file mode 100644
index 1735e2ee..00000000
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine - Common Modules
- * ================================================================================
- * Copyright (C) 2018-2019 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.common.endpoints.event.comm.bus;
-
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Test;
-
-public class DmaapTopicSourceTest {
-
- @Test
- public void test() {
- assertNotNull(DmaapTopicFactories.getSourceFactory());
- }
-
-}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicPropertyBuilder.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicPropertyBuilder.java
index cb5507e5..42ea6eba 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicPropertyBuilder.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicPropertyBuilder.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018-2019 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.
@@ -30,11 +31,8 @@ import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_F
import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_FETCH_TIMEOUT;
import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_PARTITION;
import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_DMAAP_DME2_AFT_ENVIRONMENT_SUFFIX;
import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_HTTP_HTTPS_SUFFIX;
import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_AAF_MECHID_SUFFIX;
-import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX;
import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_API_KEY_SUFFIX;
import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_API_SECRET_SUFFIX;
import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX;
@@ -45,20 +43,17 @@ import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperti
import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX;
import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX;
-import java.util.Arrays;
+import java.util.List;
import lombok.Getter;
import org.onap.policy.common.endpoints.parameters.TopicParameters;
+@Getter
public class UebTopicPropertyBuilder extends TopicPropertyBuilder {
public static final String SERVER = "my-server";
public static final String TOPIC2 = "my-topic-2";
- public static final String MY_AAF_MECHID = "my-aaf-mechid";
- public static final String MY_AAF_PASS = "my-aaf-passwd";
-
- @Getter
- private TopicParameters params = new TopicParameters();
+ private final TopicParameters params = new TopicParameters();
/**
* Constructs the object.
@@ -70,7 +65,7 @@ public class UebTopicPropertyBuilder extends TopicPropertyBuilder {
}
/**
- * Adds a topic and configures it's properties with default values.
+ * Adds a topic and configures its properties with default values.
*
* @param topic the topic to be added
* @return this builder
@@ -83,9 +78,6 @@ public class UebTopicPropertyBuilder extends TopicPropertyBuilder {
setTopicProperty(PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX, MY_CONS_INST);
setTopicProperty(PROPERTY_MANAGED_SUFFIX, "true");
setTopicProperty(PROPERTY_HTTP_HTTPS_SUFFIX, "true");
- setTopicProperty(PROPERTY_TOPIC_AAF_MECHID_SUFFIX, MY_AAF_MECHID);
- setTopicProperty(PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX, MY_AAF_PASS);
- setTopicProperty(PROPERTY_DMAAP_DME2_AFT_ENVIRONMENT_SUFFIX, MY_AFT_ENV);
setTopicProperty(PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX, "true");
setTopicProperty(PROPERTY_TOPIC_API_KEY_SUFFIX, MY_API_KEY);
setTopicProperty(PROPERTY_TOPIC_API_SECRET_SUFFIX, MY_API_SECRET);
@@ -101,8 +93,6 @@ public class UebTopicPropertyBuilder extends TopicPropertyBuilder {
params.setConsumerInstance(MY_CONS_INST);
params.setManaged(true);
params.setUseHttps(true);
- params.setUserName(MY_AAF_MECHID);
- params.setPassword(MY_AAF_PASS);
params.setAftEnvironment(MY_AFT_ENV);
params.setAllowSelfSignedCerts(true);
params.setApiKey(MY_API_KEY);
@@ -110,7 +100,7 @@ public class UebTopicPropertyBuilder extends TopicPropertyBuilder {
params.setFetchLimit(MY_FETCH_LIMIT);
params.setFetchTimeout(MY_FETCH_TIMEOUT);
params.setPartitionId(MY_PARTITION);
- params.setServers(Arrays.asList(SERVER));
+ params.setServers(List.of(SERVER));
return this;
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java
index a95e773d..70fa83c6 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java
@@ -24,7 +24,6 @@ package org.onap.policy.common.endpoints.event.comm.bus.internal;
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.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.fail;
@@ -54,13 +53,8 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.onap.dmaap.mr.client.impl.MRConsumerImpl;
-import org.onap.dmaap.mr.client.response.MRConsumerResponse;
import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusConsumer.CambriaConsumerWrapper;
-import org.onap.policy.common.endpoints.event.comm.bus.internal.BusConsumer.DmaapAafConsumerWrapper;
-import org.onap.policy.common.endpoints.event.comm.bus.internal.BusConsumer.DmaapConsumerWrapper;
-import org.onap.policy.common.endpoints.event.comm.bus.internal.BusConsumer.DmaapDmeConsumerWrapper;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusConsumer.FetchingBusConsumer;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusConsumer.KafkaConsumerWrapper;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
@@ -200,124 +194,6 @@ public class BusConsumerTest extends TopicTestBase {
}
@Test
- public void testDmaapConsumerWrapper() {
- // verify that different wrappers can be built
- assertThatCode(() -> new DmaapAafConsumerWrapper(makeBuilder().build())).doesNotThrowAnyException();
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDmaapConsumerWrapper_InvalidTopic() throws Exception {
- new DmaapAafConsumerWrapper(makeBuilder().topic(null).build());
- }
-
- @Test
- public void testDmaapConsumerWrapperFetch() throws Exception {
- DmaapAafConsumerWrapper dmaap = new DmaapAafConsumerWrapper(makeBuilder().build());
- MRConsumerImpl cons = mock(MRConsumerImpl.class);
-
- dmaap.fetchTimeout = 5;
- dmaap.consumer = cons;
-
- // null return
- when(cons.fetchWithReturnConsumerResponse()).thenReturn(null);
- assertFalse(dmaap.fetch().iterator().hasNext());
-
- // with messages, 200
- List<String> lst = Arrays.asList(MY_MESSAGE, MY_MESSAGE2);
- MRConsumerResponse resp = new MRConsumerResponse();
- resp.setResponseCode("200");
- resp.setActualMessages(lst);
- when(cons.fetchWithReturnConsumerResponse()).thenReturn(resp);
-
- assertEquals(lst, IteratorUtils.toList(dmaap.fetch().iterator()));
-
- // null messages
- resp.setActualMessages(null);
- when(cons.fetchWithReturnConsumerResponse()).thenReturn(resp);
-
- assertFalse(dmaap.fetch().iterator().hasNext());
-
- // with messages, NOT 200
- resp.setResponseCode("400");
- resp.setActualMessages(lst);
- when(cons.fetchWithReturnConsumerResponse()).thenReturn(resp);
-
- assertEquals(lst, IteratorUtils.toList(dmaap.fetch().iterator()));
- }
-
- @Test
- public void testDmaapConsumerWrapperClose() {
- assertThatCode(() -> new DmaapAafConsumerWrapper(makeBuilder().build()).close()).doesNotThrowAnyException();
- }
-
- @Test
- public void testDmaapConsumerWrapperToString() throws Exception {
- assertNotNull(new DmaapConsumerWrapper(makeBuilder().build()) {}.toString());
- }
-
- @Test
- public void testDmaapAafConsumerWrapper() throws Exception {
- // verify that different wrappers can be built
- new DmaapAafConsumerWrapper(makeBuilder().useHttps(true).build());
- assertThatCode(() -> new DmaapAafConsumerWrapper(makeBuilder().useHttps(false).build()))
- .doesNotThrowAnyException();
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDmaapAafConsumerWrapper_InvalidServers() throws Exception {
- /*
- * Unfortunately, the MR code intercepts this and throws an exception before the
- * wrapper gets a chance to check it, thus this test does not improve the coverage
- * for the constructor.
- */
- new DmaapAafConsumerWrapper(makeBuilder().servers(Collections.emptyList()).build());
- }
-
- @Test
- public void testDmaapAafConsumerWrapperToString() throws Exception {
- assertNotNull(new DmaapAafConsumerWrapper(makeBuilder().build()).toString());
- }
-
- @Test
- public void testDmaapDmeConsumerWrapper() throws Exception {
- // verify that different wrappers can be built
- new DmaapDmeConsumerWrapper(makeBuilder().build());
- new DmaapDmeConsumerWrapper(makeBuilder().useHttps(true).build());
- new DmaapDmeConsumerWrapper(makeBuilder().useHttps(false).build());
- new DmaapDmeConsumerWrapper(makeBuilder().additionalProps(null).build());
-
- addProps.put(ROUTE_PROP, MY_ROUTE);
- new DmaapDmeConsumerWrapper(makeBuilder().build());
- assertThatCode(() -> new DmaapDmeConsumerWrapper(makeBuilder().partner(null).build()))
- .doesNotThrowAnyException();
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDmaapDmeConsumerWrapper_InvalidEnvironment() throws Exception {
- new DmaapDmeConsumerWrapper(makeBuilder().environment(null).build());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDmaapDmeConsumerWrapper_InvalidAft() throws Exception {
- new DmaapDmeConsumerWrapper(makeBuilder().aftEnvironment(null).build());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDmaapDmeConsumerWrapper_InvalidLat() throws Exception {
- new DmaapDmeConsumerWrapper(makeBuilder().latitude(null).build());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDmaapDmeConsumerWrapper_InvalidLong() throws Exception {
- new DmaapDmeConsumerWrapper(makeBuilder().longitude(null).build());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDmaapDmeConsumerWrapper_InvalidPartner() throws Exception {
- new DmaapDmeConsumerWrapper(makeBuilder().partner(null).build());
- }
-
- @Test
public void testKafkaConsumerWrapper() {
// verify that different wrappers can be built
assertThatCode(() -> new KafkaConsumerWrapper(makeKafkaBuilder().build())).doesNotThrowAnyException();
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisherTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisherTest.java
index 513673bd..66029b61 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisherTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisherTest.java
@@ -3,6 +3,7 @@
* policy-endpoints
* ================================================================================
* Copyright (C) 2018-2020 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.
@@ -23,8 +24,6 @@ package org.onap.policy.common.endpoints.event.comm.bus.internal;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
@@ -33,18 +32,11 @@ import static org.mockito.Mockito.when;
import com.att.nsa.cambria.client.CambriaBatchingPublisher;
import java.io.IOException;
-import java.util.Collections;
-import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
-import org.onap.dmaap.mr.client.impl.MRSimplerBatchPublisher;
-import org.onap.dmaap.mr.client.response.MRPublisherResponse;
-import org.onap.dmaap.mr.test.clients.ProtocolTypeConstants;
import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusPublisher.CambriaPublisherWrapper;
-import org.onap.policy.common.endpoints.event.comm.bus.internal.BusPublisher.DmaapAafPublisherWrapper;
-import org.onap.policy.common.endpoints.event.comm.bus.internal.BusPublisher.DmaapDmePublisherWrapper;
-import org.onap.policy.common.endpoints.event.comm.bus.internal.BusPublisher.DmaapPublisherWrapper;
+
public class BusPublisherTest extends TopicTestBase {
@@ -105,117 +97,4 @@ public class BusPublisherTest extends TopicTestBase {
doThrow(new RuntimeException(EXPECTED)).when(pub).close();
cambria.close();
}
-
- @Test
- public void testDmaapPublisherWrapper() {
- // verify with different constructor arguments
- new DmaapAafPublisherWrapper(servers, MY_TOPIC, MY_USERNAME, MY_PASS, true);
- new DmaapAafPublisherWrapper(servers, MY_TOPIC, MY_USERNAME, MY_PASS, false);
- assertThatCode(() -> new DmaapPublisherWrapper(ProtocolTypeConstants.DME2, servers, MY_TOPIC, MY_USERNAME,
- MY_PASS, true) {}).doesNotThrowAnyException();
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDmaapPublisherWrapper_InvalidTopic() {
- new DmaapPublisherWrapper(ProtocolTypeConstants.DME2, servers, "", MY_USERNAME, MY_PASS, true) {};
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDmaapPublisherWrapper_Aaf_NullServers() {
- new DmaapAafPublisherWrapper(null, MY_TOPIC, MY_USERNAME, MY_PASS, true);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDmaapPublisherWrapper_Aaf_NoServers() {
- new DmaapAafPublisherWrapper(Collections.emptyList(), MY_TOPIC, MY_USERNAME, MY_PASS, true);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDmaapPublisherWrapper_InvalidProtocol() {
- new DmaapPublisherWrapper(ProtocolTypeConstants.HTTPNOAUTH, servers, MY_TOPIC, MY_USERNAME, MY_PASS, true) {};
- }
-
- @Test
- public void testDmaapPublisherWrapperClose() throws Exception {
- MRSimplerBatchPublisher pub = mock(MRSimplerBatchPublisher.class);
- DmaapPublisherWrapper dmaap = new DmaapAafPublisherWrapper(servers, MY_TOPIC, MY_USERNAME, MY_PASS, true);
- dmaap.publisher = pub;
-
- dmaap.close();
- verify(pub).close(anyLong(), any(TimeUnit.class));
-
- // close, but with exception from publisher
- doThrow(new IOException(EXPECTED)).when(pub).close(anyLong(), any(TimeUnit.class));
- dmaap.close();
- }
-
- @Test
- public void testDmaapPublisherWrapperSend() {
- MRSimplerBatchPublisher pub = mock(MRSimplerBatchPublisher.class);
- DmaapPublisherWrapper dmaap = new DmaapAafPublisherWrapper(servers, MY_TOPIC, MY_USERNAME, MY_PASS, true);
- dmaap.publisher = pub;
-
- // null response
- assertTrue(dmaap.send(MY_PARTITION, MY_MESSAGE));
- verify(pub).setPubResponse(any(MRPublisherResponse.class));
- verify(pub).send(MY_PARTITION, MY_MESSAGE);
-
- // with response
- pub = mock(MRSimplerBatchPublisher.class);
- dmaap.publisher = pub;
-
- MRPublisherResponse resp = new MRPublisherResponse();
- when(pub.sendBatchWithResponse()).thenReturn(resp);
- assertTrue(dmaap.send(MY_PARTITION, MY_MESSAGE));
- verify(pub).setPubResponse(any(MRPublisherResponse.class));
- verify(pub).send(MY_PARTITION, MY_MESSAGE);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDmaapPublisherWrapperSend_NullMessage() {
- MRSimplerBatchPublisher pub = mock(MRSimplerBatchPublisher.class);
- DmaapPublisherWrapper dmaap = new DmaapAafPublisherWrapper(servers, MY_TOPIC, MY_USERNAME, MY_PASS, true);
- dmaap.publisher = pub;
-
- dmaap.send(MY_PARTITION, null);
- }
-
- @Test
- public void testDmaapDmePublisherWrapper() {
- // verify with different parameters
- new DmaapDmePublisherWrapper(makeBuilder().build());
- new DmaapDmePublisherWrapper(makeBuilder().additionalProps(null).build());
-
- addProps.put(ROUTE_PROP, MY_ROUTE);
- new DmaapDmePublisherWrapper(makeBuilder().build());
- new DmaapDmePublisherWrapper(makeBuilder().partner(null).build());
-
- addProps.put("null-value", null);
- assertThatCode(() -> new DmaapDmePublisherWrapper(makeBuilder().build())).doesNotThrowAnyException();
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDmaapDmePublisherWrapper_InvalidEnv() {
- new DmaapDmePublisherWrapper(makeBuilder().environment(null).build());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDmaapDmePublisherWrapper_InvalidAft() {
- new DmaapDmePublisherWrapper(makeBuilder().aftEnvironment(null).build());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDmaapDmePublisherWrapper_InvalidLat() {
- new DmaapDmePublisherWrapper(makeBuilder().latitude(null).build());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDmaapDmePublisherWrapper_InvalidLong() {
- new DmaapDmePublisherWrapper(makeBuilder().longitude(null).build());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testDmaapDmePublisherWrapper_InvalidPartner() {
- new DmaapDmePublisherWrapper(makeBuilder().partner(null).build());
- }
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.java
deleted file mode 100644
index 239bf33a..00000000
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * policy-endpoints
- * ================================================================================
- * Copyright (C) 2018-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.common.endpoints.event.comm.bus.internal;
-
-import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase;
-import org.onap.policy.common.utils.gson.GsonTestUtils;
-
-public class InlineDmaapTopicSinkTest extends TopicTestBase {
- private InlineDmaapTopicSink sink;
-
- /**
- * Creates the object to be tested.
- */
- @Before
- @Override
- public void setUp() {
- super.setUp();
-
- sink = new InlineDmaapTopicSink(makeBuilder().build());
- }
-
- @After
- public void tearDown() {
- sink.shutdown();
- }
-
- @Test
- public void testSerialize() {
- assertThatCode(() -> new GsonTestUtils().compareGson(sink, InlineDmaapTopicSinkTest.class))
- .doesNotThrowAnyException();
- }
-
- @Test
- public void testToString() {
- assertTrue(sink.toString().startsWith("InlineDmaapTopicSink ["));
- }
-
- @Test
- public void testInit() {
- // nothing null
- sink = new InlineDmaapTopicSink(makeBuilder().build());
- sink.init();
- sink.shutdown();
-
- // no DME2 info
- sink = new InlineDmaapTopicSink(makeBuilder().environment(null).aftEnvironment(null).latitude(null)
- .longitude(null).partner(null).build());
- sink.init();
- assertThatCode(() -> sink.shutdown()).doesNotThrowAnyException();
- }
-
- @Test
- public void testGetTopicCommInfrastructure() {
- assertEquals(CommInfrastructure.DMAAP, sink.getTopicCommInfrastructure());
- }
-
-}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.java
deleted file mode 100644
index c7d30025..00000000
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * policy-endpoints
- * ================================================================================
- * Copyright (C) 2018-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.common.endpoints.event.comm.bus.internal;
-
-import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.net.MalformedURLException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase;
-import org.onap.policy.common.utils.gson.GsonTestUtils;
-
-public class SingleThreadedDmaapTopicSourceTest extends TopicTestBase {
- private static final String SOURCE_NAME = "SingleThreadedDmaapTopicSource [";
- private SingleThreadedDmaapTopicSource source;
-
- /**
- * Creates the object to be tested.
- */
- @Before
- @Override
- public void setUp() {
- super.setUp();
-
- source = new SingleThreadedDmaapTopicSource(makeBuilder().build());
- }
-
- @After
- public void tearDown() {
- source.shutdown();
- }
-
- @Test
- public void testSerialize() {
- assertThatCode(() -> new GsonTestUtils().compareGson(source, SingleThreadedDmaapTopicSourceTest.class))
- .doesNotThrowAnyException();
- }
-
- @Test
- public void testToString() {
- assertTrue(source.toString().startsWith(SOURCE_NAME));
- source.shutdown();
-
- // try with null password
- source = new SingleThreadedDmaapTopicSource(makeBuilder().password(null).build());
- assertTrue(source.toString().startsWith(SOURCE_NAME));
- source.shutdown();
-
- // try with empty password
- source = new SingleThreadedDmaapTopicSource(makeBuilder().password("").build());
- assertTrue(source.toString().startsWith(SOURCE_NAME));
- source.shutdown();
- }
-
- @Test
- public void testInit() {
- // verify with different parameters
- new SingleThreadedDmaapTopicSource(makeBuilder().environment(null).aftEnvironment(null).latitude(null)
- .longitude(null).partner(null).build()).shutdown();
- assertThatCode(() -> new SingleThreadedDmaapTopicSource(makeBuilder().userName(null).build()).shutdown())
- .doesNotThrowAnyException();
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testSingleThreadedDmaapTopicSource_Ex() {
- new SingleThreadedDmaapTopicSource(makeBuilder().build()) {
- @Override
- public void init() throws MalformedURLException {
- throw new MalformedURLException(EXPECTED);
- }
- }.shutdown();
- }
-
- @Test
- public void testGetTopicCommInfrastructure() {
- assertEquals(CommInfrastructure.DMAAP, source.getTopicCommInfrastructure());
- }
-
-}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java
index 27e7dc5f..11067974 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd.
- * Modifications Copyright 2023 Nordix Foundation.
+ * Modifications Copyright 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.
@@ -126,8 +126,6 @@ public class HttpClientTest {
echoServerAuth.addServletPackage("/*", HttpClientTest.class.getPackage().getName());
echoServerAuth.addFilterClass("/*", TestFilter.class.getName());
echoServerAuth.addFilterClass("/*", TestAuthorizationFilter.class.getName());
- echoServerAuth.addFilterClass("/*", TestAafAuthFilter.class.getName());
- echoServerAuth.addFilterClass("/*", TestAafGranularAuthFilter.class.getName());
echoServerAuth.waitedStart(5000);
if (!NetworkUtil.isTcpPortOpen(LOCALHOST, echoServerAuth.getPort(), 5, 10000L)) {
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
index 48cacaf9..8a2574e1 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020,2023 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023-2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -40,6 +40,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
+import java.util.Objects;
import java.util.UUID;
import org.apache.commons.io.IOUtils;
import org.junit.AfterClass;
@@ -397,7 +398,6 @@ public class HttpServerTest {
server.waitedStart(5000);
assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
- assertFalse(HttpServletServerFactoryInstance.getServerFactory().get(port).isAaf());
String response = http(portUrl + JUNIT_ECHO_HELLO);
assertEquals(HELLO, response);
@@ -525,7 +525,8 @@ public class HttpServerTest {
.hasMessageContaining("No resourceBase provided");
staticServer.addServletResource(null,
- HttpServerTest.class.getClassLoader().getResource("webapps/root").toExternalForm());
+ Objects.requireNonNull(HttpServerTest.class.getClassLoader().getResource("webapps/root"))
+ .toExternalForm());
thrown = catchThrowable(() -> staticServer.addServletClass("/*", RestEchoService.class.getName()));
assertThat(thrown).isInstanceOf(UnsupportedOperationException.class)
@@ -558,9 +559,11 @@ public class HttpServerTest {
HttpServletServer staticResourceServer = HttpServletServerFactoryInstance.getServerFactory()
.buildStaticResourceServer("Static Resources Server", false, LOCALHOST, port, false, "/", true);
staticResourceServer.addServletResource("/root/*",
- HttpServerTest.class.getClassLoader().getResource("webapps/root").toExternalForm());
+ Objects.requireNonNull(HttpServerTest.class.getClassLoader().getResource("webapps/root"))
+ .toExternalForm());
staticResourceServer.addServletResource("/alt-root/*",
- HttpServerTest.class.getClassLoader().getResource("webapps/alt-root").toExternalForm());
+ Objects.requireNonNull(HttpServerTest.class.getClassLoader().getResource("webapps/alt-root"))
+ .toExternalForm());
staticResourceServer.waitedStart(5000);
assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
@@ -583,7 +586,8 @@ public class HttpServerTest {
HttpServletServer staticResourceServer = HttpServletServerFactoryInstance.getServerFactory()
.buildStaticResourceServer("Static Resources Server", false, LOCALHOST, port, false, "/", true);
staticResourceServer.addServletResource("/root/*",
- HttpServerTest.class.getClassLoader().getResource("webapps/root").toExternalForm());
+ Objects.requireNonNull(HttpServerTest.class.getClassLoader().getResource("webapps/root"))
+ .toExternalForm());
staticResourceServer.waitedStart(5000);
int port2 = port + 1;
@@ -592,7 +596,8 @@ public class HttpServerTest {
jerseyServer.addServletPackage("/api/*", this.getClass().getPackage().getName());
Throwable thrown = catchThrowable(() -> jerseyServer.addServletResource("/root/*",
- HttpServerTest.class.getClassLoader().getResource("webapps/root").toExternalForm()));
+ Objects.requireNonNull(HttpServerTest.class.getClassLoader().getResource("webapps/root"))
+ .toExternalForm()));
assertThat(thrown).isInstanceOf(UnsupportedOperationException.class)
.hasMessageContaining("is not supported on this type of jetty server");
@@ -628,7 +633,7 @@ public class HttpServerTest {
}
/**
- * Performs an http request.
+ * Performs a http request.
*
* @throws MalformedURLException make sure URL is good
* @throws IOException thrown is IO exception occurs
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java
index 216c4fd9..a789a66f 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * 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.
@@ -35,10 +35,8 @@ import static org.mockito.Mockito.when;
import io.prometheus.client.servlet.jakarta.exporter.MetricsServlet;
import jakarta.servlet.FilterChain;
-import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
-import jakarta.servlet.http.HttpServletRequest;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
@@ -68,7 +66,6 @@ import org.onap.policy.common.endpoints.http.server.RestServer;
import org.onap.policy.common.endpoints.http.server.RestServer.Factory;
import org.onap.policy.common.endpoints.http.server.YamlExceptionMapper;
import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler;
-import org.onap.policy.common.endpoints.http.server.aaf.AafAuthFilter;
import org.onap.policy.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.common.gson.GsonMessageBodyHandler;
@@ -111,7 +108,7 @@ public class RestServerTest {
initRealParams();
- realRest = new RestServer(params, (Class<AafAuthFilter>) null, RealProvider.class) {
+ realRest = new RestServer(params, RealProvider.class) {
@Override
protected Properties getServerProperties(RestServerParameters restServerParameters, String names) {
Properties props = super.getServerProperties(restServerParameters, names);
@@ -161,7 +158,7 @@ public class RestServerTest {
@Test
public void testRestServer() {
- rest = new RestServer(params, Filter.class, Provider1.class, Provider2.class);
+ rest = new RestServer(params, Filter2.class, Provider1.class, Provider2.class);
rest.start();
verify(server1).start();
@@ -174,7 +171,7 @@ public class RestServerTest {
@Test
public void testRestServerListList() {
- rest = new RestServer(params, List.of(Filter.class, Filter2.class), List.of(Provider1.class, Provider2.class));
+ rest = new RestServer(params, List.of(Filter2.class), List.of(Provider1.class, Provider2.class));
rest.start();
verify(server1).start();
@@ -186,52 +183,13 @@ public class RestServerTest {
}
@Test
- public void testRestServer_NoAaf() {
- rest = new RestServer(params, Filter.class, Provider1.class, Provider2.class);
- verify(server1, never()).addFilterClass(any(), any());
- verify(server2, never()).addFilterClass(any(), any());
- }
-
- @Test
- public void testRestServer_OnlyOneAaf() {
- when(server2.isAaf()).thenReturn(true);
-
- rest = new RestServer(params, Filter.class, Provider1.class, Provider2.class);
-
- verify(server1, never()).addFilterClass(any(), any());
- verify(server2).addFilterClass(null, Filter.class.getName());
- }
-
- @Test
- public void testRestServer_BothAaf() {
- when(server1.isAaf()).thenReturn(true);
- when(server2.isAaf()).thenReturn(true);
-
- rest = new RestServer(params, Filter.class, Provider1.class, Provider2.class);
-
- verify(server1).addFilterClass(null, Filter.class.getName());
- verify(server2).addFilterClass(null, Filter.class.getName());
- }
-
- @Test
- public void testRestServer_BothAaf_NoFilter() {
- when(server1.isAaf()).thenReturn(true);
- when(server2.isAaf()).thenReturn(true);
-
- rest = new RestServer(params, (Class<AafAuthFilter>) null, Provider1.class, Provider2.class);
-
- verify(server1, never()).addFilterClass(any(), any());
- verify(server2, never()).addFilterClass(any(), any());
- }
-
- @Test
public void testRestServer_MissingProviders() {
- assertThatIllegalArgumentException().isThrownBy(() -> new RestServer(params, Filter.class));
+ assertThatIllegalArgumentException().isThrownBy(() -> new RestServer(params, List.of(Filter2.class), null));
}
@Test
public void testGetServerProperties_testGetProviderNames() {
- rest = new RestServer(params, Filter.class, Provider1.class, Provider2.class);
+ rest = new RestServer(params, Provider1.class, Provider2.class);
ArgumentCaptor<Properties> cap = ArgumentCaptor.forClass(Properties.class);
verify(serverFactory).build(cap.capture());
@@ -249,7 +207,6 @@ public class RestServerTest {
assertEquals(USER, props.getProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_AUTH_USERNAME_SUFFIX));
assertEquals(PASS, props.getProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX));
assertEquals("true", props.getProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_HTTPS_SUFFIX));
- assertEquals("true", props.getProperty(svcpfx + PolicyEndPointProperties.PROPERTY_AAF_SUFFIX));
assertEquals(String.join(",", GsonMessageBodyHandler.class.getName(), YamlMessageBodyHandler.class.getName(),
JsonExceptionMapper.class.getName(), YamlExceptionMapper.class.getName()),
props.getProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_SERIALIZATION_PROVIDER));
@@ -259,7 +216,7 @@ public class RestServerTest {
@Test
public void testExplicitPrometheusAddedToProperty() {
when(params.isPrometheus()).thenReturn(true);
- rest = new RestServer(params, Filter.class, Provider1.class, Provider2.class);
+ rest = new RestServer(params, Filter2.class, Provider1.class, Provider2.class);
ArgumentCaptor<Properties> cap = ArgumentCaptor.forClass(Properties.class);
verify(serverFactory).build(cap.capture());
@@ -272,10 +229,10 @@ public class RestServerTest {
}
@Test
- public void testStandardSevletAddedToProperty() {
+ public void testStandardServletAddedToProperty() {
when(params.getServletUriPath()).thenReturn("/metrics");
when(params.getServletClass()).thenReturn(MetricsServlet.class.getName());
- rest = new RestServer(params, Filter.class, Provider1.class, Provider2.class);
+ rest = new RestServer(params, Filter2.class, Provider1.class, Provider2.class);
ArgumentCaptor<Properties> cap = ArgumentCaptor.forClass(Properties.class);
verify(serverFactory).build(cap.capture());
@@ -341,7 +298,7 @@ public class RestServerTest {
@Test
public void testToString() {
- rest = new RestServer(params, Filter.class, Provider1.class, Provider2.class);
+ rest = new RestServer(params, Filter2.class, Provider1.class, Provider2.class);
assertNotNull(rest.toString());
}
@@ -372,22 +329,9 @@ public class RestServerTest {
when(params.isHttps()).thenReturn(true);
}
- private static class Filter extends AafAuthFilter {
- @Override
- protected String getPermissionType(HttpServletRequest request) {
- return "";
- }
-
- @Override
- protected String getPermissionInstance(HttpServletRequest request) {
- return "";
- }
- }
-
private static class Filter2 implements jakarta.servlet.Filter {
@Override
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
- throws IOException, ServletException {
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) {
// do nothing
}
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafAuthFilter.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafAuthFilter.java
deleted file mode 100644
index a9a19424..00000000
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafAuthFilter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 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.common.endpoints.http.server.test;
-
-import jakarta.servlet.http.HttpServletRequest;
-import org.onap.policy.common.endpoints.http.server.aaf.AafAuthFilter;
-
-public class TestAafAuthFilter extends AafAuthFilter {
-
- @Override
- protected String getRole(HttpServletRequest request) {
- String expectedPerm = "test|test|" + request.getMethod().toLowerCase();
- if (!expectedPerm.equals(super.getRole(request))) {
- throw new IllegalStateException("unexpected permission");
- } else {
- return "user";
- }
- }
-
- @Override
- protected String getPermissionType(HttpServletRequest request) {
- return "test";
- }
-
- @Override
- protected String getPermissionInstance(HttpServletRequest request) {
- return "test";
- }
-} \ No newline at end of file
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafGranularAuthFilter.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafGranularAuthFilter.java
deleted file mode 100644
index bccff70f..00000000
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafGranularAuthFilter.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 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.common.endpoints.http.server.test;
-
-import jakarta.servlet.http.HttpServletRequest;
-import org.onap.policy.common.endpoints.http.server.aaf.AafGranularAuthFilter;
-import org.onap.policy.common.utils.network.NetworkUtil;
-
-public class TestAafGranularAuthFilter extends AafGranularAuthFilter {
-
- @Override
- protected String getRole(HttpServletRequest request) {
- String expectedPerm = this.getPermissionTypeRoot()
- + request.getRequestURI().replace('/', '.') + "|"
- + NetworkUtil.getHostname() + "|"
- + request.getMethod().toLowerCase();
- if (!expectedPerm.equals(super.getRole(request))) {
- throw new IllegalStateException("unexpected AAF granular permission");
- } else {
- return "user";
- }
- }
-
- @Override
- public String getPermissionTypeRoot() {
- return "org.onap.policy";
- }
-} \ No newline at end of file
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java
index e3f0878f..ce0f58de 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2024 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -49,9 +49,9 @@ public class CommonTestData {
public static final boolean REST_SERVER_HTTPS = true;
public static final boolean REST_SERVER_AAF = false;
- public static final String TOPIC_NAME = "POLICY-PDP-PAP";
- public static final String TOPIC_INFRA = "dmaap";
- public static final String TOPIC_SERVER = "message-router";
+ public static final String TOPIC_NAME = "policy-pdp-pap";
+ public static final String TOPIC_INFRA = "kafka";
+ public static final String TOPIC_SERVER = "kafka:9092";
public static final List<TopicParameters> TOPIC_PARAMS =
Arrays.asList(getTopicParameters(TOPIC_NAME, TOPIC_INFRA, TOPIC_SERVER));
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.json
index 1f520456..48380426 100644
--- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.json
+++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.json
@@ -18,24 +18,8 @@
"fetchTimeout" : 101,
"fetchLimit" : 100,
"topicCommInfrastructure" : "UEB"
- }, {
- "servers" : [ "my-server" ],
- "topic" : "dmaap-source",
- "effectiveTopic" : "my-effective-topic",
- "recentEvents" : [ ],
- "alive" : false,
- "locked" : false,
- "apiKey" : "my-api-key",
- "apiSecret" : "my-api-secret",
- "useHttps" : true,
- "allowTracing": false,
- "allowSelfSignedCerts" : true,
- "consumerGroup" : "my-cons-group",
- "consumerInstance" : "my-cons-inst",
- "fetchTimeout" : 101,
- "fetchLimit" : 100,
- "topicCommInfrastructure" : "DMAAP"
- }, {
+ },
+ {
"servers" : [ "my-server" ],
"topic" : "noop-source",
"effectiveTopic" : "noop-source",
@@ -58,21 +42,8 @@
"allowSelfSignedCerts" : true,
"topicCommInfrastructure" : "UEB",
"partitionKey" : "${obj.topicSinks[0].partitionKey}"
- }, {
- "servers" : [ "my-server" ],
- "topic" : "dmaap-sink",
- "effectiveTopic" : "my-effective-topic",
- "recentEvents" : [ ],
- "alive" : false,
- "locked" : false,
- "apiKey" : "my-api-key",
- "apiSecret" : "my-api-secret",
- "useHttps" : true,
- "allowTracing": false,
- "allowSelfSignedCerts" : true,
- "topicCommInfrastructure" : "DMAAP",
- "partitionKey" : "my-partition"
- }, {
+ },
+ {
"servers" : [ "my-server" ],
"topic" : "noop-sink",
"effectiveTopic" : "noop-sink",
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.json
deleted file mode 100644
index 0f58e9b2..00000000
--- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "servers" : [ "svra", "svrb" ],
- "topic" : "my-topic",
- "effectiveTopic" : "my-effective-topic",
- "recentEvents" : [ ],
- "alive" : false,
- "locked" : false,
- "apiKey" : "my-api-key",
- "apiSecret" : "my-api-secret",
- "useHttps" : true,
- "allowTracing": true,
- "allowSelfSignedCerts" : true,
- "topicCommInfrastructure" : "DMAAP",
- "partitionKey" : "my-partition"
-}
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.json
deleted file mode 100644
index a3fc8b86..00000000
--- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "servers" : [ "svra", "svrb" ],
- "topic" : "my-topic",
- "effectiveTopic" : "my-effective-topic",
- "recentEvents" : [ ],
- "alive" : false,
- "locked" : false,
- "apiKey" : "my-api-key",
- "apiSecret" : "my-api-secret",
- "useHttps" : true,
- "allowTracing": true,
- "allowSelfSignedCerts" : true,
- "consumerGroup" : "my-cons-group",
- "consumerInstance" : "my-cons-inst",
- "fetchTimeout" : 101,
- "fetchLimit" : 100,
- "topicCommInfrastructure" : "DMAAP"
-}
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/http/server/internal/HttpServerTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/http/server/internal/HttpServerTest.json
index 8fa597ab..aba9d682 100644
--- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/http/server/internal/HttpServerTest.json
+++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/http/server/internal/HttpServerTest.json
@@ -1,5 +1,4 @@
{
- "aaf": false,
"alive": false,
"host": "localhost",
"name": "echo",
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_invalid.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_invalid.json
index b106d721..a7455525 100644
--- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_invalid.json
+++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_invalid.json
@@ -2,6 +2,5 @@
"port": 6969,
"userName": "username",
"password": "password",
- "https": true,
- "aaf": false
+ "https": true
} \ No newline at end of file
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_valid.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_valid.json
index 6c113056..61d793a8 100644
--- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_valid.json
+++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_valid.json
@@ -3,6 +3,5 @@
"port": 6969,
"userName": "username",
"password": "password",
- "https": true,
- "aaf": false
+ "https": true
} \ No newline at end of file
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_all_params.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_all_params.json
index de9487be..89e464dd 100644
--- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_all_params.json
+++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_all_params.json
@@ -1,8 +1,8 @@
{
"topicSources" : [ {
- "topic" : "POLICY-PDP-PAP1",
- "servers" : [ "message-router2, message-router3" ],
- "topicCommInfrastructure" : "dmaap",
+ "topic" : "policy-pdp-pap1",
+ "servers" : [ "kafka2, kafka3" ],
+ "topicCommInfrastructure" : "kafka",
"effectiveTopic" : "my-effective-topic",
"apiKey" : "my-api-key",
"apiSecret" : "my-api-secret",
@@ -30,9 +30,9 @@
"serializationProvider": "serializationProvider1"
}],
"topicSinks" : [ {
- "topic" : "POLICY-PDP-PAP1",
- "servers" : [ "message-router2, message-router3" ],
- "topicCommInfrastructure" : "dmaap",
+ "topic" : "policy-pdp-pap1",
+ "servers" : [ "kafka2, kafka3" ],
+ "topicCommInfrastructure" : "kafka",
"effectiveTopic" : "my-effective-topic",
"apiKey" : "my-api-key",
"apiSecret" : "my-api-secret",
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_missing_mandatory.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_missing_mandatory.json
index 157d6086..216c11ec 100644
--- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_missing_mandatory.json
+++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_missing_mandatory.json
@@ -1,12 +1,12 @@
{
"topicSources" : [ {
- "topic" : "POLICY-PDP-PAP1",
+ "topic" : "policy-pdp-pap1",
"servers" : [],
- "topicCommInfrastructure" : "dmaap"
+ "topicCommInfrastructure" : "kafka"
}],
"topicSinks" : [ {
- "topic" : "POLICY-PDP-PAP2",
- "servers" : [ "message-router1, message-router2" ],
- "topicCommInfrastructure" : "dmaap"
+ "topic" : "policy-pdp-pap2",
+ "servers" : [ "kafka1, kafka2" ],
+ "topicCommInfrastructure" : "kafka"
}]
} \ No newline at end of file
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_valid.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_valid.json
index b89f1525..2603bfdc 100644
--- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_valid.json
+++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_valid.json
@@ -4,26 +4,26 @@
"servers" : [ "my-server" ],
"topicCommInfrastructure" : "ueb"
},{
- "topic" : "POLICY-PDP-PAP1",
- "servers" : [ "message-router1, message-router2" ],
- "topicCommInfrastructure" : "dmaap"
+ "topic" : "policy-pdp-pap1",
+ "servers" : [ "kafka1, kafka2" ],
+ "topicCommInfrastructure" : "kafka"
},{
- "topic" : "POLICY-PDP-PAP2",
- "servers" : [ "message-router2, message-router3" ],
- "topicCommInfrastructure" : "dmaap"
+ "topic" : "policy-pdp-pap2",
+ "servers" : [ "kafka2, kafka3" ],
+ "topicCommInfrastructure" : "kafka"
}],
"topicSinks" : [ {
"topic" : "ueb-sink",
"servers" : [ "my-server" ],
"topicCommInfrastructure" : "ueb"
},{
- "topic" : "POLICY-PDP-PAP2",
- "servers" : [ "message-router1, message-router2" ],
- "topicCommInfrastructure" : "dmaap"
+ "topic" : "policy-pdp-pap2",
+ "servers" : [ "kafka1, kafka2" ],
+ "topicCommInfrastructure" : "kafka"
},{
- "topic" : "POLICY-PDP-PAP3",
- "servers" : [ "message-router2, message-router3" ],
- "topicCommInfrastructure" : "dmaap",
+ "topic" : "policy-pdp-pap3",
+ "servers" : [ "kafka2, kafka3" ],
+ "topicCommInfrastructure" : "kafka",
"effectiveTopic":"effectiveTopic1",
"allowSelfSignedCerts":true
}]