use of java.util.concurrent.SynchronousQueue in project j2objc by google.
the class SynchronousQueueTest method testRemove.
public void testRemove(boolean fair) {
final SynchronousQueue q = new SynchronousQueue(fair);
try {
q.remove();
shouldThrow();
} catch (NoSuchElementException success) {
}
}
use of java.util.concurrent.SynchronousQueue in project j2objc by google.
the class SynchronousQueueTest method testRemoveAll.
public void testRemoveAll(boolean fair) {
final SynchronousQueue q = new SynchronousQueue(fair);
Integer[] empty = new Integer[0];
assertFalse(q.removeAll(Arrays.asList(empty)));
Integer[] ints = new Integer[1];
ints[0] = zero;
assertFalse(q.containsAll(Arrays.asList(ints)));
}
use of java.util.concurrent.SynchronousQueue in project j2objc by google.
the class SynchronousQueueTest method testTimedPollWithOffer.
public void testTimedPollWithOffer(boolean fair) {
final SynchronousQueue q = new SynchronousQueue(fair);
final CountDownLatch pleaseOffer = new CountDownLatch(1);
final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
Thread t = newStartedThread(new CheckedRunnable() {
public void realRun() throws InterruptedException {
long startTime = System.nanoTime();
assertNull(q.poll(timeoutMillis(), MILLISECONDS));
assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
pleaseOffer.countDown();
startTime = System.nanoTime();
assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS));
Thread.currentThread().interrupt();
try {
q.poll(LONG_DELAY_MS, MILLISECONDS);
shouldThrow();
} catch (InterruptedException success) {
}
assertFalse(Thread.interrupted());
pleaseInterrupt.countDown();
try {
q.poll(LONG_DELAY_MS, MILLISECONDS);
shouldThrow();
} catch (InterruptedException success) {
}
assertFalse(Thread.interrupted());
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
}
});
await(pleaseOffer);
long startTime = System.nanoTime();
try {
assertTrue(q.offer(zero, LONG_DELAY_MS, MILLISECONDS));
} catch (InterruptedException e) {
threadUnexpectedException(e);
}
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
await(pleaseInterrupt);
assertThreadStaysAlive(t);
t.interrupt();
awaitTermination(t);
}
use of java.util.concurrent.SynchronousQueue in project j2objc by google.
the class SynchronousQueueTest method testToArray.
public void testToArray(boolean fair) {
final SynchronousQueue q = new SynchronousQueue(fair);
Object[] o = q.toArray();
assertEquals(0, o.length);
}
use of java.util.concurrent.SynchronousQueue in project j2objc by google.
the class SynchronousQueueTest method testToArray_null.
public void testToArray_null(boolean fair) {
final SynchronousQueue q = new SynchronousQueue(fair);
try {
Object[] o = q.toArray(null);
shouldThrow();
} catch (NullPointerException success) {
}
}
Aggregations