use of java.util.concurrent.BlockingQueue in project mapdb by jankotek.
the class ArrayBlockingQueueTest method testRemainingCapacity.
/**
* remainingCapacity decreases on add, increases on remove
*/
public void testRemainingCapacity() {
BlockingQueue q = populatedQueue(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertEquals(i, q.remainingCapacity());
assertEquals(SIZE, q.size() + q.remainingCapacity());
assertEquals(i, q.remove());
}
for (int i = 0; i < SIZE; ++i) {
assertEquals(SIZE - i, q.remainingCapacity());
assertEquals(SIZE, q.size() + q.remainingCapacity());
assertTrue(q.add(i));
}
}
use of java.util.concurrent.BlockingQueue in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testRemainingCapacity.
/**
* remainingCapacity decreases on add, increases on remove
*/
public void testRemainingCapacity() {
BlockingQueue q = populatedDeque(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertEquals(i, q.remainingCapacity());
assertEquals(SIZE, q.size() + q.remainingCapacity());
assertEquals(i, q.remove());
}
for (int i = 0; i < SIZE; ++i) {
assertEquals(SIZE - i, q.remainingCapacity());
assertEquals(SIZE, q.size() + q.remainingCapacity());
assertTrue(q.add(i));
}
}
use of java.util.concurrent.BlockingQueue in project mapdb by jankotek.
the class LinkedBlockingQueueTest method testRemainingCapacity.
/**
* remainingCapacity decreases on add, increases on remove
*/
public void testRemainingCapacity() {
BlockingQueue q = populatedQueue(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertEquals(i, q.remainingCapacity());
assertEquals(SIZE, q.size() + q.remainingCapacity());
assertEquals(i, q.remove());
}
for (int i = 0; i < SIZE; ++i) {
assertEquals(SIZE - i, q.remainingCapacity());
assertEquals(SIZE, q.size() + q.remainingCapacity());
assertTrue(q.add(i));
}
}
use of java.util.concurrent.BlockingQueue in project j2objc by google.
the class BlockingQueueTest method testDrainToNullN.
/**
* drainTo(null, n) throws NullPointerException
*/
public void testDrainToNullN() {
final BlockingQueue q = emptyCollection();
try {
q.drainTo(null, 0);
shouldThrow();
} catch (NullPointerException success) {
}
}
use of java.util.concurrent.BlockingQueue in project j2objc by google.
the class BlockingQueueTest method testTimedPollFromEmptyAfterInterrupt.
/**
* timed poll() throws InterruptedException immediately if
* interrupted before waiting
*/
public void testTimedPollFromEmptyAfterInterrupt() {
final BlockingQueue q = emptyCollection();
Thread t = newStartedThread(new CheckedRunnable() {
public void realRun() {
Thread.currentThread().interrupt();
try {
q.poll(2 * LONG_DELAY_MS, MILLISECONDS);
shouldThrow();
} catch (InterruptedException success) {
}
assertFalse(Thread.interrupted());
}
});
awaitTermination(t);
}
Aggregations