Package org.apache.commons.collections

Examples of org.apache.commons.collections.Buffer.addAll()


    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


        // give hungry read threads ample time to hang
        delay();

        // notifyAll should allow both read threads to complete
        blockingBuffer.addAll( Collections.singleton( obj ) );

        // allow notified threads to complete
        delay();

        // There should not be any threads waiting.
View Full Code Here

        thread1.start();
        thread2.start();

        // give hungry read threads ample time to hang
        delay();
        blockingBuffer.addAll( Collections.singleton( obj ) );

        // allow notified threads to complete
        delay();

        // There should be one thread waiting.
View Full Code Here

        // allow notified threads to complete
        delay();

        // There should be one thread waiting.
        assertTrue( "There is one thread waiting", thread1.isAlive() ^ thread2.isAlive() );
        blockingBuffer.addAll( Collections.singleton( obj ) );

        // allow notified thread to complete
        delay();

        // There should not be any threads waiting.
View Full Code Here

        thread1.start();
        thread2.start();

        // give hungry read threads ample time to hang
        delay();
        blockingBuffer.addAll( objs );

        // allow notified threads to complete
        delay();
        assertEquals( "Both objects were removed", 0, objs.size() );
View Full Code Here

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

       
        // give hungry read threads ample time to hang
        delay();
          
        // notifyAll should allow both read threads to complete
        blockingBuffer.addAll(Collections.singleton(obj));
              
        // allow notified threads to complete
        delay();
       
        // There should not be any threads waiting.
View Full Code Here

        thread2.start();
       
        // give hungry read threads ample time to hang
        delay();
          
        blockingBuffer.addAll(Collections.singleton(obj));
       
        // allow notified threads to complete
        delay();
       
        // There should be one thread waiting.
View Full Code Here

        delay();
       
        // There should be one thread waiting.
        assertTrue ("There is one thread waiting", thread1.isAlive() ^ thread2.isAlive());
          
        blockingBuffer.addAll(Collections.singleton(obj));
       
        // allow notified thread to complete
        delay();

        // There should not be any threads waiting.
View Full Code Here

        thread2.start();
       
        // give hungry read threads ample time to hang
        delay();
          
        blockingBuffer.addAll(objs);
       
        // allow notified threads to complete
        delay();
       
        assertEquals("Both objects were removed", 0, objs.size());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.