unitests: Remove extending TestCase from unitest classes. 19/3919/4
authorAlissa Bonas <abonas@redhat.com>
Wed, 25 Dec 2013 13:06:36 +0000 (15:06 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 22 Jan 2014 13:53:20 +0000 (13:53 +0000)
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 <abonas@redhat.com>
12 files changed:
opendaylight/arphandler/src/test/java/org/opendaylight/controller/arphandler/internal/ArphandlerTest.java
opendaylight/clustering/test/src/test/java/org/opendaylight/controller/clustering/test/internal/TestClusteringTest.java
opendaylight/hosttracker/api/src/test/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnectorTest.java
opendaylight/hosttracker/implementation/src/test/java/org/opendaylight/controller/hosttracker/internal/HostTrackerTest.java
opendaylight/hosttracker_new/api/src/test/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnectorTest.java
opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/CommonsNorthboundTest.java
opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/exception/CommonsNorthboundExceptionTest.java
opendaylight/northbound/controllermanager/src/test/java/org/opendaylight/controller/controllermanager/northbound/ControllerManagerNorthboundTest.java
opendaylight/northbound/staticrouting/src/test/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthboundTest.java
opendaylight/northbound/statistics/src/test/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthboundTest.java
opendaylight/northbound/switchmanager/src/test/java/org/opendaylight/controller/switchmanager/northbound/SwitchManagerNorthboundTest.java
opendaylight/samples/loadbalancer/src/test/java/org/opendaylight/controller/samples/loadbalancer/internal/LoadBalancerTest.java

index 19c8b4d..892a0bc 100644 (file)
 package org.opendaylight.controller.arphandler.internal;\r
 \r
 \r
-import junit.framework.TestCase;\r
-\r
 import org.junit.Assert;\r
 import org.junit.Test;\r
 \r
-public class ArphandlerTest extends TestCase {\r
+public class ArphandlerTest  {\r
 \r
         @Test\r
         public void testArphandlerCreation() {\r
index 1142909..d143a51 100644 (file)
@@ -13,9 +13,7 @@ package org.opendaylight.controller.clustering.test.internal;
 import org.junit.Assert;\r
 import org.junit.Test;\r
 \r
-import junit.framework.TestCase;\r
-\r
-public class TestClusteringTest extends TestCase {\r
+public class TestClusteringTest {\r
 \r
         @Test\r
         public void testComplexClass() {\r
index bdccc99..96cf308 100644 (file)
@@ -13,19 +13,14 @@ import java.net.UnknownHostException;
 \r
 import org.junit.Assert;\r
 import org.junit.Test;\r
-\r
 import org.opendaylight.controller.sal.core.ConstructionException;\r
 import org.opendaylight.controller.sal.core.Node;\r
-\r
-import junit.framework.TestCase;\r
-\r
+import org.opendaylight.controller.sal.core.NodeConnector;\r
 import org.opendaylight.controller.sal.packet.address.EthernetAddress;\r
-\r
 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;\r
-import org.opendaylight.controller.sal.core.NodeConnector;\r
 import org.opendaylight.controller.sal.utils.NodeCreator;\r
 \r
-public class HostNodeConnectorTest extends TestCase {\r
+public class HostNodeConnectorTest {\r
 \r
     @Test\r
     public void testHostNodeConnector() throws UnknownHostException {\r
index e222fcd..984d5d3 100644 (file)
@@ -11,14 +11,12 @@ package org.opendaylight.controller.hosttracker.internal;
 import java.net.InetAddress;\r
 import java.net.UnknownHostException;\r
 \r
-import junit.framework.TestCase;\r
-\r
 import org.junit.Assert;\r
 import org.junit.Test;\r
 import org.opendaylight.controller.hosttracker.IHostId;\r
 import org.opendaylight.controller.hosttracker.IPHostId;\r
 \r
-public class HostTrackerTest extends TestCase {\r
+public class HostTrackerTest {\r
 \r
     @Test\r
     public void testHostTrackerCallable() throws UnknownHostException {\r
index 430d133..4248c6d 100644 (file)
@@ -13,19 +13,14 @@ import java.net.UnknownHostException;
 \r
 import org.junit.Assert;\r
 import org.junit.Test;\r
-\r
 import org.opendaylight.controller.sal.core.ConstructionException;\r
 import org.opendaylight.controller.sal.core.Node;\r
-\r
-import junit.framework.TestCase;\r
-\r
+import org.opendaylight.controller.sal.core.NodeConnector;\r
 import org.opendaylight.controller.sal.packet.address.EthernetAddress;\r
-\r
 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;\r
-import org.opendaylight.controller.sal.core.NodeConnector;\r
 import org.opendaylight.controller.sal.utils.NodeCreator;\r
 \r
-public class HostNodeConnectorTest extends TestCase {\r
+public class HostNodeConnectorTest {\r
 \r
     @Test\r
     public void testHostNodeConnector() throws UnknownHostException {\r
index 9dba530..1e910d1 100644 (file)
@@ -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() {
index a57e615..7f8b0b4 100644 (file)
@@ -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() {
index 0764c0b..d09ff04 100644 (file)
@@ -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() {
index 5386d41..f9a88d2 100644 (file)
@@ -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() {
index 4fd3f4a..cfffb7e 100644 (file)
@@ -17,14 +17,12 @@ import org.opendaylight.controller.samples.loadbalancer.entities.PoolMember;
 import org.opendaylight.controller.samples.loadbalancer.entities.VIP;\r
 import org.opendaylight.controller.samples.loadbalancer.policies.RoundRobinLBPolicy;\r
 \r
-import junit.framework.TestCase;\r
-\r
 /**\r
  *\r
  * Class to unit test the load balancing policies.\r
  *\r
  */\r
-public class LoadBalancerTest extends TestCase {\r
+public class LoadBalancerTest {\r
     @Test\r
     public void testRoundRobinPolicy() {\r
         ConfigManager cm = null;\r
@@ -65,4 +63,4 @@ public class LoadBalancerTest extends TestCase {
         c1 = new Client("10.0.0.1","TCP",(short)5003);\r
         Assert.assertTrue(rrp.getPoolMemberForClient(c1, vip).equals(host4.getIp()));\r
     }\r
-}
\ No newline at end of file
+}