Merge "JUnit Test for Topology Northbound"
authorAlessandro Boch <aboch@cisco.com>
Thu, 28 Mar 2013 23:01:30 +0000 (23:01 +0000)
committerGerrit Code Review <gerrit@daylight1.linux-foundation.org>
Thu, 28 Mar 2013 23:01:30 +0000 (23:01 +0000)
opendaylight/northbound/flowprogrammer/src/test/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthboundTest.java [new file with mode: 0644]
opendaylight/northbound/hosttracker/src/test/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthboundTest.java [new file with mode: 0644]
opendaylight/northbound/staticrouting/src/test/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthboundTest.java [new file with mode: 0644]
opendaylight/northbound/subnets/src/test/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthboundTest.java [new file with mode: 0644]

diff --git a/opendaylight/northbound/flowprogrammer/src/test/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthboundTest.java b/opendaylight/northbound/flowprogrammer/src/test/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthboundTest.java
new file mode 100644 (file)
index 0000000..493168c
--- /dev/null
@@ -0,0 +1,33 @@
+package org.opendaylight.controller.flowprogrammer.northbound;
+
+import java.util.ArrayList;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.forwardingrulesmanager.FlowConfig;
+
+public class FlowProgrammerNorthboundTest {
+
+    @Test
+    public void testFlowConfigs() {
+        FlowConfigs fc = new FlowConfigs(null);
+        Assert.assertNull(fc.getFlowConfig());
+
+        FlowConfig conf = new FlowConfig();
+        FlowConfig conf2 = new FlowConfig();
+        ArrayList<FlowConfig> list = new ArrayList<FlowConfig>();
+
+        list.add(conf);
+        list.add(conf2);
+        FlowConfigs fc2 = new FlowConfigs(list);
+        Assert.assertTrue(fc2.getFlowConfig().equals(list));
+
+        fc.setFlowConfig(list);
+        Assert.assertTrue(fc.getFlowConfig().equals(fc2.getFlowConfig()));
+
+        fc.setFlowConfig(null);
+        Assert.assertNull(fc.getFlowConfig());
+
+    }
+
+}
diff --git a/opendaylight/northbound/hosttracker/src/test/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthboundTest.java b/opendaylight/northbound/hosttracker/src/test/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthboundTest.java
new file mode 100644 (file)
index 0000000..cd5e5a9
--- /dev/null
@@ -0,0 +1,36 @@
+package org.opendaylight.controller.hosttracker.northbound;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
+import org.opendaylight.controller.sal.core.ConstructionException;
+
+public class HostTrackerNorthboundTest {
+
+    @Test
+    public void testHosts() throws UnknownHostException, ConstructionException {
+        Hosts h1 = new Hosts();
+        Assert.assertNull(h1.getHostNodeConnector());
+
+        Hosts h2 = new Hosts(null);
+        Assert.assertNull(h2.getHostNodeConnector());
+
+        Set<HostNodeConnector> conn = new HashSet<HostNodeConnector>();
+        InetAddress addr = InetAddress.getByName("10.1.1.1");
+        HostNodeConnector c1 = new HostNodeConnector(addr);
+        conn.add(c1);
+        h1.setHostNodeConnector(conn);
+        Assert.assertTrue(h1.getHostNodeConnector().equals(conn));
+
+        Hosts h3 = new Hosts(conn);
+        Assert.assertTrue(h3.getHostNodeConnector().equals(conn));
+        h3.setHostNodeConnector(null);
+        Assert.assertNull(h3.getHostNodeConnector());
+
+    }
+}
diff --git a/opendaylight/northbound/staticrouting/src/test/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthboundTest.java b/opendaylight/northbound/staticrouting/src/test/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthboundTest.java
new file mode 100644 (file)
index 0000000..2023d52
--- /dev/null
@@ -0,0 +1,43 @@
+package org.opendaylight.controller.forwarding.staticrouting.northbound;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import junit.framework.TestCase;
+
+public class StaticRoutingNorthboundTest extends TestCase {
+
+    @Test
+    public void testStaticRoute() {
+        StaticRoute sr = new StaticRoute();
+        Assert.assertTrue(sr.getName() == null);
+        Assert.assertTrue(sr.getPrefix() == null);
+        Assert.assertTrue(sr.getNextHop() == null);
+
+        sr = new StaticRoute("Static Route 1", "192.168.100.0/24", "170.0.0.1");
+        Assert.assertTrue(sr.getName().equals("Static Route 1"));
+        Assert.assertTrue(sr.getPrefix().equals("192.168.100.0/24"));
+        Assert.assertTrue(sr.getNextHop().equals("170.0.0.1"));
+
+        sr.setName("Static Route 2");
+        Assert.assertTrue(sr.getName().equals("Static Route 2"));
+        sr.setPrefix("192.168.100.0/26");
+        Assert.assertTrue(sr.getPrefix().equals("192.168.100.0/26"));
+        sr.setNextHop("170.0.2.1");
+        Assert.assertTrue(sr.getNextHop().equals("170.0.2.1"));
+    }
+
+    @Test
+    public void testStaticRoutes() {
+        StaticRoutes srs = new StaticRoutes(null);
+        Assert.assertTrue(srs.getFlowConfig() == null);
+
+        List<StaticRoute> srl = new ArrayList<StaticRoute>();
+        srs.setFlowConfig(srl);
+        Assert.assertTrue(srs.getFlowConfig().equals(srl));
+    }
+
+}
diff --git a/opendaylight/northbound/subnets/src/test/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthboundTest.java b/opendaylight/northbound/subnets/src/test/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthboundTest.java
new file mode 100644 (file)
index 0000000..66b71e7
--- /dev/null
@@ -0,0 +1,26 @@
+package org.opendaylight.controller.subnets.northbound;
+
+import java.util.ArrayList;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.switchmanager.SubnetConfig;
+
+public class SubnetsNorthboundTest {
+
+    @Test
+    public void testSubnetConfigs() {
+        SubnetConfigs sc1 = new SubnetConfigs(null);
+        Assert.assertNull(sc1.getSubnetConfig());
+
+        ArrayList<SubnetConfig> list = new ArrayList<SubnetConfig>();
+        SubnetConfig s1 = new SubnetConfig();
+        list.add(s1);
+        sc1.setSubnetConfig(list);
+        Assert.assertTrue(sc1.getSubnetConfig().equals(list));
+
+        sc1.setSubnetConfig(null);
+        Assert.assertNull(sc1.getSubnetConfig());
+    }
+
+}