Search in sources :

Example 96 with ConcurrentLinkedQueue

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

the class ConcurrentLinkedQueueTest method testRemove.

/**
     * remove removes next element, or throws NSEE if empty
     */
public void testRemove() {
    ConcurrentLinkedQueue q = populatedQueue(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.remove());
    }
    try {
        q.remove();
        shouldThrow();
    } catch (NoSuchElementException success) {
    }
}
Also used : ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) NoSuchElementException(java.util.NoSuchElementException)

Example 97 with ConcurrentLinkedQueue

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

the class ConcurrentLinkedQueueTest method testToArray1_BadArg.

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

Example 98 with ConcurrentLinkedQueue

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

the class ConcurrentLinkedQueueTest method testSize.

/**
     * size changes when elements added and removed
     */
public void testSize() {
    ConcurrentLinkedQueue q = populatedQueue(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(SIZE - i, q.size());
        q.remove();
    }
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.size());
        q.add(new Integer(i));
    }
}
Also used : ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue)

Example 99 with ConcurrentLinkedQueue

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

the class ConcurrentLinkedQueueTest method testAddAll5.

/**
     * Queue 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);
    ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
    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 : ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue)

Example 100 with ConcurrentLinkedQueue

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

the class ConcurrentLinkedQueueTest method testRetainAll.

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

Aggregations

ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)236 Test (org.junit.Test)102 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)56 Watermark (org.apache.flink.streaming.api.watermark.Watermark)52 KeyedOneInputStreamOperatorTestHarness (org.apache.flink.streaming.util.KeyedOneInputStreamOperatorTestHarness)43 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)40 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)40 CountDownLatch (java.util.concurrent.CountDownLatch)37 ArrayList (java.util.ArrayList)31 TimeWindow (org.apache.flink.streaming.api.windowing.windows.TimeWindow)28 ListStateDescriptor (org.apache.flink.api.common.state.ListStateDescriptor)18 ReducingStateDescriptor (org.apache.flink.api.common.state.ReducingStateDescriptor)17 IOException (java.io.IOException)15 Tuple3 (org.apache.flink.api.java.tuple.Tuple3)15 StreamRecord (org.apache.flink.streaming.runtime.streamrecord.StreamRecord)14 ExecutionException (java.util.concurrent.ExecutionException)13 ExecutorService (java.util.concurrent.ExecutorService)13 Map (java.util.Map)12 OperatorStateHandles (org.apache.flink.streaming.runtime.tasks.OperatorStateHandles)12 Iterator (java.util.Iterator)11