1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.onemind.commons.java.datastructure;
22
23 import java.util.List;
24 import junit.framework.TestCase;
25 import org.onemind.commons.java.datastructure.CounterQueue;
26 /***
27 * The test for counter queue
28 * @author TiongHiang Lee (thlee@onemindsoft.org)
29 * @version $Id: CounterQueueTest.java,v 1.2 2004/08/26 12:33:09 thlee Exp $ $Name: $
30 */
31 public class CounterQueueTest extends TestCase
32 {
33
34 public void testCounterQueue()
35 {
36 CounterQueue cq = new CounterQueue();
37 Object counter = new Object();
38 Object queuer1 = new Object();
39 Object queuer2 = new Object();
40
41 assertEquals(cq.getQueue(new Object()).size(), 0);
42
43 cq.addToQueue(counter, queuer1);
44 cq.addToQueue(counter, queuer2);
45
46 assertEquals(cq.getQueue(new Object()).size(), 0);
47
48 List l = cq.getQueue(counter);
49 assertEquals(l.size(), 2);
50 assertEquals(l.get(0), queuer1);
51 assertEquals(l.get(1), queuer2);
52
53 assertEquals(cq.removeNextFromQueue(counter), queuer1);
54 assertEquals(l.size(), 1);
55
56 cq.removeFromQueue(counter, queuer2);
57 assertEquals(l.size(), 0);
58 }
59 }