Search in sources :

Example 76 with LinkedBlockingDeque

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

the class LinkedBlockingDequeTest method testOfferLastNull.

/**
     * offerLast(null) throws NullPointerException
     */
public void testOfferLastNull() {
    LinkedBlockingDeque q = new LinkedBlockingDeque();
    try {
        q.offerLast(null);
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque)

Example 77 with LinkedBlockingDeque

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

the class LinkedBlockingDequeTest method testPoll.

/**
     * poll succeeds unless empty
     */
public void testPoll() {
    LinkedBlockingDeque q = populatedDeque(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.poll());
    }
    assertNull(q.poll());
}
Also used : LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque)

Example 78 with LinkedBlockingDeque

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

the class LinkedBlockingDequeTest method testClear.

/**
     * clear removes all elements
     */
public void testClear() {
    LinkedBlockingDeque q = populatedDeque(SIZE);
    q.clear();
    assertTrue(q.isEmpty());
    assertEquals(0, q.size());
    assertEquals(SIZE, q.remainingCapacity());
    q.add(one);
    assertFalse(q.isEmpty());
    assertTrue(q.contains(one));
    q.clear();
    assertTrue(q.isEmpty());
}
Also used : LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque)

Example 79 with LinkedBlockingDeque

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

the class LinkedBlockingDequeTest method testOfferFirstNull.

/**
     * offerFirst(null) throws NullPointerException
     */
public void testOfferFirstNull() {
    LinkedBlockingDeque q = new LinkedBlockingDeque();
    try {
        q.offerFirst(null);
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque)

Example 80 with LinkedBlockingDeque

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

the class LinkedBlockingDequeTest method testConstructor6.

/**
     * Deque contains all elements of collection used to initialize
     */
public void testConstructor6() {
    Integer[] ints = new Integer[SIZE];
    for (int i = 0; i < SIZE; ++i) ints[i] = i;
    LinkedBlockingDeque q = new LinkedBlockingDeque(Arrays.asList(ints));
    for (int i = 0; i < SIZE; ++i) assertEquals(ints[i], q.poll());
}
Also used : LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque)

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