Implement test cases for fabric discovery plugin 45/14745/1
authorArun S. Yerra <arun.yerra@huawei.com>
Fri, 22 Sep 2017 22:20:32 +0000 (15:20 -0700)
committerArun S. Yerra <arun.yerra@huawei.com>
Fri, 22 Sep 2017 22:20:32 +0000 (15:20 -0700)
This change adds a negative test case to test input from
directed graph to start listening to domain controller
notifications.

Issue-id: CCSDK-96

Change-Id: I2dd1a4d2264df4c142362e242e04bf9495e0351a
Signed-off-by: Arun S. Yerra <arun.yerra@huawei.com>
fabric-discovery-plugin/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/fabricdiscovery/TestFabricDiscoveryPlugin.java

index f5dc7cb..ac04618 100644 (file)
@@ -17,6 +17,8 @@ public class TestFabricDiscoveryPlugin {
     private static final Logger LOG = LoggerFactory.getLogger(TestFabricDiscoveryPlugin.class);
     private static final String C_STREAM =
         "ws://localhost:8185/data-change-event-subscription/network-topology:network-topology/datastore=CONFIGURATION/scope=BASE";
+    private static final String W_STREAM =
+        "get://localhost:8185/data-change-event-subscription/network-topology:network/datastore=CONFIGURATION/scope=BASE";
     private final String FB_DISCOVERY_STATUS = "fb-response";
 
     @Test
@@ -32,4 +34,25 @@ public class TestFabricDiscoveryPlugin {
         fdp.processDcNotificationStream(p, ctx);
         Assert.assertEquals("Success", ctx.getAttribute(FB_DISCOVERY_STATUS));
     }
+
+    @Test
+    public void connectToNotificationServerFailure() throws Exception {
+        SvcLogicContext ctx = new SvcLogicContext();
+        String stream = W_STREAM;
+
+        Map<String, String> p = new HashMap<>();
+        p.put("stream", stream);
+        p.put("enable", "true");
+
+        FabricDiscoveryPlugin fdp = new FabricDiscoveryPlugin();
+        try {
+            fdp.processDcNotificationStream(p, ctx);
+            LOG.info("Connection to Stream:{} succeeded.", stream);
+        } catch (Exception e) {
+            LOG.info("Received Exception while connecting to Fabric Discovery notification server: {}", e.getMessage());
+        } finally {
+            Assert.assertEquals("Failure", ctx.getAttribute(FB_DISCOVERY_STATUS));
+        }
+    }
+
 }