Search in sources :

Example 91 with ConcurrentLinkedDeque

use of java.util.concurrent.ConcurrentLinkedDeque in project j2objc by google.

the class ConcurrentLinkedDequeTest method testWeaklyConsistentIteration.

/**
 * Modifications do not cause iterators to fail
 */
public void testWeaklyConsistentIteration() {
    final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque();
    q.add(one);
    q.add(two);
    q.add(three);
    for (Iterator it = q.iterator(); it.hasNext(); ) {
        q.remove();
        it.next();
    }
    assertEquals("deque should be empty again", 0, q.size());
}
Also used : Iterator(java.util.Iterator) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque)

Example 92 with ConcurrentLinkedDeque

use of java.util.concurrent.ConcurrentLinkedDeque in project j2objc by google.

the class ConcurrentLinkedDequeTest method testPollFirst.

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

Example 93 with ConcurrentLinkedDeque

use of java.util.concurrent.ConcurrentLinkedDeque in project j2objc by google.

the class ConcurrentLinkedDequeTest method testAddAllSelf.

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

Example 94 with ConcurrentLinkedDeque

use of java.util.concurrent.ConcurrentLinkedDeque in project j2objc by google.

the class ConcurrentLinkedDequeTest method testPeek.

/**
 * peek() returns next element, or null if empty
 */
public void testPeek() {
    ConcurrentLinkedDeque q = populatedDeque(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.peek());
        assertEquals(i, q.poll());
        assertTrue(q.peek() == null || !q.peek().equals(i));
    }
    assertNull(q.peek());
}
Also used : ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque)

Example 95 with ConcurrentLinkedDeque

use of java.util.concurrent.ConcurrentLinkedDeque in project j2objc by google.

the class ConcurrentLinkedDequeTest method testDescendingIterator.

/**
 * Descending iterator iterates through all elements
 */
public void testDescendingIterator() {
    ConcurrentLinkedDeque q = populatedDeque(SIZE);
    int i = 0;
    Iterator it = q.descendingIterator();
    while (it.hasNext()) {
        assertTrue(q.contains(it.next()));
        ++i;
    }
    assertEquals(i, SIZE);
    assertFalse(it.hasNext());
    try {
        it.next();
        shouldThrow();
    } catch (NoSuchElementException success) {
    }
}
Also used : Iterator(java.util.Iterator) NoSuchElementException(java.util.NoSuchElementException) 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