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

Comparing jsr166/src/test/tck/PriorityBlockingQueueTest.java (file contents):
Revision 1.16 by jsr166, Sat Nov 21 02:07:27 2009 UTC vs.
Revision 1.19 by jsr166, Sat Nov 21 10:25:05 2009 UTC

# Line 9 | Line 9
9   import junit.framework.*;
10   import java.util.*;
11   import java.util.concurrent.*;
12 + import static java.util.concurrent.TimeUnit.MILLISECONDS;
13   import java.io.*;
14  
15   public class PriorityBlockingQueueTest extends JSR166TestCase {
# Line 57 | Line 58 | public class PriorityBlockingQueueTest e
58      }
59  
60      /**
61 <     * Constructor throws IAE if  capacity argument nonpositive
61 >     * Constructor throws IAE if capacity argument nonpositive
62       */
63      public void testConstructor2() {
64          try {
# Line 327 | Line 328 | public class PriorityBlockingQueueTest e
328       */
329      public void testTimedOffer() throws InterruptedException {
330          final PriorityBlockingQueue q = new PriorityBlockingQueue(2);
331 <        Thread t = new Thread(new Runnable() {
332 <                public void run() {
333 <                    try {
334 <                        q.put(new Integer(0));
335 <                        q.put(new Integer(0));
336 <                        threadAssertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
337 <                        threadAssertTrue(q.offer(new Integer(0), LONG_DELAY_MS, TimeUnit.MILLISECONDS));
337 <                    } finally { }
338 <                }
339 <            });
331 >        Thread t = new Thread(new CheckedRunnable() {
332 >            public void realRun() {
333 >                q.put(new Integer(0));
334 >                q.put(new Integer(0));
335 >                threadAssertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, MILLISECONDS));
336 >                threadAssertTrue(q.offer(new Integer(0), LONG_DELAY_MS, MILLISECONDS));
337 >            }});
338  
339          t.start();
340          Thread.sleep(SMALL_DELAY_MS);
# Line 407 | Line 405 | public class PriorityBlockingQueueTest e
405      public void testTimedPoll0() throws InterruptedException {
406          PriorityBlockingQueue q = populatedQueue(SIZE);
407          for (int i = 0; i < SIZE; ++i) {
408 <            assertEquals(i, ((Integer)q.poll(0, TimeUnit.MILLISECONDS)).intValue());
408 >            assertEquals(i, ((Integer)q.poll(0, MILLISECONDS)).intValue());
409          }
410 <        assertNull(q.poll(0, TimeUnit.MILLISECONDS));
410 >        assertNull(q.poll(0, MILLISECONDS));
411      }
412  
413      /**
# Line 418 | Line 416 | public class PriorityBlockingQueueTest e
416      public void testTimedPoll() throws InterruptedException {
417          PriorityBlockingQueue q = populatedQueue(SIZE);
418          for (int i = 0; i < SIZE; ++i) {
419 <            assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue());
419 >            assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, MILLISECONDS)).intValue());
420          }
421 <        assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
421 >        assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
422      }
423  
424      /**
# Line 432 | Line 430 | public class PriorityBlockingQueueTest e
430              public void realRun() throws InterruptedException {
431                  PriorityBlockingQueue q = populatedQueue(SIZE);
432                  for (int i = 0; i < SIZE; ++i) {
433 <                    threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue());
433 >                    assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, MILLISECONDS)).intValue());
434                  }
435                  try {
436 <                    q.poll(SMALL_DELAY_MS, TimeUnit.MILLISECONDS);
437 <                    threadShouldThrow();
436 >                    q.poll(LONG_DELAY_MS, MILLISECONDS);
437 >                    shouldThrow();
438                  } catch (InterruptedException success) {}
439              }});
440  
# Line 454 | Line 452 | public class PriorityBlockingQueueTest e
452          final PriorityBlockingQueue q = new PriorityBlockingQueue(2);
453          Thread t = new Thread(new CheckedRunnable() {
454              public void realRun() throws InterruptedException {
455 <                threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
456 <                threadAssertEquals(0, q.poll(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS));
455 >                assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
456 >                assertEquals(0, q.poll(MEDIUM_DELAY_MS, MILLISECONDS));
457                  try {
458 <                    q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
458 >                    q.poll(LONG_DELAY_MS, MILLISECONDS);
459                      threadShouldThrow();
460                  } catch (InterruptedException success) {}
461              }});
462  
463          t.start();
464          Thread.sleep(SMALL_DELAY_MS);
465 <        assertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
465 >        assertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, MILLISECONDS));
466          t.interrupt();
467          t.join();
468      }
# Line 646 | Line 644 | public class PriorityBlockingQueueTest e
644              PriorityBlockingQueue q = populatedQueue(SIZE);
645              Object o[] = q.toArray(new String[10] );
646              shouldThrow();
647 <        } catch (ArrayStoreException  success) {}
647 >        } catch (ArrayStoreException success) {}
648      }
649  
650      /**
# Line 703 | Line 701 | public class PriorityBlockingQueueTest e
701          executor.execute(new CheckedRunnable() {
702              public void realRun() throws InterruptedException {
703                  threadAssertNull(q.poll());
704 <                threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS));
704 >                threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, MILLISECONDS));
705                  threadAssertTrue(q.isEmpty());
706              }});
707  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines