From bb661d5b5f23d9f9288b57e24d2bab5545c60f54 Mon Sep 17 00:00:00 2001 From: Alissa Bonas Date: Wed, 25 Dec 2013 15:06:36 +0200 Subject: [PATCH] unitests: Remove extending TestCase from unitest classes. Extending TestCase which is a Junit3 format, and using Junit4 annotations at the same time in same class causes confusion, and can also lead to runtime problems. An example for a problem - putting @Ignore on a test case which starts with word "test" and is located in a class that extends TestCase will actually NOT ignore the test because it will be interpreted as Junit3 and not as Junit4. Removing extending TestCase will make the unitests to be interpreted as Junit4 style and leave no room for confusion. Change-Id: I2365f0921d64667a5489c42eeb53adadc45efdaa Signed-off-by: Alissa Bonas --- .../controller/arphandler/internal/ArphandlerTest.java | 4 +--- .../clustering/test/internal/TestClusteringTest.java | 4 +--- .../hosttracker/hostAware/HostNodeConnectorTest.java | 9 ++------- .../controller/hosttracker/internal/HostTrackerTest.java | 4 +--- .../hosttracker/hostAware/HostNodeConnectorTest.java | 9 ++------- .../northbound/commons/CommonsNorthboundTest.java | 4 +--- .../exception/CommonsNorthboundExceptionTest.java | 4 +--- .../northbound/ControllerManagerNorthboundTest.java | 4 +--- .../northbound/StaticRoutingNorthboundTest.java | 4 +--- .../statistics/northbound/StatisticsNorthboundTest.java | 4 +--- .../northbound/SwitchManagerNorthboundTest.java | 6 ++---- .../samples/loadbalancer/internal/LoadBalancerTest.java | 6 ++---- 12 files changed, 16 insertions(+), 46 deletions(-) diff --git a/opendaylight/arphandler/src/test/java/org/opendaylight/controller/arphandler/internal/ArphandlerTest.java b/opendaylight/arphandler/src/test/java/org/opendaylight/controller/arphandler/internal/ArphandlerTest.java index 19c8b4d35b..892a0bc370 100644 --- a/opendaylight/arphandler/src/test/java/org/opendaylight/controller/arphandler/internal/ArphandlerTest.java +++ b/opendaylight/arphandler/src/test/java/org/opendaylight/controller/arphandler/internal/ArphandlerTest.java @@ -10,12 +10,10 @@ package org.opendaylight.controller.arphandler.internal; -import junit.framework.TestCase; - import org.junit.Assert; import org.junit.Test; -public class ArphandlerTest extends TestCase { +public class ArphandlerTest { @Test public void testArphandlerCreation() { diff --git a/opendaylight/clustering/test/src/test/java/org/opendaylight/controller/clustering/test/internal/TestClusteringTest.java b/opendaylight/clustering/test/src/test/java/org/opendaylight/controller/clustering/test/internal/TestClusteringTest.java index 1142909f85..d143a5171a 100644 --- a/opendaylight/clustering/test/src/test/java/org/opendaylight/controller/clustering/test/internal/TestClusteringTest.java +++ b/opendaylight/clustering/test/src/test/java/org/opendaylight/controller/clustering/test/internal/TestClusteringTest.java @@ -13,9 +13,7 @@ package org.opendaylight.controller.clustering.test.internal; import org.junit.Assert; import org.junit.Test; -import junit.framework.TestCase; - -public class TestClusteringTest extends TestCase { +public class TestClusteringTest { @Test public void testComplexClass() { diff --git a/opendaylight/hosttracker/api/src/test/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnectorTest.java b/opendaylight/hosttracker/api/src/test/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnectorTest.java index bdccc99c9c..96cf308983 100644 --- a/opendaylight/hosttracker/api/src/test/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnectorTest.java +++ b/opendaylight/hosttracker/api/src/test/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnectorTest.java @@ -13,19 +13,14 @@ import java.net.UnknownHostException; import org.junit.Assert; import org.junit.Test; - import org.opendaylight.controller.sal.core.ConstructionException; import org.opendaylight.controller.sal.core.Node; - -import junit.framework.TestCase; - +import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.packet.address.EthernetAddress; - import org.opendaylight.controller.sal.utils.NodeConnectorCreator; -import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.utils.NodeCreator; -public class HostNodeConnectorTest extends TestCase { +public class HostNodeConnectorTest { @Test public void testHostNodeConnector() throws UnknownHostException { diff --git a/opendaylight/hosttracker/implementation/src/test/java/org/opendaylight/controller/hosttracker/internal/HostTrackerTest.java b/opendaylight/hosttracker/implementation/src/test/java/org/opendaylight/controller/hosttracker/internal/HostTrackerTest.java index e222fcd7e4..984d5d3000 100644 --- a/opendaylight/hosttracker/implementation/src/test/java/org/opendaylight/controller/hosttracker/internal/HostTrackerTest.java +++ b/opendaylight/hosttracker/implementation/src/test/java/org/opendaylight/controller/hosttracker/internal/HostTrackerTest.java @@ -11,14 +11,12 @@ package org.opendaylight.controller.hosttracker.internal; import java.net.InetAddress; import java.net.UnknownHostException; -import junit.framework.TestCase; - import org.junit.Assert; import org.junit.Test; import org.opendaylight.controller.hosttracker.IHostId; import org.opendaylight.controller.hosttracker.IPHostId; -public class HostTrackerTest extends TestCase { +public class HostTrackerTest { @Test public void testHostTrackerCallable() throws UnknownHostException { diff --git a/opendaylight/hosttracker_new/api/src/test/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnectorTest.java b/opendaylight/hosttracker_new/api/src/test/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnectorTest.java index 430d133ad7..4248c6dfd0 100644 --- a/opendaylight/hosttracker_new/api/src/test/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnectorTest.java +++ b/opendaylight/hosttracker_new/api/src/test/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnectorTest.java @@ -13,19 +13,14 @@ import java.net.UnknownHostException; import org.junit.Assert; import org.junit.Test; - import org.opendaylight.controller.sal.core.ConstructionException; import org.opendaylight.controller.sal.core.Node; - -import junit.framework.TestCase; - +import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.packet.address.EthernetAddress; - import org.opendaylight.controller.sal.utils.NodeConnectorCreator; -import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.utils.NodeCreator; -public class HostNodeConnectorTest extends TestCase { +public class HostNodeConnectorTest { @Test public void testHostNodeConnector() throws UnknownHostException { diff --git a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/CommonsNorthboundTest.java b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/CommonsNorthboundTest.java index 9dba530c34..1e910d18fb 100644 --- a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/CommonsNorthboundTest.java +++ b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/CommonsNorthboundTest.java @@ -3,9 +3,7 @@ package org.opendaylight.controller.northbound.commons; import org.junit.Assert; import org.junit.Test; -import junit.framework.TestCase; - -public class CommonsNorthboundTest extends TestCase { +public class CommonsNorthboundTest { @Test public void testRestMessages() { diff --git a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/exception/CommonsNorthboundExceptionTest.java b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/exception/CommonsNorthboundExceptionTest.java index 0a282b9b28..c329644110 100644 --- a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/exception/CommonsNorthboundExceptionTest.java +++ b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/exception/CommonsNorthboundExceptionTest.java @@ -5,9 +5,7 @@ import javax.ws.rs.core.Response; import org.junit.Assert; import org.junit.Test; -import junit.framework.TestCase; - -public class CommonsNorthboundExceptionTest extends TestCase { +public class CommonsNorthboundExceptionTest { @Test public void testMethodNotAllowed() { diff --git a/opendaylight/northbound/controllermanager/src/test/java/org/opendaylight/controller/controllermanager/northbound/ControllerManagerNorthboundTest.java b/opendaylight/northbound/controllermanager/src/test/java/org/opendaylight/controller/controllermanager/northbound/ControllerManagerNorthboundTest.java index a57e615618..7f8b0b43bf 100644 --- a/opendaylight/northbound/controllermanager/src/test/java/org/opendaylight/controller/controllermanager/northbound/ControllerManagerNorthboundTest.java +++ b/opendaylight/northbound/controllermanager/src/test/java/org/opendaylight/controller/controllermanager/northbound/ControllerManagerNorthboundTest.java @@ -3,13 +3,11 @@ package org.opendaylight.controller.controllermanager.northbound; import java.util.HashSet; import java.util.Set; -import junit.framework.TestCase; - import org.junit.Assert; import org.junit.Test; import org.opendaylight.controller.sal.core.Property; -public class ControllerManagerNorthboundTest extends TestCase { +public class ControllerManagerNorthboundTest { @Test public void testControllerProperties() { 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 index 2023d52561..ac15a91f43 100644 --- 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 @@ -6,9 +6,7 @@ import java.util.List; import org.junit.Assert; import org.junit.Test; -import junit.framework.TestCase; - -public class StaticRoutingNorthboundTest extends TestCase { +public class StaticRoutingNorthboundTest { @Test public void testStaticRoute() { 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 index 0764c0b007..d09ff04574 100644 --- 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 @@ -12,8 +12,6 @@ package org.opendaylight.controller.statistics.northbound; import java.util.ArrayList; import java.util.List; -import junit.framework.TestCase; - import org.junit.Assert; import org.junit.Test; import org.opendaylight.controller.sal.core.Node; @@ -22,7 +20,7 @@ import org.opendaylight.controller.sal.reader.NodeConnectorStatistics; import org.opendaylight.controller.sal.reader.NodeTableStatistics; import org.opendaylight.controller.sal.utils.NodeCreator; -public class StatisticsNorthboundTest extends TestCase { +public class StatisticsNorthboundTest { @Test public void testFlowStatistics() { 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 index 5386d4142f..f9a88d2e28 100644 --- 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 @@ -1,22 +1,20 @@ package org.opendaylight.controller.switchmanager.northbound; +import java.util.ArrayList; 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 { +public class SwitchManagerNorthboundTest { @Test public void testNodes() { diff --git a/opendaylight/samples/loadbalancer/src/test/java/org/opendaylight/controller/samples/loadbalancer/internal/LoadBalancerTest.java b/opendaylight/samples/loadbalancer/src/test/java/org/opendaylight/controller/samples/loadbalancer/internal/LoadBalancerTest.java index 4fd3f4a32d..cfffb7e73a 100644 --- a/opendaylight/samples/loadbalancer/src/test/java/org/opendaylight/controller/samples/loadbalancer/internal/LoadBalancerTest.java +++ b/opendaylight/samples/loadbalancer/src/test/java/org/opendaylight/controller/samples/loadbalancer/internal/LoadBalancerTest.java @@ -17,14 +17,12 @@ import org.opendaylight.controller.samples.loadbalancer.entities.PoolMember; import org.opendaylight.controller.samples.loadbalancer.entities.VIP; import org.opendaylight.controller.samples.loadbalancer.policies.RoundRobinLBPolicy; -import junit.framework.TestCase; - /** * * Class to unit test the load balancing policies. * */ -public class LoadBalancerTest extends TestCase { +public class LoadBalancerTest { @Test public void testRoundRobinPolicy() { ConfigManager cm = null; @@ -65,4 +63,4 @@ public class LoadBalancerTest extends TestCase { c1 = new Client("10.0.0.1","TCP",(short)5003); Assert.assertTrue(rrp.getPoolMemberForClient(c1, vip).equals(host4.getIp())); } -} \ No newline at end of file +} -- 2.36.6