use of java.util.concurrent.ConcurrentLinkedQueue in project mapdb by jankotek.
the class ConcurrentLinkedQueueTest method testIteratorOrdering.
/**
* iterator ordering is FIFO
*/
public void testIteratorOrdering() {
final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
q.add(one);
q.add(two);
q.add(three);
int k = 0;
for (Iterator it = q.iterator(); it.hasNext(); ) {
assertEquals(++k, it.next());
}
assertEquals(3, k);
}
use of java.util.concurrent.ConcurrentLinkedQueue in project mapdb by jankotek.
the class ConcurrentLinkedQueueTest method testToArray1_BadArg.
/**
* toArray(incompatible array type) throws ArrayStoreException
*/
public void testToArray1_BadArg() {
ConcurrentLinkedQueue q = populatedQueue(SIZE);
try {
q.toArray(new String[10]);
shouldThrow();
} catch (ArrayStoreException success) {
}
}
use of java.util.concurrent.ConcurrentLinkedQueue in project mapdb by jankotek.
the class ConcurrentLinkedQueueTest method testOfferNull.
/**
* offer(null) throws NPE
*/
public void testOfferNull() {
ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
try {
q.offer(null);
shouldThrow();
} catch (NullPointerException success) {
}
}
use of java.util.concurrent.ConcurrentLinkedQueue in project mapdb by jankotek.
the class ConcurrentLinkedQueueTest method testAddAll5.
/**
* Queue contains all elements, in traversal order, of successful addAll
*/
public void testAddAll5() {
Integer[] empty = new Integer[0];
Integer[] ints = new Integer[SIZE];
for (int i = 0; i < SIZE; ++i) ints[i] = new Integer(i);
ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
assertFalse(q.addAll(Arrays.asList(empty)));
assertTrue(q.addAll(Arrays.asList(ints)));
for (int i = 0; i < SIZE; ++i) assertEquals(ints[i], q.poll());
}
use of java.util.concurrent.ConcurrentLinkedQueue in project mapdb by jankotek.
the class ConcurrentLinkedQueueTest method testConstructor6.
/**
* Queue contains all elements of collection used to initialize
*/
public void testConstructor6() {
Integer[] ints = new Integer[SIZE];
for (int i = 0; i < SIZE; ++i) ints[i] = new Integer(i);
ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(Arrays.asList(ints));
for (int i = 0; i < SIZE; ++i) assertEquals(ints[i], q.poll());
}
Aggregations