Search in sources :

Example 91 with ConcurrentLinkedQueue

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

the class ConcurrentLinkedQueueTest method testToArray.

/**
     * toArray contains all elements in FIFO order
     */
public void testToArray() {
    ConcurrentLinkedQueue q = populatedQueue(SIZE);
    Object[] o = q.toArray();
    for (int i = 0; i < o.length; i++) assertSame(o[i], q.poll());
}
Also used : ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue)

Example 92 with ConcurrentLinkedQueue

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

the class ConcurrentLinkedQueueTest method testIteratorRemove.

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

Example 93 with ConcurrentLinkedQueue

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

the class ConcurrentLinkedQueueTest method testToArray_NullArg.

/**
     * toArray(null) throws NullPointerException
     */
public void testToArray_NullArg() {
    ConcurrentLinkedQueue q = populatedQueue(SIZE);
    try {
        q.toArray(null);
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue)

Example 94 with ConcurrentLinkedQueue

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

the class ConcurrentLinkedQueueTest method testElement.

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

Example 95 with ConcurrentLinkedQueue

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

the class ConcurrentLinkedQueueTest method testRemoveAll.

/**
     * removeAll(c) removes only those elements of c and reports true if changed
     */
public void testRemoveAll() {
    for (int i = 1; i < SIZE; ++i) {
        ConcurrentLinkedQueue q = populatedQueue(SIZE);
        ConcurrentLinkedQueue p = populatedQueue(i);
        assertTrue(q.removeAll(p));
        assertEquals(SIZE - i, q.size());
        for (int j = 0; j < i; ++j) {
            Integer x = (Integer) (p.remove());
            assertFalse(q.contains(x));
        }
    }
}
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