use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testContains.
/**
* contains(x) reports true when elements added but not yet removed
*/
public void testContains() {
LinkedBlockingDeque q = populatedDeque(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertTrue(q.contains(new Integer(i)));
q.poll();
assertFalse(q.contains(new Integer(i)));
}
}
use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testPollFirst.
/**
* pollFirst succeeds unless empty
*/
public void testPollFirst() {
LinkedBlockingDeque q = populatedDeque(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertEquals(i, q.pollFirst());
}
assertNull(q.pollFirst());
}
use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testTimedPoll0.
/**
* timed poll with zero timeout succeeds when non-empty, else times out
*/
public void testTimedPoll0() throws InterruptedException {
LinkedBlockingDeque q = populatedDeque(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertEquals(i, q.poll(0, MILLISECONDS));
}
assertNull(q.poll(0, MILLISECONDS));
}
use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testTakeLastFromEmptyAfterInterrupt.
/**
* takeLast() throws InterruptedException immediately if interrupted
* before waiting
*/
public void testTakeLastFromEmptyAfterInterrupt() {
final BlockingDeque q = new LinkedBlockingDeque();
Thread t = newStartedThread(new CheckedRunnable() {
public void realRun() {
Thread.currentThread().interrupt();
try {
q.takeLast();
shouldThrow();
} catch (InterruptedException success) {
}
assertFalse(Thread.interrupted());
}
});
awaitTermination(t);
}
use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testRemove.
/**
* remove removes next element, or throws NSEE if empty
*/
public void testRemove() {
LinkedBlockingDeque q = populatedDeque(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertEquals(i, q.remove());
}
try {
q.remove();
shouldThrow();
} catch (NoSuchElementException success) {
}
}
Aggregations