Search in sources :

Example 61 with ConcurrentLinkedQueue

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

the class ConcurrentLinkedQueueTest method testClear.

/**
     * clear removes all elements
     */
public void testClear() {
    ConcurrentLinkedQueue q = populatedQueue(SIZE);
    q.clear();
    assertTrue(q.isEmpty());
    assertEquals(0, q.size());
    q.add(one);
    assertFalse(q.isEmpty());
    q.clear();
    assertTrue(q.isEmpty());
}
Also used : ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue)

Example 62 with ConcurrentLinkedQueue

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

the class ConcurrentLinkedQueueTest method testEmpty.

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

Example 63 with ConcurrentLinkedQueue

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

the class ConcurrentLinkedQueueTest method testOffer.

/**
     * Offer returns true
     */
public void testOffer() {
    ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
    assertTrue(q.offer(zero));
    assertTrue(q.offer(one));
}
Also used : ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue)

Example 64 with ConcurrentLinkedQueue

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

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 65 with ConcurrentLinkedQueue

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

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