tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkoli...@apache.org
Subject svn commit: r1150974 - in /tomcat/trunk/test/org/apache/catalina/tribes: group/ group/interceptors/ io/ membership/ test/
Date Tue, 26 Jul 2011 02:39:38 GMT
Author: kkolinko
Date: Tue Jul 26 02:39:35 2011
New Revision: 1150974

URL: http://svn.apache.org/viewvc?rev=1150974&view=rev
Log:
Converted tribes tests to JUnit 4.

Modified:
    tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelMemberArrival.java
    tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelOptionFlag.java
    tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java
    tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java
    tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestDomainFilterInterceptor.java
    tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestGzipInterceptor.java
    tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java
    tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java
    tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java
    tomcat/trunk/test/org/apache/catalina/tribes/io/TestXByteBuffer.java
    tomcat/trunk/test/org/apache/catalina/tribes/membership/TestMemberImplSerialization.java
    tomcat/trunk/test/org/apache/catalina/tribes/test/TribesTestSuite.java

Modified: tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelMemberArrival.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelMemberArrival.java?rev=1150974&r1=1150973&r2=1150974&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelMemberArrival.java
(original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelMemberArrival.java
Tue Jul 26 02:39:35 2011
@@ -18,22 +18,24 @@ package org.apache.catalina.tribes.group
 
 import java.util.ArrayList;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.ManagedChannel;
 import org.apache.catalina.tribes.Member;
 import org.apache.catalina.tribes.MembershipListener;
 
-public class TestGroupChannelMemberArrival
-    extends TestCase {
+public class TestGroupChannelMemberArrival {
     private static int count = 10;
     private ManagedChannel[] channels = new ManagedChannel[count];
     private TestMbrListener[] listeners = new TestMbrListener[count];
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Before
+    public void setUp() throws Exception {
         for (int i = 0; i < channels.length; i++) {
             channels[i] = new GroupChannel();
             channels[i].getMembershipService().setPayload( ("Channel-" + (i + 1)).getBytes("ASCII"));
@@ -49,6 +51,7 @@ public class TestGroupChannelMemberArriv
         }
     }
 
+    @Test
     public void testMemberArrival() throws Exception {
         //purpose of this test is to make sure that we have received all the members
         //that we can expect before the start method returns
@@ -74,8 +77,8 @@ public class TestGroupChannelMemberArriv
         for (int i=listeners.length-1; i>=0; i-- ) assertEquals("Checking member arrival
length",channels.length-1,listeners[i].members.size());
     }
 
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
 
         for (int i = 0; i < channels.length; i++) {
             try {
@@ -84,7 +87,6 @@ public class TestGroupChannelMemberArriv
                 // Ignore
             }
         }
-        super.tearDown();
     }
 
     public static class TestMbrListener

Modified: tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelOptionFlag.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelOptionFlag.java?rev=1150974&r1=1150973&r2=1150974&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelOptionFlag.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelOptionFlag.java Tue
Jul 26 02:39:35 2011
@@ -16,7 +16,12 @@
  */
 package org.apache.catalina.tribes.group;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.ChannelException;
@@ -32,22 +37,21 @@ import org.apache.catalina.tribes.Channe
  * @author not attributable
  * @version 1.0
  */
-public class TestGroupChannelOptionFlag extends TestCase {
-    GroupChannel channel = null;
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+public class TestGroupChannelOptionFlag {
+    private GroupChannel channel = null;
+
+    @Before
+    public void setUp() throws Exception {
         channel = new GroupChannel();
     }
 
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
+    @After
+    public void tearDown() throws Exception {
         if ( channel != null ) try {channel.stop(Channel.DEFAULT);}catch ( Exception ignore)
{ /* Ignore */ }
         channel = null;
     }
-    
-    
+
+    @Test
     public void testOptionConflict() throws Exception {
         boolean error = false;
         channel.setOptionCheck(true);
@@ -62,9 +66,10 @@ public class TestGroupChannelOptionFlag 
         }catch ( ChannelException x ) {
             if ( x.getMessage().indexOf("option flag conflict") >= 0 ) error = true;
         }
-        assertEquals(true,error);
+        assertTrue(error);
     }
 
+    @Test
     public void testOptionNoConflict() throws Exception {
         boolean error = false;
         channel.setOptionCheck(true);
@@ -82,7 +87,7 @@ public class TestGroupChannelOptionFlag 
         }catch ( ChannelException x ) {
             if ( x.getMessage().indexOf("option flag conflict") >= 0 ) error = true;
         }
-        assertEquals(false,error);
+        assertFalse(error);
     }
     
     public static class TestInterceptor extends ChannelInterceptorBase {

Modified: tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java?rev=1150974&r1=1150973&r2=1150974&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java
(original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java
Tue Jul 26 02:39:35 2011
@@ -21,7 +21,9 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Random;
 
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.ChannelListener;
@@ -29,14 +31,13 @@ import org.apache.catalina.tribes.Manage
 import org.apache.catalina.tribes.Member;
 import org.apache.catalina.tribes.transport.ReplicationTransmitter;
 
-public class TestGroupChannelSenderConnections extends TestCase {
+public class TestGroupChannelSenderConnections {
     private static int count = 2;
     private ManagedChannel[] channels = new ManagedChannel[count];
     private TestMsgListener[] listeners = new TestMsgListener[count];
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Before
+    public void setUp() throws Exception {
         for (int i = 0; i < channels.length; i++) {
             channels[i] = new GroupChannel();
             channels[i].getMembershipService().setPayload( ("Channel-" + (i + 1)).getBytes("ASCII"));
@@ -65,10 +66,12 @@ public class TestGroupChannelSenderConne
 
     }
 
+    @Test
     public void testConnectionLinger() throws Exception {
         sendMessages(0,15000);
     }
-    
+
+    @Test
     public void testKeepAliveCount() throws Exception {
         System.out.println("Setting keep alive count to 0");
         for (int i = 0; i < channels.length; i++) {
@@ -78,6 +81,7 @@ public class TestGroupChannelSenderConne
         sendMessages(1000,15000);
     }
 
+    @Test
     public void testKeepAliveTime() throws Exception {
         System.out.println("Setting keep alive count to 1 second");
         for (int i = 0; i < channels.length; i++) {
@@ -87,8 +91,8 @@ public class TestGroupChannelSenderConne
         sendMessages(2000,15000);
     }
 
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         for (int i = 0; i < channels.length; i++) {
             channels[i].stop(Channel.DEFAULT);
         }

Modified: tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java?rev=1150974&r1=1150973&r2=1150974&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java Tue
Jul 26 02:39:35 2011
@@ -16,7 +16,11 @@
  */
 package org.apache.catalina.tribes.group;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.transport.ReceiverBase;
@@ -25,21 +29,21 @@ import org.apache.catalina.tribes.transp
  * @author Filip Hanik
  * @version 1.0
  */
-public class TestGroupChannelStartStop extends TestCase {
-    GroupChannel channel = null;
-    int udpPort = 45543;
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+public class TestGroupChannelStartStop {
+    private GroupChannel channel = null;
+    private int udpPort = 45543;
+
+    @Before
+    public void setUp() throws Exception {
         channel = new GroupChannel();
     }
 
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
+    @After
+    public void tearDown() throws Exception {
         try {channel.stop(Channel.DEFAULT);}catch (Exception ignore){ /* Ignore */ }
     }
 
+    @Test
     public void testDoubleFullStart() throws Exception {
         int count = 0;
         try {
@@ -54,12 +58,13 @@ public class TestGroupChannelStartStop e
         channel.stop(Channel.DEFAULT);
     }
 
+    @Test
     public void testScrap() throws Exception {
         System.out.println(channel.getChannelReceiver().getClass());
         ((ReceiverBase)channel.getChannelReceiver()).setMaxThreads(1);
     }
 
-
+    @Test
     public void testDoublePartialStart() throws Exception {
         //try to double start the RX
         int count = 0;
@@ -113,6 +118,7 @@ public class TestGroupChannelStartStop e
         channel.stop(Channel.DEFAULT);
     }
 
+    @Test
     public void testFalseOption() throws Exception {
         int flag = 0xFFF0;//should get ignored by the underlying components
         int count = 0;
@@ -128,6 +134,7 @@ public class TestGroupChannelStartStop e
         channel.stop(Channel.DEFAULT);
     }
 
+    @Test
     public void testUdpReceiverStart() throws Exception {
         ReceiverBase rb = (ReceiverBase)channel.getChannelReceiver();
         rb.setUdpPort(udpPort);

Modified: tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestDomainFilterInterceptor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestDomainFilterInterceptor.java?rev=1150974&r1=1150973&r2=1150974&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestDomainFilterInterceptor.java
(original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestDomainFilterInterceptor.java
Tue Jul 26 02:39:35 2011
@@ -18,7 +18,11 @@ package org.apache.catalina.tribes.group
 
 import java.util.ArrayList;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.ManagedChannel;
@@ -27,15 +31,13 @@ import org.apache.catalina.tribes.Member
 import org.apache.catalina.tribes.group.GroupChannel;
 import org.apache.catalina.tribes.util.UUIDGenerator;
 
-public class TestDomainFilterInterceptor
-    extends TestCase {
+public class TestDomainFilterInterceptor {
     private static int count = 10;
     private ManagedChannel[] channels = new ManagedChannel[count];
     private TestMbrListener[] listeners = new TestMbrListener[count];
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Before
+    public void setUp() throws Exception {
         for (int i = 0; i < channels.length; i++) {
             channels[i] = new GroupChannel();
             channels[i].getMembershipService().setPayload( ("Channel-" + (i + 1)).getBytes("ASCII"));
@@ -53,6 +55,7 @@ public class TestDomainFilterInterceptor
         }
     }
 
+    @Test
     public void testMemberArrival() throws Exception {
         //purpose of this test is to make sure that we have received all the members
         //that we can expect before the start method returns
@@ -77,8 +80,8 @@ public class TestDomainFilterInterceptor
         for (int i=listeners.length-1; i>=0; i-- ) assertEquals("Checking member arrival
length",0,listeners[i].members.size());
     }
 
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
 
         for (int i = 0; i < channels.length; i++) {
             try {
@@ -87,7 +90,6 @@ public class TestDomainFilterInterceptor
                 // Ignore
             }
         }
-        super.tearDown();
     }
 
     public static class TestMbrListener

Modified: tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestGzipInterceptor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestGzipInterceptor.java?rev=1150974&r1=1150973&r2=1150974&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestGzipInterceptor.java
(original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestGzipInterceptor.java
Tue Jul 26 02:39:35 2011
@@ -18,34 +18,43 @@ package org.apache.catalina.tribes.group
 
 import java.util.Arrays;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertTrue;
 
-public class TestGzipInterceptor extends TestCase {
+import org.junit.Test;
 
+public class TestGzipInterceptor {
+
+    @Test
     public void testSmallerThanBufferSize() throws Exception {
         doCompressDecompress(GzipInterceptor.DEFAULT_BUFFER_SIZE / 2);
     }
 
+    @Test
     public void testJustSmallerThanBufferSize() throws Exception {
         doCompressDecompress(GzipInterceptor.DEFAULT_BUFFER_SIZE -1);
     }
 
+    @Test
     public void testExactBufferSize() throws Exception {
         doCompressDecompress(GzipInterceptor.DEFAULT_BUFFER_SIZE);
     }
 
+    @Test
     public void testJustLargerThanBufferSize() throws Exception {
         doCompressDecompress(GzipInterceptor.DEFAULT_BUFFER_SIZE + 1);
     }
 
+    @Test
     public void testFactor2BufferSize() throws Exception {
         doCompressDecompress(GzipInterceptor.DEFAULT_BUFFER_SIZE * 2);
     }
 
+    @Test
     public void testFactor4BufferSize() throws Exception {
         doCompressDecompress(GzipInterceptor.DEFAULT_BUFFER_SIZE * 4);
     }
 
+    @Test
     public void testMuchLargerThanBufferSize() throws Exception {
         doCompressDecompress(GzipInterceptor.DEFAULT_BUFFER_SIZE * 10 + 1000);
     }

Modified: tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java?rev=1150974&r1=1150973&r2=1150974&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java
(original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java
Tue Jul 26 02:39:35 2011
@@ -16,24 +16,26 @@
  */
 package org.apache.catalina.tribes.group.interceptors;
 
-import junit.framework.TestCase;
-import junit.framework.TestResult;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.Member;
 import org.apache.catalina.tribes.group.GroupChannel;
 
-public class TestNonBlockingCoordinator extends TestCase {
+public class TestNonBlockingCoordinator {
+
+    private GroupChannel[] channels = null;
+    private NonBlockingCoordinator[] coordinators = null;
+    private int channelCount = 10;
+    private Thread[] threads = null;
 
-    GroupChannel[] channels = null;
-    NonBlockingCoordinator[] coordinators = null;
-    int channelCount = 10;
-    Thread[] threads = null;
-    @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         System.out.println("Setup");
-        super.setUp();
         channels = new GroupChannel[channelCount];
         coordinators = new NonBlockingCoordinator[channelCount];
         threads = new Thread[channelCount];
@@ -59,7 +61,8 @@ public class TestNonBlockingCoordinator 
         for ( int i=0; i<channelCount; i++ ) threads[i].join();
         Thread.sleep(1000);
     }
-    
+
+    @Test
     public void testCoord1() throws Exception {
         for (int i=1; i<channelCount; i++ ) 
             assertEquals("Message count expected to be equal.",channels[i-1].getMembers().length,channels[i].getMembers().length);
@@ -70,7 +73,8 @@ public class TestNonBlockingCoordinator 
         System.out.println("Coordinator[1] is:"+member);
         
     }
-    
+
+    @Test
     public void testCoord2() throws Exception {
         Member member = coordinators[1].getCoordinator();
         System.out.println("Coordinator[2a] is:" + member);
@@ -91,19 +95,16 @@ public class TestNonBlockingCoordinator 
         System.out.println("Coordinator[2b] is:" + member);
     }
 
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         System.out.println("tearDown");
-        super.tearDown();
         for ( int i=0; i<channelCount; i++ ) {
             channels[i].stop(Channel.DEFAULT);
         }
     }
-    
+
     public static void main(String[] args) throws Exception {
-        TestSuite suite = new TestSuite();
-        suite.addTestSuite(TestNonBlockingCoordinator.class);
-        suite.run(new TestResult());
+        org.junit.runner.JUnitCore.main(TestNonBlockingCoordinator.class.getName());
     }
 
 

Modified: tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java?rev=1150974&r1=1150973&r2=1150974&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java
(original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java
Tue Jul 26 02:39:35 2011
@@ -21,9 +21,12 @@ import java.util.Queue;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import junit.framework.TestCase;
-import junit.framework.TestResult;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.ChannelException;
@@ -34,7 +37,7 @@ import org.apache.catalina.tribes.group.
 import org.apache.catalina.tribes.group.GroupChannel;
 import org.apache.catalina.tribes.group.InterceptorPayload;
 
-public class TestOrderInterceptor extends TestCase {
+public class TestOrderInterceptor {
 
     GroupChannel[] channels = null;
     OrderInterceptor[] orderitcs = null;
@@ -42,10 +45,10 @@ public class TestOrderInterceptor extend
     TestListener[] test = null;
     int channelCount = 2;
     Thread[] threads = null;
-    @Override
-    protected void setUp() throws Exception {
+
+    @Before
+    public void setUp() throws Exception {
         System.out.println("Setup");
-        super.setUp();
         channels = new GroupChannel[channelCount];
         orderitcs = new OrderInterceptor[channelCount];
         mangleitcs = new MangleOrderInterceptor[channelCount];
@@ -78,7 +81,8 @@ public class TestOrderInterceptor extend
         for ( int i=0; i<channelCount; i++ ) threads[i].join();
         Thread.sleep(1000);
     }
-    
+
+    @Test
     public void testOrder1() throws Exception {
         Member[] dest = channels[0].getMembers();
         final AtomicInteger value = new AtomicInteger(0);
@@ -87,10 +91,11 @@ public class TestOrderInterceptor extend
         }
         Thread.sleep(5000);
         for ( int i=0; i<test.length; i++ ) {
-            assertEquals(false,test[i].fail);
+            assertFalse(test[i].fail);
         }
     }
-    
+
+    @Test
     public void testOrder2() throws Exception {
         final Member[] dest = channels[0].getMembers();
         final AtomicInteger value = new AtomicInteger(0);
@@ -125,24 +130,20 @@ public class TestOrderInterceptor extend
         }
         Thread.sleep(5000);
         for ( int i=0; i<test.length; i++ ) {
-            assertEquals(false,test[i].fail);
+            assertFalse(test[i].fail);
         }
     }
 
-
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         System.out.println("tearDown");
-        super.tearDown();
         for ( int i=0; i<channelCount; i++ ) {
             channels[i].stop(Channel.DEFAULT);
         }
     }
-    
-    public static void main(String[] args) throws Exception {
-        TestSuite suite = new TestSuite();
-        suite.addTestSuite(TestOrderInterceptor.class);
-        suite.run(new TestResult());
+
+    public static void main(String[] args) {
+        org.junit.runner.JUnitCore.main(TestOrderInterceptor.class.getName());
     }
     
     public static class TestListener implements ChannelListener {

Modified: tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java?rev=1150974&r1=1150973&r2=1150974&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java
(original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java
Tue Jul 26 02:39:35 2011
@@ -18,7 +18,12 @@ package org.apache.catalina.tribes.group
 
 import java.util.ArrayList;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 import org.apache.catalina.tribes.ByteMessage;
 import org.apache.catalina.tribes.Channel;
@@ -38,16 +43,16 @@ import org.apache.catalina.tribes.group.
  * @author not attributable
  * @version 1.0
  */
-public class TestTcpFailureDetector extends TestCase {
+public class TestTcpFailureDetector {
     private TcpFailureDetector tcpFailureDetector1 = null;
     private TcpFailureDetector tcpFailureDetector2 = null;
     private ManagedChannel channel1 = null;
     private ManagedChannel channel2 = null;
     private TestMbrListener mbrlist1 = null;
     private TestMbrListener mbrlist2 = null;
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+
+    @Before
+    public void setUp() throws Exception {
         channel1 = new GroupChannel();
         channel2 = new GroupChannel();
         channel1.getMembershipService().setPayload("Channel-1".getBytes("ASCII"));
@@ -66,7 +71,8 @@ public class TestTcpFailureDetector exte
         mbrlist1.members.clear();
         mbrlist2.members.clear();
     }
-    
+
+    @Test
     public void testTcpSendFailureMemberDrop() throws Exception {
         System.out.println("testTcpSendFailureMemberDrop()");
         clear();
@@ -78,7 +84,7 @@ public class TestTcpFailureDetector exte
         ByteMessage msg = new ByteMessage(new byte[1024]);
         try {
             channel1.send(channel1.getMembers(), msg, 0);
-            assertEquals("Message send should have failed.",true,false);
+            fail("Message send should have failed.");
         } catch ( ChannelException x ) {
             // Ignore
         }
@@ -86,7 +92,8 @@ public class TestTcpFailureDetector exte
         channel1.stop(Channel.DEFAULT);
         channel2.stop(Channel.DEFAULT);
     }
-    
+
+    @Test
     public void testTcpFailureMemberAdd() throws Exception {
         System.out.println("testTcpFailureMemberAdd()");
         clear();
@@ -102,6 +109,7 @@ public class TestTcpFailureDetector exte
         channel2.stop(Channel.DEFAULT);
     }
 
+    @Test
     public void testTcpMcastFail() throws Exception {
         System.out.println("testTcpMcastFail()");
         clear();
@@ -116,22 +124,20 @@ public class TestTcpFailureDetector exte
             assertEquals("Expecting member count to be equal",mbrlist1.members.size(),mbrlist2.members.size());
             channel1.send(channel1.getMembers(), msg, 0);
         } catch ( ChannelException x ) {
-            assertEquals("Message send should have succeeded.",true,false);
+            fail("Message send should have succeeded.");
         }
         channel1.stop(Channel.DEFAULT);
         channel2.stop(Channel.DEFAULT);
     }
 
-
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         tcpFailureDetector1 = null;
         tcpFailureDetector2 = null;
         try { channel1.stop(Channel.DEFAULT);}catch (Exception ignore){ /* Ignore */ }
         channel1 = null;
         try { channel2.stop(Channel.DEFAULT);}catch (Exception ignore){ /* Ignore */ }
         channel2 = null;
-        super.tearDown();
     }
     
     public static class TestMbrListener implements MembershipListener {

Modified: tomcat/trunk/test/org/apache/catalina/tribes/io/TestXByteBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/io/TestXByteBuffer.java?rev=1150974&r1=1150973&r2=1150974&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/io/TestXByteBuffer.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/io/TestXByteBuffer.java Tue Jul 26 02:39:35
2011
@@ -16,15 +16,21 @@
  */
 package org.apache.catalina.tribes.io;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
-public class TestXByteBuffer extends TestCase {
+import org.junit.Test;
 
+public class TestXByteBuffer {
+
+    @Test
     public void testEmptyArray() throws Exception {
         Object obj = XByteBuffer.deserialize(new byte[0]);
         assertNull(obj);
     }
 
+    @Test
     public void testSerializationString() throws Exception {
         String test = "This is as test.";
         byte[] msg = XByteBuffer.serialize(test);

Modified: tomcat/trunk/test/org/apache/catalina/tribes/membership/TestMemberImplSerialization.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/membership/TestMemberImplSerialization.java?rev=1150974&r1=1150973&r2=1150974&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/membership/TestMemberImplSerialization.java
(original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/membership/TestMemberImplSerialization.java
Tue Jul 26 02:39:35 2011
@@ -18,7 +18,11 @@ package org.apache.catalina.tribes.membe
 
 import java.util.Arrays;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * <p>Title: </p>
@@ -30,13 +34,13 @@ import junit.framework.TestCase;
  * @author not attributable
  * @version 1.0
  */
-public class TestMemberImplSerialization extends TestCase {
-    MemberImpl m1, m2, p1,p2;
-    byte[] payload = null;
-    int udpPort = 3445;
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+public class TestMemberImplSerialization {
+    private MemberImpl m1, m2, p1,p2;
+    private byte[] payload = null;
+    private int udpPort = 3445;
+
+    @Before
+    public void setUp() throws Exception {
         payload = new byte[333];
         Arrays.fill(payload,(byte)1);
         m1 = new MemberImpl("localhost",3333,1,payload);
@@ -52,7 +56,8 @@ public class TestMemberImplSerialization
         m1.setUdpPort(udpPort);
         m2.setUdpPort(m1.getUdpPort());
     }
-    
+
+    @Test
     public void testCompare() throws Exception {
         assertTrue(m1.equals(m2));
         assertTrue(m2.equals(m1));
@@ -62,7 +67,8 @@ public class TestMemberImplSerialization
         assertFalse(m2.equals(p2));
         assertFalse(p1.equals(p2));
     }
-    
+
+    @Test
     public void testUdpPort() throws Exception {
         byte[] md1 = m1.getData();
         byte[] md2 = m2.getData();
@@ -70,10 +76,11 @@ public class TestMemberImplSerialization
         MemberImpl a1 = MemberImpl.getMember(md1);
         MemberImpl a2 = MemberImpl.getMember(md2);
         
-        assertEquals(true, a1.getUdpPort()==a2.getUdpPort());
-        assertEquals(true,a1.getUdpPort()==udpPort);
+        assertTrue(a1.getUdpPort()==a2.getUdpPort());
+        assertTrue(a1.getUdpPort()==udpPort);
     }
-    
+
+    @Test
     public void testSerializationOne() throws Exception {
         MemberImpl m = m1;
         byte[] md1 = m.getData(false,true);

Modified: tomcat/trunk/test/org/apache/catalina/tribes/test/TribesTestSuite.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/test/TribesTestSuite.java?rev=1150974&r1=1150973&r2=1150974&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/test/TribesTestSuite.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/test/TribesTestSuite.java Tue Jul 26 02:39:35
2011
@@ -16,9 +16,9 @@
  */
 package org.apache.catalina.tribes.test;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
 
 import org.apache.catalina.tribes.group.TestGroupChannelMemberArrival;
 import org.apache.catalina.tribes.group.TestGroupChannelOptionFlag;
@@ -35,33 +35,19 @@ import org.apache.catalina.tribes.test.c
 import org.apache.catalina.tribes.test.channel.TestRemoteProcessException;
 import org.apache.catalina.tribes.test.channel.TestUdpPackages;
 
-public class TribesTestSuite
-    extends TestCase {
-
-    public TribesTestSuite(String s) {
-        super(s);
-    }
-
-    public static Test suite() {
-        TestSuite suite = new TestSuite();
+@RunWith(Suite.class)
+@SuiteClasses({
         // o.a.catalina.tribes.test.channel
-        suite.addTestSuite(TestGroupChannelStartStop.class);
-        suite.addTestSuite(TestGroupChannelOptionFlag.class);
-        suite.addTestSuite(TestDataIntegrity.class);
-        suite.addTestSuite(TestMulticastPackages.class);
-        suite.addTestSuite(TestRemoteProcessException.class);
-        suite.addTestSuite(TestUdpPackages.class);
+        TestGroupChannelStartStop.class, TestGroupChannelOptionFlag.class,
+        TestDataIntegrity.class, TestMulticastPackages.class,
+        TestRemoteProcessException.class, TestUdpPackages.class,
         // o.a.catalina.tribes.test.interceptors
-        suite.addTestSuite(TestNonBlockingCoordinator.class);
-        suite.addTestSuite(TestOrderInterceptor.class);
+        TestNonBlockingCoordinator.class, TestOrderInterceptor.class,
         // o.a.catalina.tribes.test.io
-        suite.addTestSuite(TestGroupChannelSenderConnections.class);
-        suite.addTestSuite(TestXByteBuffer.class);
+        TestGroupChannelSenderConnections.class, TestXByteBuffer.class,
         // o.a.catalina.tribes.test.membership
-        suite.addTestSuite(TestMemberImplSerialization.class);
-        suite.addTestSuite(TestDomainFilterInterceptor.class);
-        suite.addTestSuite(TestGroupChannelMemberArrival.class);
-        suite.addTestSuite(TestTcpFailureDetector.class);
-        return suite;
-    }
+        TestMemberImplSerialization.class, TestDomainFilterInterceptor.class,
+        TestGroupChannelMemberArrival.class, TestTcpFailureDetector.class })
+public class TribesTestSuite {
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message