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

Comparing jsr166/src/test/tck/ArrayBlockingQueueTest.java (file contents):
Revision 1.15 by jsr166, Sat Nov 21 02:07:26 2009 UTC vs.
Revision 1.16 by jsr166, Sat Nov 21 02:33:20 2009 UTC

# Line 10 | Line 10
10   import junit.framework.*;
11   import java.util.*;
12   import java.util.concurrent.*;
13 + import static java.util.concurrent.TimeUnit.MILLISECONDS;
14   import java.io.*;
15  
16   public class ArrayBlockingQueueTest extends JSR166TestCase {
# Line 389 | Line 390 | public class ArrayBlockingQueueTest exte
390                      try {
391                          q.put(new Object());
392                          q.put(new Object());
393 <                        threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS/2, TimeUnit.MILLISECONDS));
394 <                        q.offer(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS);
393 >                        threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS/2, MILLISECONDS));
394 >                        q.offer(new Object(), LONG_DELAY_MS, MILLISECONDS);
395                          threadShouldThrow();
396                      } catch (InterruptedException success) {}
397                  }
# Line 489 | Line 490 | public class ArrayBlockingQueueTest exte
490          try {
491              ArrayBlockingQueue q = populatedQueue(SIZE);
492              for (int i = 0; i < SIZE; ++i) {
493 <                assertEquals(i, ((Integer)q.poll(0, TimeUnit.MILLISECONDS)).intValue());
493 >                assertEquals(i, ((Integer)q.poll(0, MILLISECONDS)).intValue());
494              }
495 <            assertNull(q.poll(0, TimeUnit.MILLISECONDS));
495 >            assertNull(q.poll(0, MILLISECONDS));
496          } catch (InterruptedException e) {
497              unexpectedException();
498          }
# Line 504 | Line 505 | public class ArrayBlockingQueueTest exte
505          try {
506              ArrayBlockingQueue q = populatedQueue(SIZE);
507              for (int i = 0; i < SIZE; ++i) {
508 <                assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue());
508 >                assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, MILLISECONDS)).intValue());
509              }
510 <            assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
510 >            assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
511          } catch (InterruptedException e) {
512              unexpectedException();
513          }
# Line 522 | Line 523 | public class ArrayBlockingQueueTest exte
523                      try {
524                          ArrayBlockingQueue q = populatedQueue(SIZE);
525                          for (int i = 0; i < SIZE; ++i) {
526 <                            threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue());
526 >                            threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, MILLISECONDS)).intValue());
527                          }
528 <                        threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
528 >                        threadAssertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
529                      } catch (InterruptedException success) {
530                      }
531                  }});
# Line 548 | Line 549 | public class ArrayBlockingQueueTest exte
549          Thread t = new Thread(new Runnable() {
550                  public void run() {
551                      try {
552 <                        threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
553 <                        q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
554 <                        q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
552 >                        threadAssertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
553 >                        q.poll(LONG_DELAY_MS, MILLISECONDS);
554 >                        q.poll(LONG_DELAY_MS, MILLISECONDS);
555                          threadShouldThrow();
556                      } catch (InterruptedException success) { }
557                  }
# Line 558 | Line 559 | public class ArrayBlockingQueueTest exte
559          try {
560              t.start();
561              Thread.sleep(SMALL_DELAY_MS);
562 <            assertTrue(q.offer(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
562 >            assertTrue(q.offer(zero, SHORT_DELAY_MS, MILLISECONDS));
563              t.interrupt();
564              t.join();
565          } catch (Exception e) {
# Line 854 | Line 855 | public class ArrayBlockingQueueTest exte
855              public void run() {
856                  threadAssertFalse(q.offer(three));
857                  try {
858 <                    threadAssertTrue(q.offer(three, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS));
858 >                    threadAssertTrue(q.offer(three, MEDIUM_DELAY_MS, MILLISECONDS));
859                      threadAssertEquals(0, q.remainingCapacity());
860                  }
861                  catch (InterruptedException e) {
# Line 889 | Line 890 | public class ArrayBlockingQueueTest exte
890              public void run() {
891                  threadAssertNull(q.poll());
892                  try {
893 <                    threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS));
893 >                    threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, MILLISECONDS));
894                      threadAssertTrue(q.isEmpty());
895                  }
896                  catch (InterruptedException e) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines