/** * Tests that the removal operation actually removes the first element. */ public void testBoundedFifoBufferRemove() { resetFull(); int size = confirmed.size(); for (int i = 0; i < size; i++) { Object o1 = ((BoundedFifoBuffer)collection).remove(); Object o2 = ((ArrayList)confirmed).remove(0); assertEquals("Removed objects should be equal", o1, o2); verify(); } try { ((BoundedFifoBuffer)collection).remove(); fail("Empty buffer should raise Underflow."); } catch (BufferUnderflowException e) { // expected } }
/** * Runs through the regular verifications, but also verifies that * the buffer contains the same elements in the same sequence as the * list. */ public void verify() { super.verify(); Iterator iterator1 = collection.iterator(); Iterator iterator2 = confirmed.iterator(); while (iterator2.hasNext()) { assertTrue(iterator1.hasNext()); Object o1 = iterator1.next(); Object o2 = iterator2.next(); assertEquals(o1, o2); } }
/** * Returns a full ArrayList. * * @return a full ArrayList */ public Collection makeConfirmedFullCollection() { Collection c = makeConfirmedCollection(); c.addAll(java.util.Arrays.asList(getFullElements())); return c; }
/** * Tests that the constructor correctly throws an exception. */ public void testConstructorException1() { try { new BoundedFifoBuffer(0); } catch (IllegalArgumentException ex) { return; } fail(); }
public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest(TestBoundedFifoBuffer.suite()); suite.addTest(TestBoundedFifoBuffer2.suite()); suite.addTest(TestCircularFifoBuffer.suite()); suite.addTest(TestPriorityBuffer.suite()); suite.addTest(TestUnboundedFifoBuffer.suite()); suite.addTest(TestBlockingBuffer.suite()); suite.addTest(TestBoundedBuffer.suite()); suite.addTest(TestPredicatedBuffer.suite()); suite.addTest(TestSynchronizedBuffer.suite()); suite.addTest(TestTransformedBuffer.suite()); suite.addTest(TestUnmodifiableBuffer.suite()); return suite; }
/** * Tests that the constructor correctly throws an exception. */ public void testConstructorException2() { try { new BoundedFifoBuffer(-20); } catch (IllegalArgumentException ex) { return; } fail(); }
/** * Tests that the constructor correctly throws an exception. */ public void testConstructorException3() { try { new BoundedFifoBuffer(null); } catch (NullPointerException ex) { return; } fail(); }