--- jsr166/src/test/tck/DelayQueueTest.java 2017/03/11 18:20:47 1.82 +++ jsr166/src/test/tck/DelayQueueTest.java 2017/05/29 22:44:26 1.88 @@ -234,7 +234,7 @@ public class DelayQueueTest extends JSR1 } /** - * addAll(this) throws IAE + * addAll(this) throws IllegalArgumentException */ public void testAddAllSelf() { DelayQueue q = populatedQueue(SIZE); @@ -338,9 +338,8 @@ public class DelayQueueTest extends JSR1 final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { - for (int i = 0; i < SIZE; ++i) { + for (int i = 0; i < SIZE; i++) assertEquals(new PDelay(i), ((PDelay)q.take())); - } Thread.currentThread().interrupt(); try { @@ -358,7 +357,7 @@ public class DelayQueueTest extends JSR1 }}); await(pleaseInterrupt); - assertThreadStaysAlive(t); + assertThreadBlocks(t, Thread.State.WAITING); t.interrupt(); awaitTermination(t); } @@ -411,10 +410,9 @@ public class DelayQueueTest extends JSR1 Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { long startTime = System.nanoTime(); - for (int i = 0; i < SIZE; ++i) { + for (int i = 0; i < SIZE; i++) assertEquals(new PDelay(i), ((PDelay)q.poll(LONG_DELAY_MS, MILLISECONDS))); - } Thread.currentThread().interrupt(); try { @@ -429,11 +427,12 @@ public class DelayQueueTest extends JSR1 shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); + assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); }}); await(pleaseInterrupt); - assertThreadStaysAlive(t); + assertThreadBlocks(t, Thread.State.TIMED_WAITING); t.interrupt(); awaitTermination(t); checkEmpty(q); @@ -714,7 +713,9 @@ public class DelayQueueTest extends JSR1 public void testTimedPollDelayed() throws InterruptedException { DelayQueue q = new DelayQueue(); q.add(new NanoDelay(LONG_DELAY_MS * 1000000L)); + long startTime = System.nanoTime(); assertNull(q.poll(timeoutMillis(), MILLISECONDS)); + assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); } /**