Search in sources :

Example 36 with LinkedBlockingDeque

use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.

the class LinkedBlockingDequeTest method testAddAllSelf.

/**
     * addAll(this) throws IAE
     */
public void testAddAllSelf() {
    LinkedBlockingDeque q = populatedDeque(SIZE);
    try {
        q.addAll(q);
        shouldThrow();
    } catch (IllegalArgumentException success) {
    }
}
Also used : LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque)

Example 37 with LinkedBlockingDeque

use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.

the class LinkedBlockingDequeTest method testPut.

/**
     * all elements successfully put are contained
     */
public void testPut() throws InterruptedException {
    LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        Integer x = new Integer(i);
        q.put(x);
        assertTrue(q.contains(x));
    }
    assertEquals(0, q.remainingCapacity());
}
Also used : LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque)

Example 38 with LinkedBlockingDeque

use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.

the class LinkedBlockingDequeTest method testRemoveAll.

/**
     * removeAll(c) removes only those elements of c and reports true if changed
     */
public void testRemoveAll() {
    for (int i = 1; i < SIZE; ++i) {
        LinkedBlockingDeque q = populatedDeque(SIZE);
        LinkedBlockingDeque p = populatedDeque(i);
        assertTrue(q.removeAll(p));
        assertEquals(SIZE - i, q.size());
        for (int j = 0; j < i; ++j) {
            Integer x = (Integer) (p.remove());
            assertFalse(q.contains(x));
        }
    }
}
Also used : LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque)

Example 39 with LinkedBlockingDeque

use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.

the class LinkedBlockingDequeTest method testEmptyIterator.

/**
     * iterator of empty collection has no elements
     */
public void testEmptyIterator() {
    Deque c = new LinkedBlockingDeque();
    assertIteratorExhausted(c.iterator());
    assertIteratorExhausted(c.descendingIterator());
}
Also used : LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) BlockingDeque(java.util.concurrent.BlockingDeque) Deque(java.util.Deque) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque)

Example 40 with LinkedBlockingDeque

use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.

the class LinkedBlockingDequeTest method testElement.

/**
     * element returns next element, or throws NSEE if empty
     */
public void testElement() {
    LinkedBlockingDeque q = populatedDeque(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.element());
        q.poll();
    }
    try {
        q.element();
        shouldThrow();
    } catch (NoSuchElementException success) {
    }
}
Also used : LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

LinkedBlockingDeque (java.util.concurrent.LinkedBlockingDeque)119 Test (org.junit.Test)21 CountDownLatch (java.util.concurrent.CountDownLatch)20 NoSuchElementException (java.util.NoSuchElementException)8 ArrayList (java.util.ArrayList)7 Iterator (java.util.Iterator)7 IOException (java.io.IOException)5 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)5 ExecutorService (java.util.concurrent.ExecutorService)5 BlockingDeque (java.util.concurrent.BlockingDeque)4 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)4 ByteBuffer (java.nio.ByteBuffer)3 HashMap (java.util.HashMap)3 IotHubOutboundPacket (com.microsoft.azure.sdk.iot.device.transport.IotHubOutboundPacket)2 AmqpsMessage (com.microsoft.azure.sdk.iot.device.transport.amqps.AmqpsMessage)2 AmqpsTransport (com.microsoft.azure.sdk.iot.device.transport.amqps.AmqpsTransport)2 ByteBuf (io.netty.buffer.ByteBuf)2 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)2 ChannelInboundHandlerAdapter (io.netty.channel.ChannelInboundHandlerAdapter)2 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)2