/** * 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() ); }
/** * Tests {@link BlockingBuffer#remove()} in combination with {@link BlockingBuffer#add(Object)}. */ public void testRemoveWithAdd() { 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.remove() ); }
/** * Tests {@link BlockingBuffer#get()} in combination with {@link BlockingBuffer#addAll(java.util.Collection)}. */ public void testGetWithAddAll() { Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer() ); Object obj = new Object(); new DelayedAddAll( blockingBuffer, obj ).start(); // verify does not throw BufferUnderflowException; should block until other thread has added to the buffer . assertSame( obj, blockingBuffer.get() ); }
/** * Tests {@link BlockingBuffer#remove()} in combination with {@link BlockingBuffer#addAll(java.util.Collection)}. */ public void testRemoveWithAddAll() { Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer() ); Object obj = new Object(); new DelayedAddAll( blockingBuffer, obj ).start(); // verify does not throw BufferUnderflowException; should block until other thread has added to the buffer . assertSame( obj, blockingBuffer.remove() ); }
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() ); }
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() ); }