@@ -0,0 +1,2126 @@
+package org.smpp.util;%0A%0Aimport static org.junit.Assert.*;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.ExpectedException;%0A%0Apublic class QueueTest %7B%0A%0A%09private Queue queue;%0A%0A%09@Rule%0A%09public ExpectedException thrown = ExpectedException.none();%0A%0A%09@Before%0A%09public void setup() %7B%0A%09%09queue = new Queue();%0A%09%7D%0A%0A%09@Test%0A%09public void testDefaultConstructorDoesNotLimitSize() %7B%0A%09%09Object o = new Object();%0A%09%09// FIXME: there seems to be a performance issue going over this...%0A%09%09int limit = 1000000;%0A%09%09for (int i = 0; i %3C limit; i++) %7B%0A%09%09%09queue.enqueue(o);%0A%09%09%7D%0A%09%09assertEquals(limit, queue.size());%0A%09%7D%0A%0A%09@Test%0A%09public void testConstructorLimitsSize() throws IndexOutOfBoundsException %7B%0A%09%09thrown.expect(IndexOutOfBoundsException.class);%0A%0A%09%09queue = new Queue(10);%0A%09%09for (int i = 0; i %3C 11; i++) %7B%0A%09%09%09queue.enqueue(new Object());%0A%09%09%7D%0A%09%7D%0A%0A%09@Test%0A%09public void testIsEmpty() %7B%0A%09%09assertTrue(queue.isEmpty());%0A%09%09queue.enqueue(new Object());%0A%09%09assertFalse(queue.isEmpty());%0A%09%09queue.dequeue();%0A%09%09assertTrue(queue.isEmpty());%0A%09%7D%0A%0A%09@Test%0A%09public void testSize() %7B%0A%09%09int size = 0;%0A%09%09assertEquals(size, queue.size());%0A%09%09for (int i = 0; i %3C 10; i++) %7B%0A%09%09%09queue.enqueue(size++);%0A%09%09%09assertEquals(size, queue.size());%0A%09%09%7D%0A%09%7D%0A%0A%09@Test%0A%09public void testFifo() %7B%0A%09%09Object a = new Object();%0A%09%09Object b = new Object();%0A%09%09Object c = new Object();%0A%0A%09%09queue.enqueue(a);%0A%09%09queue.enqueue(b);%0A%09%09queue.enqueue(c);%0A%0A%09%09assertSame(a, queue.dequeue());%0A%09%09assertSame(b, queue.dequeue());%0A%09%09assertSame(c, queue.dequeue());%0A%09%09assertTrue(queue.isEmpty());%0A%09%7D%0A%0A%09@Test%0A%09public void testFind() %7B%0A%09%09Object a = new Object();%0A%09%09Object b = new Object();%0A%09%09Object c = new Object();%0A%0A%09%09queue.enqueue(a);%0A%09%09queue.enqueue(b);%0A%09%09queue.enqueue(c);%0A%0A%09%09assertEquals(3, queue.size());%0A%09%09assertSame(a, queue.find(a));%0A%09%09assertSame(b, queue.find(b));%0A%09%09assertSame(c, queue.find(c));%0A%09%09assertEquals(3, queue.size());%0A%09%7D%0A%0A%09@Test%0A%09public void testDequeueReturnsNullWhenEmpty() %7B%0A%09%09assertNull(queue.dequeue());%0A%09%7D%0A%0A%09@Test%0A%09public void testDequeueReturnsNullWhenNotEnqueued() %7B%0A%09%09queue.enqueue(new Object());%0A%09%09assertNull(queue.dequeue(new Object()));%0A%09%7D%0A%7D%0A

add tests for queue