import java.util.Arrays;
import java.util.Random;
-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.ChannelListener;
* @author not attributable
* @version 1.0
*/
-public class TestDataIntegrity extends TestCase {
- int msgCount = 500;
- int threadCount = 20;
- GroupChannel channel1;
- GroupChannel channel2;
- Listener listener1;
- int threadCounter = 0;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+public class TestDataIntegrity {
+ private int msgCount = 500;
+ private int threadCount = 20;
+ private GroupChannel channel1;
+ private GroupChannel channel2;
+ private Listener listener1;
+
+ @SuppressWarnings("unused")
+ private int threadCounter = 0;
+
+ @Before
+ public void setUp() throws Exception {
channel1 = new GroupChannel();
channel1.addInterceptor(new MessageDispatch15Interceptor());
channel2 = new GroupChannel();
channel2.start(Channel.DEFAULT);
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void tearDown() throws Exception {
channel1.stop(Channel.DEFAULT);
channel2.stop(Channel.DEFAULT);
}
+ @Test
public void testDataSendNO_ACK() throws Exception {
System.err.println("Starting NO_ACK");
Thread[] threads = new Thread[threadCount];
assertEquals("Checking success messages.",msgCount*threadCount,listener1.count);
}
+ @Test
public void testDataSendASYNCM() throws Exception {
System.err.println("Starting ASYNC MULTI THREAD");
Thread[] threads = new Thread[threadCount];
System.err.println("Finished ASYNC MULTI THREAD ["+listener1.count+"]");
assertEquals("Checking success messages.",msgCount*threadCount,listener1.count);
}
+
+ @Test
public void testDataSendASYNC() throws Exception {
System.err.println("Starting ASYNC");
for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(),Channel.SEND_OPTIONS_ASYNCHRONOUS);
assertEquals("Checking success messages.",msgCount,listener1.count);
}
+ @Test
public void testDataSendACK() throws Exception {
System.err.println("Starting ACK");
for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(),Channel.SEND_OPTIONS_USE_ACK);
assertEquals("Checking success messages.",msgCount,listener1.count);
}
+ @Test
public void testDataSendSYNCACK() throws Exception {
System.err.println("Starting SYNC_ACK");
for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(),Channel.SEND_OPTIONS_SYNCHRONIZED_ACK|Channel.SEND_OPTIONS_USE_ACK);
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-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.ChannelListener;
/**
*/
-public class TestMulticastPackages extends TestCase {
- int msgCount = 500;
- int threadCount = 20;
- GroupChannel channel1;
- GroupChannel channel2;
- Listener listener1;
- int threadCounter = 0;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+public class TestMulticastPackages {
+ private int msgCount = 500;
+ private int threadCount = 20;
+ private GroupChannel channel1;
+ private GroupChannel channel2;
+ private Listener listener1;
+
+ @SuppressWarnings("unused")
+ private int threadCounter = 0;
+
+ @Before
+ public void setUp() throws Exception {
channel1 = new GroupChannel();
channel1.addInterceptor(new MessageDispatch15Interceptor());
channel2 = new GroupChannel();
channel2.start(Channel.DEFAULT);
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void tearDown() throws Exception {
channel1.stop(Channel.DEFAULT);
channel2.stop(Channel.DEFAULT);
}
+ @Test
public void testSingleDataSendNO_ACK() throws Exception {
AbstractSender s1 =(AbstractSender) ((ReplicationTransmitter)channel1.getChannelSender()).getTransport();
AbstractSender s2 =(AbstractSender) ((ReplicationTransmitter)channel2.getChannelSender()).getTransport();
System.out.println();
}
+ @Test
public void testDataSendASYNCM() throws Exception {
final AtomicInteger counter = new AtomicInteger(0);
ReceiverBase rb1 = (ReceiverBase)channel1.getChannelReceiver();
printMissingMsgs(listener1.nrs,counter.get());
assertEquals("Checking success messages.",msgCount*threadCount,listener1.count.get());
}
+
+ @Test
public void testDataSendASYNC() throws Exception {
System.err.println("Starting ASYNC");
for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),Channel.SEND_OPTIONS_ASYNCHRONOUS|Channel.SEND_OPTIONS_MULTICAST);
assertEquals("Checking success messages.",msgCount,listener1.count.get());
}
+ @Test
public void testDataSendACK() throws Exception {
System.err.println("Starting ACK");
for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),Channel.SEND_OPTIONS_USE_ACK|Channel.SEND_OPTIONS_MULTICAST);
assertEquals("Checking success messages.",msgCount,listener1.count.get());
}
+ @Test
public void testDataSendSYNCACK() throws Exception {
System.err.println("Starting SYNC_ACK");
for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),Channel.SEND_OPTIONS_SYNCHRONIZED_ACK|Channel.SEND_OPTIONS_USE_ACK|Channel.SEND_OPTIONS_MULTICAST);
import java.util.Arrays;
import java.util.Random;
-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.ChannelListener;
* @author not attributable
* @version 1.0
*/
-public class TestRemoteProcessException extends TestCase {
- int msgCount = 10000;
- GroupChannel channel1;
- GroupChannel channel2;
- Listener listener1;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+public class TestRemoteProcessException {
+ private int msgCount = 10000;
+ private GroupChannel channel1;
+ private GroupChannel channel2;
+ private Listener listener1;
+
+ @Before
+ public void setUp() throws Exception {
channel1 = new GroupChannel();
channel2 = new GroupChannel();
listener1 = new Listener();
channel2.start(Channel.DEFAULT);
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void tearDown() throws Exception {
channel1.stop(Channel.DEFAULT);
channel2.stop(Channel.DEFAULT);
}
+ @Test
public void testDataSendSYNCACK() throws Exception {
System.err.println("Starting SYNC_ACK");
int errC=0, nerrC=0;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-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.ChannelListener;
/**
*/
-public class TestUdpPackages extends TestCase {
- int msgCount = 500;
- int threadCount = 20;
- GroupChannel channel1;
- GroupChannel channel2;
- Listener listener1;
- int threadCounter = 0;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+public class TestUdpPackages {
+ private int msgCount = 500;
+ private int threadCount = 20;
+ private GroupChannel channel1;
+ private GroupChannel channel2;
+ private Listener listener1;
+
+ @SuppressWarnings("unused")
+ private int threadCounter = 0;
+
+ @Before
+ public void setUp() throws Exception {
channel1 = new GroupChannel();
channel1.addInterceptor(new MessageDispatch15Interceptor());
channel2 = new GroupChannel();
channel2.start(Channel.DEFAULT);
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void tearDown() throws Exception {
channel1.stop(Channel.DEFAULT);
channel2.stop(Channel.DEFAULT);
}
+ @Test
public void testSingleDataSendNO_ACK() throws Exception {
AbstractSender s1 =(AbstractSender) ((ReplicationTransmitter)channel1.getChannelSender()).getTransport();
AbstractSender s2 =(AbstractSender) ((ReplicationTransmitter)channel2.getChannelSender()).getTransport();
assertEquals("Checking success messages.",1,listener1.count.get());
}
-
+ @Test
public void testDataSendNO_ACK() throws Exception {
final AtomicInteger counter = new AtomicInteger(0);
ReceiverBase rb1 = (ReceiverBase)channel1.getChannelReceiver();
System.out.println();
}
+ @Test
public void testDataSendASYNCM() throws Exception {
final AtomicInteger counter = new AtomicInteger(0);
ReceiverBase rb1 = (ReceiverBase)channel1.getChannelReceiver();
printMissingMsgs(listener1.nrs,counter.get());
assertEquals("Checking success messages.",msgCount*threadCount,listener1.count.get());
}
+
+ @Test
public void testDataSendASYNC() throws Exception {
System.err.println("Starting ASYNC");
for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),Channel.SEND_OPTIONS_ASYNCHRONOUS|Channel.SEND_OPTIONS_UDP);
assertEquals("Checking success messages.",msgCount,listener1.count.get());
}
+ @Test
public void testDataSendACK() throws Exception {
System.err.println("Starting ACK");
for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),Channel.SEND_OPTIONS_USE_ACK|Channel.SEND_OPTIONS_UDP);
assertEquals("Checking success messages.",msgCount,listener1.count.get());
}
+ @Test
public void testDataSendSYNCACK() throws Exception {
System.err.println("Starting SYNC_ACK");
for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),Channel.SEND_OPTIONS_SYNCHRONIZED_ACK|Channel.SEND_OPTIONS_USE_ACK|Channel.SEND_OPTIONS_UDP);
<bug>51531</bug>: Update sample Eclipse classpath file to reflect
updated ECJ jar. Patch provided by Ian Brandt. (markt)
</fix>
+ <update>
+ Converted Tomcat unit tests to JUnit 4. (kkolinko)
+ </update>
</changelog>
</subsection>
</section>