use of java.util.concurrent.ConcurrentLinkedQueue in project j2objc by google.
the class ConcurrentLinkedQueueTest method testToArray.
/**
* toArray contains all elements in FIFO order
*/
public void testToArray() {
ConcurrentLinkedQueue q = populatedQueue(SIZE);
Object[] o = q.toArray();
for (int i = 0; i < o.length; i++) assertSame(o[i], q.poll());
}
use of java.util.concurrent.ConcurrentLinkedQueue in project j2objc by google.
the class ConcurrentLinkedQueueTest method testIteratorRemove.
/**
* iterator.remove removes current element
*/
public void testIteratorRemove() {
final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
q.add(one);
q.add(two);
q.add(three);
Iterator it = q.iterator();
it.next();
it.remove();
it = q.iterator();
assertSame(it.next(), two);
assertSame(it.next(), three);
assertFalse(it.hasNext());
}
use of java.util.concurrent.ConcurrentLinkedQueue in project j2objc by google.
the class ConcurrentLinkedQueueTest method testToArray_NullArg.
/**
* toArray(null) throws NullPointerException
*/
public void testToArray_NullArg() {
ConcurrentLinkedQueue q = populatedQueue(SIZE);
try {
q.toArray(null);
shouldThrow();
} catch (NullPointerException success) {
}
}
use of java.util.concurrent.ConcurrentLinkedQueue in project j2objc by google.
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 j2objc by google.
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