--- jsr166/src/test/tck/LinkedBlockingQueueTest.java 2009/11/21 09:28:16 1.17 +++ jsr166/src/test/tck/LinkedBlockingQueueTest.java 2009/11/21 22:00:46 1.21 @@ -48,7 +48,7 @@ public class LinkedBlockingQueueTest ext } /** - * Constructor throws IAE if capacity argument nonpositive + * Constructor throws IAE if capacity argument nonpositive */ public void testConstructor2() { try { @@ -341,13 +341,16 @@ public class LinkedBlockingQueueTest ext */ public void testTimedOffer() throws InterruptedException { final LinkedBlockingQueue q = new LinkedBlockingQueue(2); - Thread t = new ThreadShouldThrow(InterruptedException.class) { + Thread t = new Thread(new CheckedRunnable() { public void realRun() throws InterruptedException { q.put(new Object()); q.put(new Object()); - threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS, MILLISECONDS)); - q.offer(new Object(), LONG_DELAY_MS, MILLISECONDS); - }}; + assertFalse(q.offer(new Object(), SHORT_DELAY_MS, MILLISECONDS)); + try { + q.offer(new Object(), LONG_DELAY_MS, MILLISECONDS); + shouldThrow(); + } catch (InterruptedException success) {} + }}); t.start(); Thread.sleep(SMALL_DELAY_MS); @@ -439,14 +442,17 @@ public class LinkedBlockingQueueTest ext * returning timeout status */ public void testInterruptedTimedPoll() throws InterruptedException { - Thread t = new ThreadShouldThrow(InterruptedException.class) { + Thread t = new Thread(new CheckedRunnable() { public void realRun() throws InterruptedException { LinkedBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, MILLISECONDS)).intValue()); + assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, MILLISECONDS)).intValue()); } - q.poll(SMALL_DELAY_MS, MILLISECONDS); - }}; + try { + q.poll(SMALL_DELAY_MS, MILLISECONDS); + shouldThrow(); + } catch (InterruptedException success) {} + }}); t.start(); Thread.sleep(SHORT_DELAY_MS); @@ -460,12 +466,15 @@ public class LinkedBlockingQueueTest ext */ public void testTimedPollWithOffer() throws InterruptedException { final LinkedBlockingQueue q = new LinkedBlockingQueue(2); - Thread t = new ThreadShouldThrow(InterruptedException.class) { + Thread t = new Thread(new CheckedRunnable() { public 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);