use of java.util.concurrent.BlockingQueue in project HugeCollections-OLD by peter-lawrey.
the class SharedJSR166TestCase method testRemoveAll.
/**
* removeAll(c) removes only those elements of c and reports true if changed
*/
@Test
public void testRemoveAll() throws IOException {
for (int i = 1; i < SIZE; ++i) {
BlockingQueue<Integer> q = populatedQueue(SIZE);
BlockingQueue p = populatedQueue(i);
assertTrue(q.removeAll(p));
assertEquals(SIZE - i, q.size());
for (int j = 0; j < i; ++j) {
Integer I = (Integer) (p.remove());
assertFalse(q.contains(I));
}
}
}
use of java.util.concurrent.BlockingQueue in project HugeCollections-OLD by peter-lawrey.
the class SharedJSR166TestCase method testRetainAll.
/**
* retainAll(c) retains only those elements of c and reports true if changed
*/
@Test
public void testRetainAll() throws IOException {
BlockingQueue q = populatedQueue(SIZE);
BlockingQueue 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();
}
}
use of java.util.concurrent.BlockingQueue in project HugeCollections-OLD by peter-lawrey.
the class LocalJSR166TestCase method testIteratorRemove.
/**
* iterator.remove removes current element
*/
@Ignore
@Test
public void testIteratorRemove() {
final BlockingQueue q = new LocalConcurrentBlockingObjectQueue(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.BlockingQueue in project HugeCollections-OLD by peter-lawrey.
the class LocalJSR166TestCase method testTimedPoll0.
/**
* timed poll with zero timeout succeeds when non-empty, else times out
*/
@Test
public void testTimedPoll0() throws InterruptedException {
BlockingQueue q = populatedQueue(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertEquals(i, q.poll(0, MILLISECONDS));
}
assertNull(q.poll(0, MILLISECONDS));
checkEmpty(q);
}
use of java.util.concurrent.BlockingQueue in project HugeCollections-OLD by peter-lawrey.
the class LocalJSR166TestCase method testAddAll4.
/**
* addAll throws ISE if not enough room
*/
@Test
public void testAddAll4() {
try {
BlockingQueue q = new LocalConcurrentBlockingObjectQueue(1);
Integer[] ints = new Integer[SIZE];
for (int i = 0; i < SIZE; ++i) ints[i] = new Integer(i);
q.addAll(Arrays.asList(ints));
shouldThrow();
} catch (IllegalStateException success) {
}
}
Aggregations