Add unit test case for dmaap-listener.
Change-Id: I501614016c96d8300bc15cdf1819691f95c467f4
Issue-ID: CCSDK-106
Signed-off-by: Dan Timoney <dtimoney@att.com>
* 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.
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()) {
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(";");
--- /dev/null
+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);
+ }
+ }
+ }
+
+}
--- /dev/null
+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
+
--- /dev/null
+preferredRouteKey=ABC123
\ No newline at end of file
--- /dev/null
+subscriptions=org.onap.ccsdk.sli.northbound.dmaapclient.DummyDmaapConsumer:dmaap-consumer-1.properties
\ No newline at end of file