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 19c8b4d35bd39f8a1c4ad516911ad149cfc5d9a0..892a0bc370a53e9dd930f089d24040106fb44eb5 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 1142909f8562844075b3cbbf475b2a65d016738e..d143a5171a9ffbc4d907cf2aa32dc80fd83ccc50 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 bdccc99c9c52d29801bf43c7a7ebff602a207c65..96cf308983c1444ea8e68b17fe94685af5c7baa7 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 e222fcd7e42cdb23b5a0850f6b55fd6834deba8a..984d5d3000303865dd44465a32600fc03c9c7feb 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 430d133ad7724024814dc232856f7c365dbd42a1..4248c6dfd0a93de3cb5ceb313e8927d8bc0de8ef 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 9dba530c341237763c96cab63ac0c50e54e88364..1e910d18fb98ac50e719a09703ad6e4343d57798 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 0a282b9b28b8c3c68ca31e3419a39b0f607105c2..c3296441109b00e5335dde7af1984fbfc4ff3001 100644 (file)
@@ -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() {
index a57e615618a8b0854e9ed07721c6df1d2857b247..7f8b0b43bfc0ad227f6ac98b7929bdb35ff3d75a 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 2023d5256109f734668de07265bac6b01906489f..ac15a91f43a6caa0c2b4480057a9fe4150f2e034 100644 (file)
@@ -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() {
index 0764c0b0077d25f9d33e2d173079a16e2bae9078..d09ff04574095a9d771ff08c655f993ded13a0b5 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 5386d4142fd55f0d3c7c79a5254aaa4faa70710b..f9a88d2e28526a35cbc0c149bd8008887c4ff622 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 4fd3f4a32de5964fe7f2b0df20c4125497e71eb6..cfffb7e73aa8c83e0bca5ec2af19b11d6ebb5c97 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
+}