1 package jtest.org.onap.ccsdk.sli.plugins.fabricdiscovery;
3 import java.util.HashMap;
5 import org.junit.Assert;
7 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
8 import org.onap.ccsdk.sli.plugins.fabricdiscovery.FabricDiscoveryPlugin;
9 import org.slf4j.Logger;
10 import org.slf4j.LoggerFactory;
13 * Created by arun on 9/18/17.
16 public class TestFabricDiscoveryPlugin {
17 private static final Logger LOG = LoggerFactory.getLogger(TestFabricDiscoveryPlugin.class);
18 private static final String C_STREAM =
19 "ws://localhost:8185/data-change-event-subscription/network-topology:network-topology/datastore=CONFIGURATION/scope=BASE";
20 private static final String W_STREAM =
21 "get://localhost:8185/data-change-event-subscription/network-topology:network/datastore=CONFIGURATION/scope=BASE";
22 private final String FB_DISCOVERY_STATUS = "fb-response";
25 public void connectToNotificationServerSuccess() throws Exception {
26 SvcLogicContext ctx = new SvcLogicContext();
27 String stream = C_STREAM;
29 Map<String, String> p = new HashMap<String, String>();
30 p.put("stream", stream);
31 p.put("enable", "true");
33 FabricDiscoveryPlugin fdp = new FabricDiscoveryPlugin();
34 fdp.processDcNotificationStream(p, ctx);
35 Assert.assertEquals("Success", ctx.getAttribute(FB_DISCOVERY_STATUS));
39 public void connectToNotificationServerFailure() throws Exception {
40 SvcLogicContext ctx = new SvcLogicContext();
41 String stream = W_STREAM;
43 Map<String, String> p = new HashMap<>();
44 p.put("stream", stream);
45 p.put("enable", "true");
47 FabricDiscoveryPlugin fdp = new FabricDiscoveryPlugin();
49 fdp.processDcNotificationStream(p, ctx);
50 LOG.info("Connection to Stream:{} succeeded.", stream);
51 } catch (Exception e) {
52 LOG.info("Received Exception while connecting to Fabric Discovery notification server: {}", e.getMessage());
54 Assert.assertEquals("Failure", ctx.getAttribute(FB_DISCOVERY_STATUS));