Permalink
Browse files

added tests to RetransmitterTest

  • Loading branch information...
1 parent dccdafc commit 2458f322b46b3a1cc913a1c152e874559086612a Bela Ban committed Oct 18, 2011
Showing with 54 additions and 5 deletions.
  1. +54 −5 tests/junit-functional/org/jgroups/tests/RetransmitterTest.java
@@ -12,6 +12,10 @@
import org.testng.Assert;
import org.testng.annotations.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
@Test(groups=Global.FUNCTIONAL,sequential=true,dataProvider="createRetransmitter")
public class RetransmitterTest {
@@ -128,13 +132,58 @@ public void testMultipleEntries(Retransmitter xmitter) {
Assert.assertEquals(0, size);
}
-
+ /**
+ * Note that we do not have overlapping ranges due to the way {@link org.jgroups.stack.NakReceiverWindow} adds
+ * missing messages !
+ * @param xmitter
+ */
@Test(dataProvider="createRetransmitter")
public void testRanges(Retransmitter xmitter) {
- xmitter.add(200, 500);
- xmitter.add(100, 300);
- System.out.println("xmitter: " + xmitter);
- assert xmitter.size() == 401 : "size was " + xmitter.size();
+ xmitter.add(100, 200);
+ xmitter.add(300, 400);
+ System.out.println("xmitter (" + xmitter.getClass().getCanonicalName() + "): " + xmitter);
+ assert xmitter.size() == 202 : "size was " + xmitter.size();
+ }
+
+ @Test(dataProvider="createRetransmitter")
+ public void testAddAndRemoveIndividualSeqnos(Retransmitter xmitter) {
+ int NUM=100;
+ List<Long> seqnos=new ArrayList<Long>(NUM);
+ for(long i=1; i <= NUM; i++) {
+ seqnos.add(i);
+ xmitter.add(i, i);
+ }
+
+ System.out.println("xmitter = " + xmitter);
+ assert xmitter.size() == NUM;
+ Collections.shuffle(seqnos);
+ while(!seqnos.isEmpty()) {
+ long seqno=seqnos.remove(0);
+ xmitter.remove(seqno);
+ }
+ System.out.println("xmitter = " + xmitter);
+ assert xmitter.size() == 0 : "expected size of 0, but size is " + xmitter.size();
+ }
+
+
+ @Test(dataProvider="createRetransmitter")
+ public void testAddAndRemoveRanges(Retransmitter xmitter) {
+ int NUM=100;
+ List<Long> seqnos=new ArrayList<Long>(NUM);
+ for(long i=1; i <= NUM; i++)
+ seqnos.add(i);
+
+ xmitter.add(1, NUM);
+
+ System.out.println("xmitter = " + xmitter);
+ assert xmitter.size() == NUM;
+ Collections.shuffle(seqnos);
+ while(!seqnos.isEmpty()) {
+ long seqno=seqnos.remove(0);
+ xmitter.remove(seqno);
+ }
+ System.out.println("xmitter = " + xmitter);
+ assert xmitter.size() == 0 : "expected size of 0, but size is " + xmitter.size();
}

0 comments on commit 2458f32

Please sign in to comment.