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.18 by jsr166, Sat Nov 21 02:07:26 2009 UTC vs.
Revision 1.19 by jsr166, Sat Nov 21 02:33:20 2009 UTC

# Line 8 | Line 8
8  
9   import junit.framework.*;
10   import java.util.*;
11 + import static java.util.concurrent.TimeUnit.MILLISECONDS;
12   import java.util.concurrent.*;
13  
14   public class DelayQueueTest extends JSR166TestCase {
# Line 407 | Line 408 | public class DelayQueueTest extends JSR1
408                      try {
409                          q.put(new PDelay(0));
410                          q.put(new PDelay(0));
411 <                        threadAssertTrue(q.offer(new PDelay(0), SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
412 <                        threadAssertTrue(q.offer(new PDelay(0), LONG_DELAY_MS, TimeUnit.MILLISECONDS));
411 >                        threadAssertTrue(q.offer(new PDelay(0), SHORT_DELAY_MS, MILLISECONDS));
412 >                        threadAssertTrue(q.offer(new PDelay(0), LONG_DELAY_MS, MILLISECONDS));
413                      } finally { }
414                  }
415              });
# Line 506 | Line 507 | public class DelayQueueTest extends JSR1
507          try {
508              DelayQueue q = populatedQueue(SIZE);
509              for (int i = 0; i < SIZE; ++i) {
510 <                assertEquals(new PDelay(i), ((PDelay)q.poll(0, TimeUnit.MILLISECONDS)));
510 >                assertEquals(new PDelay(i), ((PDelay)q.poll(0, MILLISECONDS)));
511              }
512 <            assertNull(q.poll(0, TimeUnit.MILLISECONDS));
512 >            assertNull(q.poll(0, MILLISECONDS));
513          } catch (InterruptedException e) {
514              unexpectedException();
515          }
# Line 521 | Line 522 | public class DelayQueueTest extends JSR1
522          try {
523              DelayQueue q = populatedQueue(SIZE);
524              for (int i = 0; i < SIZE; ++i) {
525 <                assertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)));
525 >                assertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, MILLISECONDS)));
526              }
527 <            assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
527 >            assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
528          } catch (InterruptedException e) {
529              unexpectedException();
530          }
# Line 539 | Line 540 | public class DelayQueueTest extends JSR1
540                      try {
541                          DelayQueue q = populatedQueue(SIZE);
542                          for (int i = 0; i < SIZE; ++i) {
543 <                            threadAssertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)));
543 >                            threadAssertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, MILLISECONDS)));
544                          }
545 <                        threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
545 >                        threadAssertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
546                      } catch (InterruptedException success) {
547                      }
548                  }});
# Line 565 | Line 566 | public class DelayQueueTest extends JSR1
566          Thread t = new Thread(new Runnable() {
567                  public void run() {
568                      try {
569 <                        threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
570 <                        q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
571 <                        q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
569 >                        threadAssertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
570 >                        q.poll(LONG_DELAY_MS, MILLISECONDS);
571 >                        q.poll(LONG_DELAY_MS, MILLISECONDS);
572                          threadFail("Should block");
573                      } catch (InterruptedException success) { }
574                  }
# Line 575 | Line 576 | public class DelayQueueTest extends JSR1
576          try {
577              t.start();
578              Thread.sleep(SMALL_DELAY_MS);
579 <            assertTrue(q.offer(new PDelay(0), SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
579 >            assertTrue(q.offer(new PDelay(0), SHORT_DELAY_MS, MILLISECONDS));
580              t.interrupt();
581              t.join();
582          } catch (Exception e) {
# Line 831 | Line 832 | public class DelayQueueTest extends JSR1
832              public void run() {
833                  threadAssertNull(q.poll());
834                  try {
835 <                    threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS));
835 >                    threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, MILLISECONDS));
836                      threadAssertTrue(q.isEmpty());
837                  }
838                  catch (InterruptedException e) {
# Line 911 | Line 912 | public class DelayQueueTest extends JSR1
912          DelayQueue q = new DelayQueue();
913          q.add(new NanoDelay(LONG_DELAY_MS * 1000000L));
914          try {
915 <            assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
915 >            assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
916          } catch (Exception ex) {
917              unexpectedException();
918          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines