summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2017-10-03 07:34:22 -0400
committerDan Timoney <dtimoney@att.com>2017-10-03 07:34:22 -0400
commit12d893efa353bc5bd5054cd59998a623f5d058d0 (patch)
tree44baab68c60f9dcd7e093880f60c69b2a54b972d
parent119808a2ded9ea8c4dd9d1eef96f39ab2e001ff7 (diff)
Add unit test for dmaap-listener
Add unit test case for dmaap-listener. Change-Id: I501614016c96d8300bc15cdf1819691f95c467f4 Issue-ID: CCSDK-106 Signed-off-by: Dan Timoney <dtimoney@att.com>
-rw-r--r--dmaap-listener/src/main/java/org/onap/ccsdk/sli/northbound/dmaapclient/DmaapListener.java8
-rw-r--r--dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestDmaapListener.java52
-rwxr-xr-xdmaap-listener/src/test/resources/dmaap-consumer-1.properties35
-rwxr-xr-xdmaap-listener/src/test/resources/dmaap-listener.preferredRoute.txt1
-rwxr-xr-xdmaap-listener/src/test/resources/dmaap-listener.properties1
5 files changed, 93 insertions, 4 deletions
diff --git a/dmaap-listener/src/main/java/org/onap/ccsdk/sli/northbound/dmaapclient/DmaapListener.java b/dmaap-listener/src/main/java/org/onap/ccsdk/sli/northbound/dmaapclient/DmaapListener.java
index de76e454e..ce099cd64 100644
--- a/dmaap-listener/src/main/java/org/onap/ccsdk/sli/northbound/dmaapclient/DmaapListener.java
+++ b/dmaap-listener/src/main/java/org/onap/ccsdk/sli/northbound/dmaapclient/DmaapListener.java
@@ -8,9 +8,9 @@
* 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.
@@ -96,7 +96,7 @@ public class DmaapListener {
return threadsRunning;
}
- private static Properties loadProperties(String propPath, Properties properties) {
+ static Properties loadProperties(String propPath, Properties properties) {
File propFile = new File(propPath);
if (!propFile.canRead()) {
@@ -113,7 +113,7 @@ public class DmaapListener {
return properties;
}
- private static boolean handleSubscriptions(String subscriptionStr, String propDir, Properties properties,
+ static boolean handleSubscriptions(String subscriptionStr, String propDir, Properties properties,
List<SdncDmaapConsumer> consumers) {
String[] subscriptions = subscriptionStr.split(";");
diff --git a/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestDmaapListener.java b/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestDmaapListener.java
new file mode 100644
index 000000000..943ef0204
--- /dev/null
+++ b/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestDmaapListener.java
@@ -0,0 +1,52 @@
+package org.onap.ccsdk.sli.northbound.dmaapclient;
+
+import static org.junit.Assert.*;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestDmaapListener {
+
+ private static final String DMAAP_LISTENER_PROPERTIES = "dmaap-listener.properties";
+ private static final String DMAAP_LISTENER_PROPERTIES_DIR = "src/test/resources";
+
+ private static final Logger LOG = LoggerFactory.getLogger(TestDmaapListener.class);
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @Test
+ public void test() {
+ Properties properties = new Properties();
+ String propFileName = DMAAP_LISTENER_PROPERTIES;
+ String propPath = null;
+ String propDir = DMAAP_LISTENER_PROPERTIES_DIR;
+
+ List<SdncDmaapConsumer> consumers = new LinkedList<>();
+
+
+ propPath = propDir + "/" + propFileName;
+
+ if (propPath != null) {
+ properties = DmaapListener.loadProperties(propPath, properties);
+
+ String subscriptionStr = properties.getProperty("subscriptions");
+
+ boolean threadsRunning = false;
+
+ LOG.debug("Dmaap subscriptions : " + subscriptionStr);
+
+ if (subscriptionStr != null) {
+ threadsRunning = DmaapListener.handleSubscriptions(subscriptionStr, propDir, properties, consumers);
+ }
+ }
+ }
+
+}
diff --git a/dmaap-listener/src/test/resources/dmaap-consumer-1.properties b/dmaap-listener/src/test/resources/dmaap-consumer-1.properties
new file mode 100755
index 000000000..ae83ef8c2
--- /dev/null
+++ b/dmaap-listener/src/test/resources/dmaap-consumer-1.properties
@@ -0,0 +1,35 @@
+TransportType=HTTPAAF
+Latitude =40.397443
+Longitude =-74.135602
+Version =1.0
+ServiceName =localhost/events
+Environment =DEV
+Partner =
+SubContextPath =/
+Protocol =http
+MethodType =GET
+username =test
+password =test
+contenttype =application/json
+authKey=ABC123
+authDate=2016-05-10T13:13:50-0700
+host=localhost:3904
+topic=ccsdk-topic
+group=ccsdk-unittest
+id=ccsdk_unittest
+timeout=15000
+limit=1000
+filter=
+AFT_DME2_EXCHANGE_REQUEST_HANDLERS=com.att.nsa.test.PreferredRouteRequestHandler
+AFT_DME2_EXCHANGE_REPLY_HANDLERS=com.att.nsa.test.PreferredRouteReplyHandler
+AFT_DME2_REQ_TRACE_ON=true
+AFT_ENVIRONMENT=AFTUAT
+AFT_DME2_EP_CONN_TIMEOUT=15000
+AFT_DME2_ROUNDTRIP_TIMEOUT_MS=240000
+AFT_DME2_EP_READ_TIMEOUT_MS=50000
+sessionstickinessrequired=NO
+DME2preferredRouterFilePath=src/test/resources/dmaap-listener.preferredRoute.txt
+sdnc.odl.user=admin
+sdnc.odl.password=admin
+sdnc.odl.url-base=http://localhost:8282/restconf/operations
+
diff --git a/dmaap-listener/src/test/resources/dmaap-listener.preferredRoute.txt b/dmaap-listener/src/test/resources/dmaap-listener.preferredRoute.txt
new file mode 100755
index 000000000..88705f73b
--- /dev/null
+++ b/dmaap-listener/src/test/resources/dmaap-listener.preferredRoute.txt
@@ -0,0 +1 @@
+preferredRouteKey=ABC123 \ No newline at end of file
diff --git a/dmaap-listener/src/test/resources/dmaap-listener.properties b/dmaap-listener/src/test/resources/dmaap-listener.properties
new file mode 100755
index 000000000..ed180e515
--- /dev/null
+++ b/dmaap-listener/src/test/resources/dmaap-listener.properties
@@ -0,0 +1 @@
+subscriptions=org.onap.ccsdk.sli.northbound.dmaapclient.DummyDmaapConsumer:dmaap-consumer-1.properties \ No newline at end of file