From: Alessandro Boch Date: Thu, 28 Mar 2013 23:01:30 +0000 (+0000) Subject: Merge "JUnit Test for Topology Northbound" X-Git-Tag: releasepom-0.1.0~616 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=244e6a69236780568bc9b793816530a0b76e4cae;hp=e8dd07c183aa6735bafc9dfcd451b2db7fd76b98 Merge "JUnit Test for Topology Northbound" --- 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 index 0000000000..493168cd51 --- /dev/null +++ b/opendaylight/northbound/flowprogrammer/src/test/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthboundTest.java @@ -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 list = new ArrayList(); + + 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 index 0000000000..cd5e5a91d6 --- /dev/null +++ b/opendaylight/northbound/hosttracker/src/test/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthboundTest.java @@ -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 conn = new HashSet(); + 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 index 0000000000..2023d52561 --- /dev/null +++ b/opendaylight/northbound/staticrouting/src/test/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthboundTest.java @@ -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 srl = new ArrayList(); + 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 index 0000000000..66b71e70a2 --- /dev/null +++ b/opendaylight/northbound/subnets/src/test/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthboundTest.java @@ -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 list = new ArrayList(); + SubnetConfig s1 = new SubnetConfig(); + list.add(s1); + sc1.setSubnetConfig(list); + Assert.assertTrue(sc1.getSubnetConfig().equals(list)); + + sc1.setSubnetConfig(null); + Assert.assertNull(sc1.getSubnetConfig()); + } + +}