01: package org.shiftone.cache.test;
02:
03: import junit.framework.TestCase;
04:
05: import org.shiftone.cache.util.RingFifo;
06:
07: /**
08: * @author <a href="mailto:jeff@shiftone.org">Jeff Drost</a>
09: * @version $Revision: 1.5 $
10: */
11: public class RingFifoTestCase extends TestCase {
12:
13: public void testSimple() {
14:
15: RingFifo fifo = new RingFifo(5);
16:
17: assertEquals(",,,,", fifo.dump());
18: fifo.enqueue("A");
19: assertEquals("A", fifo.peek());
20: assertEquals("A,,,,", fifo.dump());
21: fifo.enqueue("B");
22: assertEquals("A,B,,,", fifo.dump());
23: fifo.enqueue("C");
24: assertEquals("A,B,C,,", fifo.dump());
25: fifo.enqueue("D");
26: assertEquals("A,B,C,D,", fifo.dump());
27: fifo.enqueue("E");
28: assertEquals("A,B,C,D,E", fifo.dump());
29: fifo.enqueue("F");
30: assertEquals("F,B,C,D,E", fifo.dump());
31: fifo.enqueue("G");
32: assertEquals("C", fifo.dequeue());
33: assertEquals("D", fifo.dequeue());
34: assertEquals("E", fifo.dequeue());
35: assertEquals("F", fifo.dequeue());
36: assertEquals("G", fifo.dequeue());
37: assertNull(fifo.dequeue());
38: }
39: }
|