use of java.util.concurrent.ArrayBlockingQueue in project mapdb by jankotek.
the class ArrayBlockingQueueTest method testContains.
/**
* contains(x) reports true when elements added but not yet removed
*/
public void testContains() {
ArrayBlockingQueue q = populatedQueue(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertTrue(q.contains(new Integer(i)));
assertEquals(i, q.poll());
assertFalse(q.contains(new Integer(i)));
}
}
use of java.util.concurrent.ArrayBlockingQueue in project mapdb by jankotek.
the class ArrayBlockingQueueTest method testClear.
/**
* clear removes all elements
*/
public void testClear() {
ArrayBlockingQueue q = populatedQueue(SIZE);
q.clear();
assertTrue(q.isEmpty());
assertEquals(0, q.size());
assertEquals(SIZE, q.remainingCapacity());
q.add(one);
assertFalse(q.isEmpty());
assertTrue(q.contains(one));
q.clear();
assertTrue(q.isEmpty());
}
use of java.util.concurrent.ArrayBlockingQueue in project mapdb by jankotek.
the class ArrayBlockingQueueTest method testPut.
/**
* all elements successfully put are contained
*/
public void testPut() throws InterruptedException {
ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE);
for (int i = 0; i < SIZE; ++i) {
Integer x = new Integer(i);
q.put(x);
assertTrue(q.contains(x));
}
assertEquals(0, q.remainingCapacity());
}
use of java.util.concurrent.ArrayBlockingQueue in project mapdb by jankotek.
the class ArrayBlockingQueueTest method testIteratorRemove.
/**
* iterator.remove removes current element
*/
public void testIteratorRemove() {
final ArrayBlockingQueue q = new ArrayBlockingQueue(3);
q.add(two);
q.add(one);
q.add(three);
Iterator it = q.iterator();
it.next();
it.remove();
it = q.iterator();
assertSame(it.next(), one);
assertSame(it.next(), three);
assertFalse(it.hasNext());
}
use of java.util.concurrent.ArrayBlockingQueue in project mapdb by jankotek.
the class ArrayBlockingQueueTest method testPoll.
/**
* poll succeeds unless empty
*/
public void testPoll() {
ArrayBlockingQueue q = populatedQueue(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertEquals(i, q.poll());
}
assertNull(q.poll());
}
Aggregations