use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testIterator.
/**
* iterator iterates through all elements
*/
public void testIterator() throws InterruptedException {
LinkedBlockingDeque q = populatedDeque(SIZE);
Iterator it = q.iterator();
int i;
for (i = 0; it.hasNext(); i++) assertTrue(q.contains(it.next()));
assertEquals(i, SIZE);
assertIteratorExhausted(it);
it = q.iterator();
for (i = 0; it.hasNext(); i++) assertEquals(it.next(), q.take());
assertEquals(i, SIZE);
assertIteratorExhausted(it);
}
use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testAddFirst.
/**
* peekFirst returns element inserted with addFirst
*/
public void testAddFirst() {
LinkedBlockingDeque q = populatedDeque(3);
q.pollLast();
q.addFirst(four);
assertSame(four, q.peekFirst());
}
use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testPutFirst.
/**
* all elements successfully putFirst are contained
*/
public void testPutFirst() throws InterruptedException {
LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
for (int i = 0; i < SIZE; ++i) {
Integer x = new Integer(i);
q.putFirst(x);
assertTrue(q.contains(x));
}
assertEquals(0, q.remainingCapacity());
}
use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testPeekFirst.
/**
* peekFirst returns next element, or null if empty
*/
public void testPeekFirst() {
LinkedBlockingDeque q = populatedDeque(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertEquals(i, q.peekFirst());
assertEquals(i, q.pollFirst());
assertTrue(q.peekFirst() == null || !q.peekFirst().equals(i));
}
assertNull(q.peekFirst());
}
use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testPush.
/**
* push succeeds if not full; throws ISE if full
*/
public void testPush() {
LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
for (int i = 0; i < SIZE; ++i) {
Integer x = new Integer(i);
q.push(x);
assertEquals(x, q.peek());
}
assertEquals(0, q.remainingCapacity());
try {
q.push(new Integer(SIZE));
shouldThrow();
} catch (IllegalStateException success) {
}
}
Aggregations