--- jsr166/src/test/tck/PriorityBlockingQueueTest.java 2009/11/21 09:28:16 1.18 +++ jsr166/src/test/tck/PriorityBlockingQueueTest.java 2009/11/22 00:17:37 1.23 @@ -58,7 +58,7 @@ public class PriorityBlockingQueueTest e } /** - * Constructor throws IAE if capacity argument nonpositive + * Constructor throws IAE if capacity argument nonpositive */ public void testConstructor2() { try { @@ -332,8 +332,8 @@ public class PriorityBlockingQueueTest e public void realRun() { q.put(new Integer(0)); q.put(new Integer(0)); - threadAssertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, MILLISECONDS)); - threadAssertTrue(q.offer(new Integer(0), LONG_DELAY_MS, MILLISECONDS)); + assertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, MILLISECONDS)); + assertTrue(q.offer(new Integer(0), LONG_DELAY_MS, MILLISECONDS)); }}); t.start(); @@ -372,13 +372,16 @@ public class PriorityBlockingQueueTest e * Take removes existing elements until empty, then blocks interruptibly */ public void testBlockingTake() throws InterruptedException { - Thread t = new Thread(new CheckedInterruptedRunnable() { + final PriorityBlockingQueue q = populatedQueue(SIZE); + Thread t = new Thread(new CheckedRunnable() { public void realRun() throws InterruptedException { - PriorityBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - threadAssertEquals(i, ((Integer)q.take()).intValue()); + assertEquals(i, q.take()); } - q.take(); + try { + q.take(); + shouldThrow(); + } catch (InterruptedException success) {} }}); t.start(); @@ -433,7 +436,7 @@ public class PriorityBlockingQueueTest e assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, MILLISECONDS)).intValue()); } try { - q.poll(LONG_DELAY_MS, MILLISECONDS); + q.poll(SMALL_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (InterruptedException success) {} }}); @@ -453,16 +456,16 @@ public class PriorityBlockingQueueTest e Thread t = new Thread(new CheckedRunnable() { public void realRun() throws InterruptedException { assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); - assertEquals(0, q.poll(MEDIUM_DELAY_MS, MILLISECONDS)); + assertSame(zero, q.poll(MEDIUM_DELAY_MS, MILLISECONDS)); try { q.poll(LONG_DELAY_MS, MILLISECONDS); - threadShouldThrow(); + shouldThrow(); } catch (InterruptedException success) {} }}); t.start(); Thread.sleep(SMALL_DELAY_MS); - assertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, MILLISECONDS)); + assertTrue(q.offer(zero, SHORT_DELAY_MS, MILLISECONDS)); t.interrupt(); t.join(); } @@ -644,7 +647,7 @@ public class PriorityBlockingQueueTest e PriorityBlockingQueue q = populatedQueue(SIZE); Object o[] = q.toArray(new String[10] ); shouldThrow(); - } catch (ArrayStoreException success) {} + } catch (ArrayStoreException success) {} } /**