01: package org.jgroups.tests;
02:
03: import junit.framework.Test;
04: import junit.framework.TestCase;
05: import junit.framework.TestSuite;
06: import org.jgroups.Message;
07: import org.jgroups.stack.AckReceiverWindow;
08:
09: /**
10: * @author Bela Ban
11: * @version $Id: AckReceiverWindowTest.java,v 1.2 2005/08/21 20:37:50 belaban Exp $
12: */
13: public class AckReceiverWindowTest extends TestCase {
14: AckReceiverWindow win;
15:
16: public AckReceiverWindowTest(String name) {
17: super (name);
18: }
19:
20: public void setUp() throws Exception {
21: super .setUp();
22: }
23:
24: public void tearDown() throws Exception {
25: super .tearDown();
26: }
27:
28: public void test1() {
29: Message m;
30: win = new AckReceiverWindow(10);
31: assertEquals(0, win.size());
32: win.add(9, msg());
33: assertEquals(0, win.size());
34:
35: win.add(10, msg());
36: assertEquals(1, win.size());
37:
38: win.add(13, msg());
39: assertEquals(2, win.size());
40:
41: m = win.remove();
42: assertNotNull(m);
43: assertEquals(1, win.size());
44:
45: m = win.remove();
46: assertNull(m);
47: assertEquals(1, win.size());
48:
49: win.add(11, msg());
50: win.add(12, msg());
51: assertEquals(3, win.size());
52:
53: m = win.remove();
54: assertNotNull(m);
55: m = win.remove();
56: assertNotNull(m);
57: m = win.remove();
58: assertNotNull(m);
59: assertEquals(0, win.size());
60: m = win.remove();
61: assertNull(m);
62: }
63:
64: private Message msg() {
65: return new Message();
66: }
67:
68: public static Test suite() {
69: TestSuite s = new TestSuite(AckReceiverWindowTest.class);
70: return s;
71: }
72:
73: public static void main(String[] args) {
74: String[] testCaseName = { AckReceiverWindowTest.class.getName() };
75: junit.textui.TestRunner.main(testCaseName);
76: }
77:
78: }
|