From 24ec831c484af2c756540027f5b341d4973e8649 Mon Sep 17 00:00:00 2001 From: Kalvin Hom Date: Mon, 20 May 2013 15:45:11 -0700 Subject: [PATCH] plugin-stub: InventoryService to Stub 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 --- .../stub/internal/InventoryService.java | 24 ++++++++++++++----- .../SwitchmanagerIntegrationTest.java | 24 +++++++++++++++---- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/InventoryService.java b/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/InventoryService.java index 54b4ea17af..64d4fc1675 100644 --- a/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/InventoryService.java +++ b/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/InventoryService.java @@ -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>(); nodeConnectorProps = new ConcurrentHashMap>(); - + 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; } diff --git a/opendaylight/switchmanager/integrationtest/src/test/java/org/opendaylight/controller/switchmanager/internal/SwitchmanagerIntegrationTest.java b/opendaylight/switchmanager/integrationtest/src/test/java/org/opendaylight/controller/switchmanager/internal/SwitchmanagerIntegrationTest.java index 450a7174e0..790f48b760 100644 --- a/opendaylight/switchmanager/integrationtest/src/test/java/org/opendaylight/controller/switchmanager/internal/SwitchmanagerIntegrationTest.java +++ b/opendaylight/switchmanager/integrationtest/src/test/java/org/opendaylight/controller/switchmanager/internal/SwitchmanagerIntegrationTest.java @@ -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 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 propMap = this.switchManager.getNodeConnectorProps(nc); Assert.assertFalse(propMap.isEmpty()); -- 2.36.6