aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncJsonDmaapConsumer.java116
-rw-r--r--dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncOdlConnection.java26
-rw-r--r--ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncOdlConnection.java45
3 files changed, 187 insertions, 0 deletions
diff --git a/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncJsonDmaapConsumer.java b/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncJsonDmaapConsumer.java
index 0d65231d..620098cb 100644
--- a/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncJsonDmaapConsumer.java
+++ b/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncJsonDmaapConsumer.java
@@ -10,6 +10,16 @@ package org.onap.ccsdk.sli.northbound.dmaapclient;
import org.junit.Test;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+
+import java.util.Map;
+import java.util.Properties;
+
public class TestSdncJsonDmaapConsumer {
private static final String DMAAP_LISTENER_PROPERTIES = "dmaap-listener.properties";
private static final String DMAAP_LISTENER_PROPERTIES_DIR = "src/test/resources";
@@ -19,4 +29,110 @@ public class TestSdncJsonDmaapConsumer {
SdncFlatJsonDmaapConsumer consumer = new SdncFlatJsonDmaapConsumer();
consumer.processMsg(null);
}
+
+ @Test
+ public void testProcessMsgFieldMap() throws Exception {
+ SdncFlatJsonDmaapConsumer consumer = new SdncFlatJsonDmaapConsumer();
+
+ String DMAAPLISTENERROOT = "DMAAPLISTENERROOT";
+ File directory = new File("lib");
+
+ if (! directory.exists()){
+ directory.mkdir();
+ }
+
+ File file = new File("lib" + "/" + "input.map");
+ try{
+ FileWriter fw = new FileWriter(file.getAbsoluteFile());
+ BufferedWriter bw = new BufferedWriter(fw);
+ bw.write("SDNC.endpoint=>http://localhost:8282/restconf/operations");
+ bw.close();
+ }
+ catch (Exception 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);
+ }
+
+ String msg = "{\n" +
+ " \"input\" : { \n" +
+ " }\n" +
+ "}";
+
+ InputStream propStr = TestSdncJsonDmaapConsumer.class.getResourceAsStream("/dmaap-consumer-pserver.properties");
+ Properties props = new Properties();
+
+ props.load(propStr);
+
+ consumer.init(props, "src/test/resources/dmaap-consumer-pserver.properties");
+ consumer.processMsg(msg);
+ }
+
+ @Test(expected = InvalidMessageException.class)
+ public void testProcessMsgFieldMapNoSdncEndPoint() throws Exception {
+ SdncFlatJsonDmaapConsumer consumer = new SdncFlatJsonDmaapConsumer();
+
+ String DMAAPLISTENERROOT = "DMAAPLISTENERROOT";
+ File directory = new File("lib");
+
+ if (! directory.exists()){
+ directory.mkdir();
+ }
+
+ File file = new File("lib" + "/" + "input.map");
+ try{
+ FileWriter fw = new FileWriter(file.getAbsoluteFile());
+ BufferedWriter bw = new BufferedWriter(fw);
+ bw.write("SDNC");
+ bw.close();
+ }
+ catch (Exception 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);
+ }
+
+ String msg = "{\n" +
+ " \"input\" : { \n" +
+ " }\n" +
+ "}";
+
+ InputStream propStr = TestSdncJsonDmaapConsumer.class.getResourceAsStream("/dmaap-consumer-pserver.properties");
+ Properties props = new Properties();
+
+ props.load(propStr);
+
+ consumer.init(props, "src/test/resources/dmaap-consumer-pserver.properties");
+ consumer.processMsg(msg);
+ }
+
+ @Test(expected = InvalidMessageException.class)
+ public void testProcessMsgFieldMapNoFieldMap() throws Exception {
+ SdncFlatJsonDmaapConsumer consumer = new SdncFlatJsonDmaapConsumer();
+
+ String msg = "{\n" +
+ " \"input\" : { \n" +
+ " }\n" +
+ "}";
+
+ consumer.processMsg(msg);
+ }
}
diff --git a/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncOdlConnection.java b/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncOdlConnection.java
new file mode 100644
index 00000000..db24a454
--- /dev/null
+++ b/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncOdlConnection.java
@@ -0,0 +1,26 @@
+package org.onap.ccsdk.sli.northbound.dmaapclient;
+
+import org.junit.Test;
+
+import java.io.IOException;
+import java.net.ConnectException;
+
+public class TestSdncOdlConnection {
+
+ @Test
+ public void test() {
+
+ try {
+ SdncOdlConnection sdncOdlConnection = SdncOdlConnection.newInstance("https://127.0.0.1:8447/aai/v11/network/pnfs/pnf/a8098c1a-f86e-11da-bd1a-00112444be1e", "", "");
+ sdncOdlConnection.send("PUT", "application/json", "{\n" +
+ " \"input\" : { \n" +
+ " }\n" +
+ "}");
+ } catch (ConnectException e) {
+ //Connection exception
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncOdlConnection.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncOdlConnection.java
new file mode 100644
index 00000000..1fac0c29
--- /dev/null
+++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncOdlConnection.java
@@ -0,0 +1,45 @@
+package org.onap.ccsdk.sli.northbound.uebclient;
+
+import ch.vorburger.mariadb4j.DB;
+import ch.vorburger.mariadb4j.DBConfigurationBuilder;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
+import org.openecomp.sdc.api.IDistributionClient;
+import org.openecomp.sdc.api.notification.INotificationData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.ConnectException;
+import java.net.URL;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.Properties;
+
+import static org.mockito.Mockito.mock;
+
+public class TestSdncOdlConnection {
+
+ @Test
+ public void test() {
+
+ try {
+ SdncOdlConnection sdncOdlConnection = SdncOdlConnection.newInstance("https://127.0.0.1:8447/aai/v11/network/pnfs/pnf/a8098c1a-f86e-11da-bd1a-00112444be1e", "", "");
+ sdncOdlConnection.send("PUT", "application/json", "{\n" +
+ " \"input\" : { \n" +
+ " }\n" +
+ "}");
+ } catch (ConnectException e) {
+ //Connection exception
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+}