Search in sources :

Example 16 with ConcurrentLinkedDeque

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

the class ConcurrentLinkedDequeTest method testRemoveFirst.

/**
     * removeFirst() removes first element, or throws NSEE if empty
     */
public void testRemoveFirst() {
    ConcurrentLinkedDeque q = populatedDeque(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.removeFirst());
    }
    try {
        q.removeFirst();
        shouldThrow();
    } catch (NoSuchElementException success) {
    }
    assertNull(q.peekFirst());
}
Also used : NoSuchElementException(java.util.NoSuchElementException) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque)

Example 17 with ConcurrentLinkedDeque

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

the class ConcurrentLinkedDequeTest method testOfferFirst.

/**
     * offerFirst(x) succeeds
     */
public void testOfferFirst() {
    ConcurrentLinkedDeque q = new ConcurrentLinkedDeque();
    assertTrue(q.offerFirst(zero));
    assertTrue(q.offerFirst(one));
    assertSame(one, q.peekFirst());
    assertSame(zero, q.peekLast());
}
Also used : ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque)

Example 18 with ConcurrentLinkedDeque

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

the class ConcurrentLinkedDequeTest method testAddAll1.

/**
     * addAll(null) throws NPE
     */
public void testAddAll1() {
    ConcurrentLinkedDeque q = new ConcurrentLinkedDeque();
    try {
        q.addAll(null);
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque)

Example 19 with ConcurrentLinkedDeque

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

the class ConcurrentLinkedDequeTest method testRemoveFirstOccurrence.

/**
     * removeFirstOccurrence(x) removes x and returns true if present
     */
public void testRemoveFirstOccurrence() {
    ConcurrentLinkedDeque q = populatedDeque(SIZE);
    for (int i = 1; i < SIZE; i += 2) {
        assertTrue(q.removeFirstOccurrence(new Integer(i)));
    }
    for (int i = 0; i < SIZE; i += 2) {
        assertTrue(q.removeFirstOccurrence(new Integer(i)));
        assertFalse(q.removeFirstOccurrence(new Integer(i + 1)));
    }
    assertTrue(q.isEmpty());
}
Also used : ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque)

Example 20 with ConcurrentLinkedDeque

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

the class ConcurrentLinkedDequeTest method testEmptyIterator.

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

Aggregations

ConcurrentLinkedDeque (java.util.concurrent.ConcurrentLinkedDeque)209 Test (org.junit.Test)21 NoSuchElementException (java.util.NoSuchElementException)16 Iterator (java.util.Iterator)14 Random (java.util.Random)14 CountDownLatch (java.util.concurrent.CountDownLatch)14 Deque (java.util.Deque)7 ExecutorService (java.util.concurrent.ExecutorService)7 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 IOException (java.io.IOException)4 List (java.util.List)4 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)4 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)4 BlockIdList (alluxio.grpc.BlockIdList)3 BlockStoreLocationProto (alluxio.grpc.BlockStoreLocationProto)3 LocationBlockIdListEntry (alluxio.grpc.LocationBlockIdListEntry)3