simple JUnit test for switchmanager.northbound 78/78/1
authorKalvin Hom <kahom@cisco.com>
Wed, 27 Mar 2013 21:58:36 +0000 (14:58 -0700)
committerKalvin Hom <kahom@cisco.com>
Wed, 27 Mar 2013 21:58:36 +0000 (14:58 -0700)
Signed-off-by: Kalvin Hom <kahom@cisco.com>
opendaylight/northbound/switchmanager/src/test/java/org/opendaylight/controller/switchmanager/northbound/SwitchManagerNorthboundTest.java [new file with mode: 0644]

diff --git a/opendaylight/northbound/switchmanager/src/test/java/org/opendaylight/controller/switchmanager/northbound/SwitchManagerNorthboundTest.java b/opendaylight/northbound/switchmanager/src/test/java/org/opendaylight/controller/switchmanager/northbound/SwitchManagerNorthboundTest.java
new file mode 100644 (file)
index 0000000..a8b18d5
--- /dev/null
@@ -0,0 +1,75 @@
+package org.opendaylight.controller.switchmanager.northbound;
+
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.ArrayList;
+
+import org.junit.Assert;
+import org.junit.Test;
+import junit.framework.TestCase;
+
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.Property;
+import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
+import org.opendaylight.controller.sal.utils.NodeCreator;
+
+public class SwitchManagerNorthboundTest extends TestCase {
+
+       @Test
+       public void testNodes() {
+               List<NodeProperties> nodeProperties = new ArrayList<NodeProperties>();
+               Nodes nodes = new Nodes(nodeProperties);
+               Assert.assertTrue(nodes.getNodeProperties().equals(nodeProperties));
+               nodes.setNodeProperties(null);
+               Assert.assertTrue(nodes.getNodeProperties() == null);
+       }
+       
+       @Test
+       public void testNodeProperties() {
+               Node node = NodeCreator.createOFNode(1L);
+               NodeProperties np= new NodeProperties(node, null);
+               Assert.assertTrue(np.getNode().equals(node));
+               Assert.assertTrue(np.getProperties() == null);
+               
+               Node node2 = NodeCreator.createOFNode(2L);
+               np.setNode(node2);
+               Assert.assertTrue(np.getNode().equals(node2));
+
+               Set<Property> props = new HashSet<Property>();
+               np.setProperties(props);
+               Assert.assertTrue(np.getProperties().equals(props));
+       }
+
+       @Test
+       public void testNodeConnectors() {
+               List<NodeConnectorProperties> nodeConnectorProperties = new ArrayList<NodeConnectorProperties>();
+               NodeConnectors ncs = new NodeConnectors(nodeConnectorProperties);
+               Assert.assertTrue(ncs.getNodeConnectorProperties().equals(nodeConnectorProperties));
+               ncs.setNodeConnectorProperties(null);
+               Assert.assertTrue(ncs.getNodeConnectorProperties() == null);
+       }
+       
+       @Test
+       public void testNodeConnectorProperties() {
+               Node node = NodeCreator.createOFNode(1L);
+        NodeConnector port = NodeConnectorCreator.createOFNodeConnector(
+                (short) 24, node);
+        
+        NodeConnectorProperties ncp= new NodeConnectorProperties(port, null);
+               Assert.assertTrue(ncp.getProperties() == null);
+               Assert.assertTrue(ncp.getNodeConnector().equals(port));
+               
+        NodeConnector port2 = NodeConnectorCreator.createOFNodeConnector(
+                (short) 33, node);
+               ncp.setNodeConnector(port2);
+               Assert.assertTrue(ncp.getNodeConnector().equals(port2));
+
+               Set<Property> props = new HashSet<Property>();
+               ncp.setProperties(props);
+               Assert.assertTrue(ncp.getProperties().equals(props));
+       }
+       
+}

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.