Search in sources :

Example 46 with LinkedTransferQueue

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

the class LinkedTransferQueueTest method testToArray1_BadArg.

/**
     * toArray(incompatible array type) throws ArrayStoreException
     */
public void testToArray1_BadArg() {
    LinkedTransferQueue q = populatedQueue(SIZE);
    try {
        q.toArray(new String[10]);
        shouldThrow();
    } catch (ArrayStoreException success) {
    }
}
Also used : LinkedTransferQueue(java.util.concurrent.LinkedTransferQueue)

Example 47 with LinkedTransferQueue

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

the class LinkedTransferQueueTest method testIteratorRemove.

/**
     * iterator.remove() removes current element
     */
public void testIteratorRemove() {
    final LinkedTransferQueue q = new LinkedTransferQueue();
    q.add(two);
    q.add(one);
    q.add(three);
    Iterator it = q.iterator();
    it.next();
    it.remove();
    it = q.iterator();
    assertSame(it.next(), one);
    assertSame(it.next(), three);
    assertFalse(it.hasNext());
}
Also used : Iterator(java.util.Iterator) LinkedTransferQueue(java.util.concurrent.LinkedTransferQueue)

Example 48 with LinkedTransferQueue

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

the class LinkedTransferQueueTest method testTransfer1.

/**
     * transfer(null) throws NullPointerException
     */
public void testTransfer1() throws InterruptedException {
    try {
        LinkedTransferQueue q = new LinkedTransferQueue();
        q.transfer(null);
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : LinkedTransferQueue(java.util.concurrent.LinkedTransferQueue)

Example 49 with LinkedTransferQueue

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

the class LinkedTransferQueueTest method testRetainAll.

/**
     * retainAll(c) retains only those elements of c and reports true
     * if changed
     */
public void testRetainAll() {
    LinkedTransferQueue q = populatedQueue(SIZE);
    LinkedTransferQueue p = populatedQueue(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        boolean changed = q.retainAll(p);
        if (i == 0) {
            assertFalse(changed);
        } else {
            assertTrue(changed);
        }
        assertTrue(q.containsAll(p));
        assertEquals(SIZE - i, q.size());
        p.remove();
    }
}
Also used : LinkedTransferQueue(java.util.concurrent.LinkedTransferQueue)

Example 50 with LinkedTransferQueue

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

the class LinkedTransferQueueTest method testTryTransfer1.

/**
     * tryTransfer(null) throws NullPointerException
     */
public void testTryTransfer1() {
    final LinkedTransferQueue q = new LinkedTransferQueue();
    try {
        q.tryTransfer(null);
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : LinkedTransferQueue(java.util.concurrent.LinkedTransferQueue)

Aggregations

LinkedTransferQueue (java.util.concurrent.LinkedTransferQueue)66 ArrayList (java.util.ArrayList)10 Iterator (java.util.Iterator)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 List (java.util.List)4 ExecutorService (java.util.concurrent.ExecutorService)4 Callable (java.util.concurrent.Callable)2 IOException (java.io.IOException)1 RandomAccessFile (java.io.RandomAccessFile)1 MappedByteBuffer (java.nio.MappedByteBuffer)1 FileChannel (java.nio.channels.FileChannel)1 AbstractList (java.util.AbstractList)1 Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1 LinkedList (java.util.LinkedList)1 Queue (java.util.Queue)1 RejectedExecutionHandler (java.util.concurrent.RejectedExecutionHandler)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 TransferQueue (java.util.concurrent.TransferQueue)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1