public void testTimeoutGet() { final BlockingBuffer buffer = new BlockingBuffer( new MyBuffer() ); try { buffer.get( 100 ); fail( "Get should have timed out." ); } catch( BufferUnderflowException e ) { } }
public void testTimeoutRemove() { final BlockingBuffer buffer = new BlockingBuffer( new MyBuffer() ); try { buffer.remove( 100 ); fail( "Get should have timed out." ); } catch( BufferUnderflowException e ) { } }
public void testRemoveError5() throws Exception { // based on bug 33071 CircularFifoBuffer fifo = new CircularFifoBuffer(5); fifo.add("1"); fifo.add("2"); fifo.add("3"); fifo.add("4"); fifo.add("5"); // end=0 fifo.add("6"); // end=1 fifo.add("7"); // end=2 assertEquals("[3, 4, 5, 6, 7]", fifo.toString()); fifo.remove("5"); // remove element at last pos in array assertEquals("[3, 4, 6, 7]", fifo.toString()); }
/** * Tests that the constructor correctly throws an exception. */ public void testConstructorException1() { try { new CircularFifoBuffer(0); } catch (IllegalArgumentException ex) { return; } fail(); }
public void testAddToFullBufferRemoveViaIterator() { final Buffer bounded = BoundedBuffer.decorate(new UnboundedFifoBuffer(), 1, 500); bounded.add( "Hello" ); new DelayedIteratorRemove( bounded, 200 ).start(); bounded.add( "World" ); assertEquals( 1, bounded.size() ); assertEquals( "World", bounded.get() ); }
public Collection makeCollection() { return UnmodifiableBuffer.decorate(new UnboundedFifoBuffer()); }
public void testAddToFullBufferNoTimeout() { final Buffer bounded = BoundedBuffer.decorate(new UnboundedFifoBuffer(), 1); bounded.add( "Hello" ); try { bounded.add("World"); fail(); } catch (BufferOverflowException e) { } }
/** * Tests {@link BlockingBuffer#get()} in combination with {@link BlockingBuffer#add(Object)}. */ public void testGetWithAdd() { Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer() ); Object obj = new Object(); new DelayedAdd( blockingBuffer, obj ).start(); // verify does not throw BufferUnderflowException; should block until other thread has added to the buffer . assertSame( obj, blockingBuffer.get() ); }
public void testGetWithAddAllTimeout() { Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer(), 500 ); Object obj = new Object(); new DelayedAddAll( blockingBuffer, obj, 100 ).start(); // verify does not throw BufferUnderflowException; should block until other thread has added to the buffer . assertSame( obj, blockingBuffer.get() ); }
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 testConstructorException1() { try { new UnboundedFifoBuffer(0); } catch (IllegalArgumentException ex) { return; } fail(); }
/** * 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 testConstructorException2() { try { new CircularFifoBuffer(-20); } catch (IllegalArgumentException ex) { return; } fail(); }
public void testGetWithAddTimeout() { Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer(), 500 ); Object obj = new Object(); new DelayedAdd( blockingBuffer, obj, 100 ).start(); // verify does not throw BufferUnderflowException; should block until other thread has added to the buffer . assertSame( obj, blockingBuffer.get() ); }
/** * Tests that the constructor correctly throws an exception. */ public void testConstructorException2() { try { new UnboundedFifoBuffer(-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(); }
/** * Tests that the constructor correctly throws an exception. */ public void testConstructorException3() { try { new CircularFifoBuffer(null); } catch (NullPointerException ex) { return; } fail(); }
/** * Tests that the constructor correctly throws an exception. */ public void testConstructorException1() { try { new BoundedFifoBuffer(0); } catch (IllegalArgumentException ex) { return; } fail(); }