From ad549735710c24edcd4ceb38239e708e9fa6d128 Mon Sep 17 00:00:00 2001 From: Kalvin Hom Date: Wed, 27 Mar 2013 23:13:58 -0700 Subject: [PATCH 1/1] JUnit for StatisticsNorthbound Change-Id: I2b876ac1b2a22e6599edcb25e28b665f3f083500 Signed-off-by: Kalvin Hom --- .../northbound/StatisticsNorthboundTest.java | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 opendaylight/northbound/statistics/src/test/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthboundTest.java diff --git a/opendaylight/northbound/statistics/src/test/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthboundTest.java b/opendaylight/northbound/statistics/src/test/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthboundTest.java new file mode 100644 index 0000000000..3790ae8ea9 --- /dev/null +++ b/opendaylight/northbound/statistics/src/test/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthboundTest.java @@ -0,0 +1,67 @@ +package org.opendaylight.controller.statistics.northbound; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.controller.sal.core.Node; +import org.opendaylight.controller.sal.reader.FlowOnNode; +import org.opendaylight.controller.sal.reader.NodeConnectorStatistics; +import org.opendaylight.controller.sal.utils.NodeCreator; + +import junit.framework.TestCase; + +public class StatisticsNorthboundTest extends TestCase { + + @Test + public void testFlowStatistics() { + List fon = new ArrayList(); + Node node = NodeCreator.createOFNode(1L); + FlowStatistics fs = new FlowStatistics(node, fon); + Assert.assertTrue(fs.getNode().equals(node)); + Assert.assertTrue(fs.getFlowStats().equals(fon)); + + Node node2 = NodeCreator.createOFNode(2L); + fs.setNode(node2); + Assert.assertTrue(fs.getNode().equals(node2)); + fs.setNode(node2); + Assert.assertTrue(fs.getNode().equals(node2)); + fs.setFlowStats(null); + Assert.assertTrue(fs.getFlowStats() == null); + } + + @Test + public void testAllFlowStatistics() { + List fs = new ArrayList(); + AllFlowStatistics afs = new AllFlowStatistics(fs); + Assert.assertTrue(afs.getFlowStatistics().equals(fs)); + afs.setFlowStatistics(null); + Assert.assertTrue(afs.getFlowStatistics() == null); + } + + @Test + public void testPortStatistics() { + List ncs = new ArrayList(); + Node node = NodeCreator.createOFNode(1L); + PortStatistics ps = new PortStatistics(node, ncs); + + Assert.assertTrue(ps.getNode().equals(node)); + Assert.assertTrue(ps.getPortStats().equals(ncs)); + Node node2 = NodeCreator.createOFNode(2L); + ps.setNode(node2); + Assert.assertTrue(ps.getNode().equals(node2)); + ps.setFlowStats(null); + Assert.assertTrue(ps.getPortStats() == null); + } + + @Test + public void testAllPortStatistics() { + List ps = new ArrayList(); + AllPortStatistics aps = new AllPortStatistics(ps); + Assert.assertTrue(aps.getPortStatistics().equals(ps)); + aps.setPortStatistics(null); + Assert.assertTrue(aps.getPortStatistics() == null); + } + +} -- 2.36.6