plugin-stub: InventoryService to Stub 76/376/2
authorKalvin Hom <kahom@cisco.com>
Mon, 20 May 2013 22:45:11 +0000 (15:45 -0700)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 22 May 2013 12:46:49 +0000 (12:46 +0000)
Changing the InventoryService to use the
node STUB type instead of OF.  Changed the
SwitchManagerIntegrationTest to match the
stub type changes.

Change-Id: I1a508bb8893c0f7f655a0270234aeeb13cf644b3
Signed-off-by: Kalvin Hom <kahom@cisco.com>
opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/InventoryService.java
opendaylight/switchmanager/integrationtest/src/test/java/org/opendaylight/controller/switchmanager/internal/SwitchmanagerIntegrationTest.java

index 54b4ea17af64e186d4983a6d9a9fea8d27af7041..64d4fc167597e39e2ca479ad5984221071ed346a 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.controller.sal.core.Bandwidth;
 import org.opendaylight.controller.sal.core.Buffers;
 import org.opendaylight.controller.sal.core.Capabilities;
 import org.opendaylight.controller.sal.core.Capabilities.CapabilitiesType;
+import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Property;
@@ -53,7 +54,8 @@ public class InventoryService implements IPluginInInventoryService {
     void init() {
         nodeProps = new ConcurrentHashMap<Node, Map<String, Property>>();
         nodeConnectorProps = new ConcurrentHashMap<NodeConnector, Map<String, Property>>();
-
+        Node.NodeIDType.registerIDType("STUB", Integer.class);
+        NodeConnector.NodeConnectorIDType.registerIDType("STUB", Integer.class, "STUB");
     }
 
     /**
@@ -106,9 +108,13 @@ public class InventoryService implements IPluginInInventoryService {
 
         // setup property map for all nodes
         Node node;
-        node = NodeCreator.createOFNode(2L);
+        try{
+            node = new Node("STUB", new Integer(0xCAFE));
+        }catch(ConstructionException e){
+            node = null;
+        }       
+     
         nodeProps.put(node, propMap);
-
         return nodeProps;
     }
 
@@ -130,10 +136,16 @@ public class InventoryService implements IPluginInInventoryService {
         ncPropMap.put(State.StatePropName, st);
 
         // setup property map for all node connectors
-        NodeConnector nc = NodeConnectorCreator.createOFNodeConnector
-                ((short)2, NodeCreator.createOFNode(3L));
+        NodeConnector nc;
+        Node node;
+        try{
+            node = new Node("STUB", new Integer(0xCAFE));
+            nc = new NodeConnector("STUB", 0xCAFE, node);
+        }catch(ConstructionException e){
+            nc = null;
+            node = null;
+        }
         nodeConnectorProps.put(nc, ncPropMap);
-
         return nodeConnectorProps;
     }
 
index 450a7174e062c25e0627c8ddf6f6a0f14c64e33c..790f48b760c41293e9b8ef537e1a3b886c05c0ce 100644 (file)
@@ -37,6 +37,7 @@ import org.opendaylight.controller.sal.core.Actions;
 import org.opendaylight.controller.sal.core.Bandwidth;
 import org.opendaylight.controller.sal.core.Buffers;
 import org.opendaylight.controller.sal.core.Capabilities;
+import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.State;
@@ -189,7 +190,14 @@ public class SwitchmanagerIntegrationTest {
     public void testNodeProp() throws UnknownHostException {
         assertNotNull(this.switchManager);
 
-        Node node = NodeCreator.createOFNode((long)2);
+        Node node;
+        try{
+            node = new Node("STUB", new Integer(0xCAFE));
+        }catch(ConstructionException e){
+            //test failed if node cannot be created.
+            node = null;
+            Assert.assertTrue(false);
+        }
         Map<String, Property> propMap = this.switchManager.getNodeProps(node);
         Assert.assertFalse(propMap.isEmpty());
 
@@ -210,9 +218,17 @@ public class SwitchmanagerIntegrationTest {
     @Test
     public void testNodeConnectorProp() throws UnknownHostException {
         assertNotNull(this.switchManager);
-
-        NodeConnector nc = NodeConnectorCreator.createOFNodeConnector
-                ((short)2, NodeCreator.createOFNode((long)3));
+        Node node;
+        NodeConnector nc;
+        try {
+            node = new Node("STUB", 0xCAFE);
+            nc = new NodeConnector("STUB", 0xCAFE, node);
+        }
+        catch(ConstructionException e){
+            node = null;
+            nc = null;
+            Assert.assertTrue(false);
+        }
         Map<String, Property> propMap = this.switchManager.getNodeConnectorProps(nc);
         Assert.assertFalse(propMap.isEmpty());