--- jsr166/src/test/tck/LinkedTransferQueueTest.java 2009/11/21 19:45:16 1.17 +++ jsr166/src/test/tck/LinkedTransferQueueTest.java 2009/11/22 18:57:17 1.20 @@ -284,14 +284,19 @@ public class LinkedTransferQueueTest ext */ public void testBlockingTake() throws InterruptedException { final LinkedTransferQueue q = populatedQueue(SIZE); - Thread t = newStartedThread(new CheckedInterruptedRunnable() { - void realRun() throws InterruptedException { + Thread t = new Thread(new CheckedRunnable() { + public void realRun() throws InterruptedException { for (int i = 0; i < SIZE; ++i) { - threadAssertEquals(i, (int) q.take()); + assertEquals(i, (int) q.take()); } - q.take(); + try { + q.take(); + shouldThrow(); + } catch (InterruptedException success) {} }}); - Thread.sleep(SMALL_DELAY_MS); + + t.start(); + Thread.sleep(SHORT_DELAY_MS); t.interrupt(); t.join(); checkEmpty(q); @@ -369,12 +374,17 @@ public class LinkedTransferQueueTest ext */ public void testTimedPollWithOffer() throws InterruptedException { final LinkedTransferQueue q = new LinkedTransferQueue(); - Thread t = newStartedThread(new CheckedInterruptedRunnable() { + Thread t = new Thread(new CheckedRunnable() { void realRun() throws InterruptedException { - threadAssertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); - q.poll(LONG_DELAY_MS, MILLISECONDS); - q.poll(LONG_DELAY_MS, MILLISECONDS); + assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); + assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS)); + try { + q.poll(LONG_DELAY_MS, MILLISECONDS); + shouldThrow(); + } catch (InterruptedException success) {} }}); + + t.start(); Thread.sleep(SMALL_DELAY_MS); assertTrue(q.offer(zero, SHORT_DELAY_MS, MILLISECONDS)); t.interrupt(); @@ -560,8 +570,8 @@ public class LinkedTransferQueueTest ext * toArray(null) throws NullPointerException */ public void testToArray_BadArg() { + LinkedTransferQueue q = populatedQueue(SIZE); try { - LinkedTransferQueue q = populatedQueue(SIZE); Object o[] = q.toArray(null); shouldThrow(); } catch (NullPointerException success) {} @@ -571,8 +581,8 @@ public class LinkedTransferQueueTest ext * toArray(incompatible array type) throws CCE */ public void testToArray1_BadArg() { + LinkedTransferQueue q = populatedQueue(SIZE); try { - LinkedTransferQueue q = populatedQueue(SIZE); Object o[] = q.toArray(new String[10]); shouldThrow(); } catch (ArrayStoreException success) {}