ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/DelayQueueTest.java
(Generate patch)

Comparing jsr166/src/test/tck/DelayQueueTest.java (file contents):
Revision 1.33 by jsr166, Thu Sep 16 00:52:49 2010 UTC vs.
Revision 1.36 by jsr166, Mon Oct 11 04:19:16 2010 UTC

# Line 484 | Line 484 | public class DelayQueueTest extends JSR1
484      }
485  
486      /**
487 <     *  timed poll before a delayed offer fails; after offer succeeds;
488 <     *  on interruption throws
487 >     * timed poll before a delayed offer fails; after offer succeeds;
488 >     * on interruption throws
489       */
490      public void testTimedPollWithOffer() throws InterruptedException {
491          final DelayQueue q = new DelayQueue();
492          final PDelay pdelay = new PDelay(0);
493 +        final CheckedBarrier barrier = new CheckedBarrier(2);
494          Thread t = new Thread(new CheckedRunnable() {
495              public void realRun() throws InterruptedException {
496                  assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
497 <                assertSame(pdelay, q.poll(LONG_DELAY_MS, MILLISECONDS));
497 >
498 >                barrier.await();
499 >                assertSame(pdelay, q.poll(MEDIUM_DELAY_MS, MILLISECONDS));
500 >
501 >                Thread.currentThread().interrupt();
502 >                try {
503 >                    q.poll(SHORT_DELAY_MS, MILLISECONDS);
504 >                    shouldThrow();
505 >                } catch (InterruptedException success) {}
506 >
507 >                barrier.await();
508                  try {
509 <                    q.poll(LONG_DELAY_MS, MILLISECONDS);
509 >                    q.poll(MEDIUM_DELAY_MS, MILLISECONDS);
510                      shouldThrow();
511                  } catch (InterruptedException success) {}
512              }});
513  
514          t.start();
515 <        Thread.sleep(SMALL_DELAY_MS);
515 >        barrier.await();
516          assertTrue(q.offer(pdelay, SHORT_DELAY_MS, MILLISECONDS));
517 +        barrier.await();
518 +        sleep(SHORT_DELAY_MS);
519          t.interrupt();
520          t.join();
521      }
# Line 775 | Line 788 | public class DelayQueueTest extends JSR1
788          for (int i = 0; i < SIZE; ++i) {
789              NanoDelay e = (NanoDelay)(q.take());
790              long tt = e.getTriggerTime();
791 <            assertTrue(tt <= System.nanoTime());
791 >            assertTrue(tt - System.nanoTime() <= 0);
792              if (i != 0)
793                  assertTrue(tt >= last);
794              last = tt;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines