use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testAdd.
/**
* add succeeds if not full; throws ISE if full
*/
public void testAdd() {
LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
for (int i = 0; i < SIZE; ++i) assertTrue(q.add(new Integer(i)));
assertEquals(0, q.remainingCapacity());
try {
q.add(new Integer(SIZE));
shouldThrow();
} catch (IllegalStateException success) {
}
}
use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testFirstElement.
/**
* getFirst() returns first element, or throws NSEE if empty
*/
public void testFirstElement() {
LinkedBlockingDeque q = populatedDeque(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertEquals(i, q.getFirst());
assertEquals(i, q.pollFirst());
}
try {
q.getFirst();
shouldThrow();
} catch (NoSuchElementException success) {
}
assertNull(q.peekFirst());
}
use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testPushWithPeek.
/**
* peekFirst returns element inserted with push
*/
public void testPushWithPeek() {
LinkedBlockingDeque q = populatedDeque(3);
q.pollLast();
q.push(four);
assertSame(four, q.peekFirst());
}
use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testLastElement.
/**
* getLast() returns last element, or throws NSEE if empty
*/
public void testLastElement() {
LinkedBlockingDeque q = populatedDeque(SIZE);
for (int i = SIZE - 1; i >= 0; --i) {
assertEquals(i, q.getLast());
assertEquals(i, q.pollLast());
}
try {
q.getLast();
shouldThrow();
} catch (NoSuchElementException success) {
}
assertNull(q.peekLast());
}
use of java.util.concurrent.LinkedBlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testToArray.
/**
* toArray contains all elements in FIFO order
*/
public void testToArray() throws InterruptedException {
LinkedBlockingDeque q = populatedDeque(SIZE);
Object[] o = q.toArray();
for (int i = 0; i < o.length; i++) assertSame(o[i], q.poll());
}
Aggregations