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());
}
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());
}
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));
}
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) {
}
}
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));
}
}
}
Aggregations