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.34 by dl, Wed Sep 29 12:33:48 2010 UTC vs.
Revision 1.35 by jsr166, Wed Oct 6 07:49:22 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 +
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 <                    assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
497 <                    assertSame(pdelay, q.poll(LONG_DELAY_MS, MILLISECONDS));
498 <                    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      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines