use of java.util.concurrent.ConcurrentLinkedQueue in project j2objc by google.
the class ConcurrentLinkedQueueTest method testRemove.
/**
* remove removes next element, or throws NSEE if empty
*/
public void testRemove() {
ConcurrentLinkedQueue q = populatedQueue(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertEquals(i, q.remove());
}
try {
q.remove();
shouldThrow();
} catch (NoSuchElementException success) {
}
}
use of java.util.concurrent.ConcurrentLinkedQueue in project j2objc by google.
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 j2objc by google.
the class ConcurrentLinkedQueueTest method testSize.
/**
* size changes when elements added and removed
*/
public void testSize() {
ConcurrentLinkedQueue q = populatedQueue(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertEquals(SIZE - i, q.size());
q.remove();
}
for (int i = 0; i < SIZE; ++i) {
assertEquals(i, q.size());
q.add(new Integer(i));
}
}
use of java.util.concurrent.ConcurrentLinkedQueue in project j2objc by google.
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 j2objc by google.
the class ConcurrentLinkedQueueTest method testRetainAll.
/**
* retainAll(c) retains only those elements of c and reports true if change
*/
public void testRetainAll() {
ConcurrentLinkedQueue q = populatedQueue(SIZE);
ConcurrentLinkedQueue p = populatedQueue(SIZE);
for (int i = 0; i < SIZE; ++i) {
boolean changed = q.retainAll(p);
if (i == 0)
assertFalse(changed);
else
assertTrue(changed);
assertTrue(q.containsAll(p));
assertEquals(SIZE - i, q.size());
p.remove();
}
}
Aggregations