Search in sources :

Example 81 with ConcurrentLinkedDeque

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

the class ConcurrentLinkedDequeTest method testToString.

/**
 * toString() contains toStrings of elements
 */
public void testToString() {
    ConcurrentLinkedDeque q = populatedDeque(SIZE);
    String s = q.toString();
    for (int i = 0; i < SIZE; ++i) {
        assertTrue(s.contains(String.valueOf(i)));
    }
}
Also used : ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque)

Example 82 with ConcurrentLinkedDeque

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

the class ConcurrentLinkedDequeTest method testRetainAll.

/**
 * retainAll(c) retains only those elements of c and reports true if change
 */
public void testRetainAll() {
    ConcurrentLinkedDeque q = populatedDeque(SIZE);
    ConcurrentLinkedDeque p = populatedDeque(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 : ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque)

Example 83 with ConcurrentLinkedDeque

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

the class ConcurrentLinkedDequeTest method testEmpty.

/**
 * isEmpty is true before add, false after
 */
public void testEmpty() {
    ConcurrentLinkedDeque q = new ConcurrentLinkedDeque();
    assertTrue(q.isEmpty());
    q.add(one);
    assertFalse(q.isEmpty());
    q.add(two);
    q.remove();
    q.remove();
    assertTrue(q.isEmpty());
}
Also used : ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque)

Example 84 with ConcurrentLinkedDeque

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

the class ConcurrentLinkedDequeTest method testAddAll5.

/**
 * Deque contains all elements, in traversal order, of successful addAll
 */
public void testAddAll5() {
    Integer[] empty = new Integer[0];
    Integer[] ints = new Integer[SIZE];
    for (int i = 0; i < SIZE; ++i) ints[i] = new Integer(i);
    ConcurrentLinkedDeque q = new ConcurrentLinkedDeque();
    assertFalse(q.addAll(Arrays.asList(empty)));
    assertTrue(q.addAll(Arrays.asList(ints)));
    for (int i = 0; i < SIZE; ++i) assertEquals(ints[i], q.poll());
}
Also used : ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque)

Example 85 with ConcurrentLinkedDeque

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

the class ConcurrentLinkedDequeTest method testRemoveElement.

/**
 * remove(x) removes x and returns true if present
 */
public void testRemoveElement() {
    ConcurrentLinkedDeque q = populatedDeque(SIZE);
    for (int i = 1; i < SIZE; i += 2) {
        assertTrue(q.contains(i));
        assertTrue(q.remove(i));
        assertFalse(q.contains(i));
        assertTrue(q.contains(i - 1));
    }
    for (int i = 0; i < SIZE; i += 2) {
        assertTrue(q.contains(i));
        assertTrue(q.remove(i));
        assertFalse(q.contains(i));
        assertFalse(q.remove(i + 1));
        assertFalse(q.contains(i + 1));
    }
    assertTrue(q.isEmpty());
}
Also used : 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