Package org.apache.commons.collections

Examples of org.apache.commons.collections.Buffer


        } catch (BufferOverflowException e) {
        }
    }

    public void testAddAllToEmptyBufferExceedMaxSizeNoTimeout() {
        final Buffer bounded = BoundedBuffer.decorate(new UnboundedFifoBuffer(), 1);
        try {
            bounded.addAll(Collections.nCopies(2, "test"));
            fail();
        } catch (BufferOverflowException e) {
        }
    }
View Full Code Here


        } catch (BufferOverflowException e) {
        }
    }

    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() );

    }
View Full Code Here

        assertEquals( "World", bounded.get() );

    }

    public void testAddAllToFullBufferRemoveViaIterator() {
        final Buffer bounded = BoundedBuffer.decorate(new UnboundedFifoBuffer(), 2, 500);
        bounded.add( "Hello" );
        bounded.add( "World" );
        new DelayedIteratorRemove( bounded, 200, 2 ).start();
        bounded.addAll( Arrays.asList( new String[] { "Foo", "Bar" } ) );
        assertEquals( 2, bounded.size() );
        assertEquals( "Foo", bounded.remove() );
        assertEquals( "Bar", bounded.remove() );
    }
View Full Code Here

        assertEquals( "Foo", bounded.remove() );
        assertEquals( "Bar", bounded.remove() );
    }

    public void testAddToFullBufferWithTimeout() {
        final Buffer bounded = BoundedBuffer.decorate(new UnboundedFifoBuffer(), 1, 500);
        bounded.add( "Hello" );
        new DelayedRemove( bounded, 200 ).start();
        bounded.add( "World" );
        assertEquals( 1, bounded.size() );
        assertEquals( "World", bounded.get() );
        try {
            bounded.add( "!" );
            fail();
        }
        catch( BufferOverflowException e ) {
        }
    }
View Full Code Here

        catch( BufferOverflowException e ) {
        }
    }

    public void testAddAllToFullBufferWithTimeout() {
        final Buffer bounded = BoundedBuffer.decorate(new UnboundedFifoBuffer(), 2, 500);
        bounded.add( "Hello" );
        bounded.add( "World" );
        new DelayedRemove( bounded, 200, 2 ).start();

        bounded.addAll( Arrays.asList( new String[] { "Foo", "Bar" } ) );
        assertEquals( 2, bounded.size() );
        assertEquals( "Foo", bounded.get() );
        try {
            bounded.add( "!" );
            fail();
        }
        catch( BufferOverflowException e ) {
        }
    }
View Full Code Here

    /**
     * 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() );
    }
View Full Code Here

        // verify does not throw BufferUnderflowException; should block until other thread has added to the buffer .
        assertSame( obj, blockingBuffer.get() );
    }

    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() );
    }
View Full Code Here

    /**
     * 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() );
    }
View Full Code Here

        // 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() );
    }
View Full Code Here

    /**
     * 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() );
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.collections.Buffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.