summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshashikanth.vh <shashikanth.vh@huawei.com>2018-03-28 17:32:01 +0530
committerShashikanth VH <shashikanth.vh@huawei.com>2018-03-28 14:00:44 +0000
commit7fc8f9fe913e35121c8e9f6e222c9b741beefdda (patch)
treeaef4230aec7e5d95a7d10146ffd34b66b24dd145
parente290ebd8696ea897d20cf0234c33e9104fca3853 (diff)
coverage SdncAaiDmaapConsumer
Coverage improvement for SdncAaiDmaapConsumer https://jira.onap.org/browse/CCSDK-213?jql=project%20%3D%20CCSDK%20AND%20text%20~%20coverage Issue-ID: CCSDK-213 Change-Id: Icc9af3a9f27d4bae543525b5651d1f6485ef8857 Signed-off-by: shashikanth.vh <shashikanth.vh@huawei.com>
-rw-r--r--dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncPserverDmaapReceiver.java90
-rw-r--r--ueb-listener/src/test/resources/incoming/src_test_resources_csars_nsepc.csarbin0 -> 42569 bytes
2 files changed, 90 insertions, 0 deletions
diff --git a/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncPserverDmaapReceiver.java b/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncPserverDmaapReceiver.java
index db7cbd72c..963b20d68 100644
--- a/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncPserverDmaapReceiver.java
+++ b/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncPserverDmaapReceiver.java
@@ -10,8 +10,15 @@ package org.onap.ccsdk.sli.northbound.dmaapclient;
import static org.junit.Assert.assertTrue;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.util.Map;
import java.util.Properties;
+import org.apache.commons.io.FileUtils;
+
import org.junit.Before;
import org.junit.Test;
@@ -81,5 +88,88 @@ public class TestSdncPserverDmaapReceiver {
assertTrue(rpcMsgbody.indexOf("common-header") != -1);
}
+ @Test
+ public void testProcessMsgFieldMap() throws Exception {
+
+
+ String DMAAPLISTENERROOT = "DMAAPLISTENERROOT";
+ File directory = new File("lib");
+
+ if (! directory.exists()){
+ directory.mkdir();
+ }
+
+ File source = new File("src/main/resources");
+ File dest = new File("lib/");
+ try {
+ FileUtils.copyDirectory(source, dest);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ Map<String, String> env = System.getenv();
+ Class<?> cl = env.getClass();
+ Field field = cl.getDeclaredField("m");
+ field.setAccessible(true);
+ Map<String, String> writableEnv = (Map<String, String>) field.get(env);
+ writableEnv.put(DMAAPLISTENERROOT, ".");
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to set environment variable", e);
+ }
+ Properties props = new Properties();
+
+ SdncAaiDmaapConsumer consumer = new SdncAaiDmaapConsumer();
+
+ InputStream propStr = TestSdncPserverDmaapReceiver.class.getResourceAsStream("/dmaap-consumer-pserver.properties");
+
+
+ props.load(propStr);
+
+ consumer.init(props, "src/test/resources/dmaap-consumer-pserver.properties");
+ consumer.processMsg(aaiInput);
+ }
+
+ @Test(expected = InvalidMessageException.class)
+ public void testProcessMsgNullMessage() throws Exception {
+ Properties props = new Properties();
+
+ SdncAaiDmaapConsumer consumer = new SdncAaiDmaapConsumer();
+ consumer.processMsg(null);
+ }
+
+ @Test(expected = InvalidMessageException.class)
+ public void testProcessMsgInvalidMessage() throws Exception {
+ Properties props = new Properties();
+
+ SdncAaiDmaapConsumer consumer = new SdncAaiDmaapConsumer();
+ consumer.processMsg("test");
+ }
+
+ @Test
+ public void testProcessMsgMissingEventHeader() throws Exception {
+ Properties props = new Properties();
+
+ SdncAaiDmaapConsumer consumer = new SdncAaiDmaapConsumer();
+ consumer.processMsg("{\n" +
+ " \"input\" : { \n" +
+ " }\n" +
+ "}");
+ }
+
+ @Test
+ public void testProcessMsgInvalidEventType() throws Exception {
+ Properties props = new Properties();
+
+ String msg = "{\"cambria.partition\": \"AAI\",\r\n" +
+ " \"event-header\": {\"event-type\": \"TEST-EVENT\"}}";
+
+ SdncAaiDmaapConsumer consumer = new SdncAaiDmaapConsumer();
+ consumer.processMsg(msg);
+ }
+
+
+
+
}
diff --git a/ueb-listener/src/test/resources/incoming/src_test_resources_csars_nsepc.csar b/ueb-listener/src/test/resources/incoming/src_test_resources_csars_nsepc.csar
new file mode 100644
index 000000000..087d8c3d8
--- /dev/null
+++ b/ueb-listener/src/test/resources/incoming/src_test_resources_csars_nsepc.csar
Binary files differ