--- jsr166/src/test/tck/LinkedTransferQueueTest.java 2009/11/22 00:17:37 1.19 +++ jsr166/src/test/tck/LinkedTransferQueueTest.java 2009/12/01 06:28:43 1.23 @@ -271,7 +271,7 @@ public class LinkedTransferQueueTest ext public void testTakeFromEmpty() throws InterruptedException { final LinkedTransferQueue q = new LinkedTransferQueue(); Thread t = newStartedThread(new CheckedInterruptedRunnable() { - void realRun() throws InterruptedException { + public void realRun() throws InterruptedException { q.take(); }}); Thread.sleep(SHORT_DELAY_MS); @@ -348,11 +348,10 @@ public class LinkedTransferQueueTest ext public void testInterruptedTimedPoll() throws InterruptedException { final LinkedTransferQueue q = populatedQueue(SIZE); Thread t = newStartedThread(new CheckedRunnable() { - void realRun() throws InterruptedException { + public void realRun() throws InterruptedException { for (int i = 0; i < SIZE; ++i) { long t0 = System.nanoTime(); - threadAssertEquals(i, (int) q.poll(LONG_DELAY_MS, - MILLISECONDS)); + assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); long millisElapsed = (System.nanoTime() - t0)/(1024 * 1024); assertTrue(millisElapsed < SMALL_DELAY_MS); } @@ -375,7 +374,7 @@ public class LinkedTransferQueueTest ext public void testTimedPollWithOffer() throws InterruptedException { final LinkedTransferQueue q = new LinkedTransferQueue(); Thread t = new Thread(new CheckedRunnable() { - void realRun() throws InterruptedException { + public void realRun() throws InterruptedException { assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS)); try { @@ -462,7 +461,7 @@ public class LinkedTransferQueueTest ext assertTrue(q.remove(one)); assertTrue(q.remove(two)); assertTrue(q.add(three)); - assertTrue(q.take() == three); + assertSame(q.take(), three); } /** @@ -570,8 +569,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) {} @@ -581,8 +580,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) {} @@ -674,15 +673,14 @@ public class LinkedTransferQueueTest ext ExecutorService executor = Executors.newFixedThreadPool(2); executor.execute(new CheckedRunnable() { - void realRun() { - threadAssertTrue(q.offer(three, MEDIUM_DELAY_MS, - MILLISECONDS)); + public void realRun() { + assertTrue(q.offer(three, MEDIUM_DELAY_MS, MILLISECONDS)); }}); executor.execute(new CheckedRunnable() { - void realRun() throws InterruptedException { + public void realRun() throws InterruptedException { Thread.sleep(SMALL_DELAY_MS); - threadAssertEquals(one, q.take()); + assertEquals(one, q.take()); }}); joinPool(executor); @@ -696,15 +694,14 @@ public class LinkedTransferQueueTest ext ExecutorService executor = Executors.newFixedThreadPool(2); executor.execute(new CheckedRunnable() { - void realRun() throws InterruptedException { - threadAssertNull(q.poll()); - threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, - MILLISECONDS)); - threadAssertTrue(q.isEmpty()); + public void realRun() throws InterruptedException { + assertNull(q.poll()); + assertSame(one, q.poll(MEDIUM_DELAY_MS, MILLISECONDS)); + assertTrue(q.isEmpty()); }}); executor.execute(new CheckedRunnable() { - void realRun() throws InterruptedException { + public void realRun() throws InterruptedException { Thread.sleep(SMALL_DELAY_MS); q.put(one); }}); @@ -790,7 +787,7 @@ public class LinkedTransferQueueTest ext public void testDrainToWithActivePut() throws InterruptedException { final LinkedTransferQueue q = populatedQueue(SIZE); Thread t = newStartedThread(new CheckedRunnable() { - void realRun() { + public void realRun() { q.put(SIZE + 1); }}); ArrayList l = new ArrayList(); @@ -857,16 +854,16 @@ public class LinkedTransferQueueTest ext assertFalse(q.hasWaitingConsumer()); Thread t = newStartedThread(new CheckedRunnable() { - void realRun() throws InterruptedException { + public void realRun() throws InterruptedException { Thread.sleep(SMALL_DELAY_MS); - threadAssertTrue(q.hasWaitingConsumer()); - threadAssertEquals(q.getWaitingConsumerCount(), 1); - threadAssertTrue(q.offer(new Object())); - threadAssertFalse(q.hasWaitingConsumer()); - threadAssertEquals(q.getWaitingConsumerCount(), 0); + assertTrue(q.hasWaitingConsumer()); + assertEquals(q.getWaitingConsumerCount(), 1); + assertTrue(q.offer(one)); + assertFalse(q.hasWaitingConsumer()); + assertEquals(q.getWaitingConsumerCount(), 0); }}); - assertTrue(q.poll(LONG_DELAY_MS, MILLISECONDS) != null); + assertSame(one, q.poll(LONG_DELAY_MS, MILLISECONDS)); assertEquals(q.getWaitingConsumerCount(), 0); assertFalse(q.hasWaitingConsumer()); t.join(); @@ -892,7 +889,7 @@ public class LinkedTransferQueueTest ext = new LinkedTransferQueue(); Thread t = newStartedThread(new CheckedRunnable() { - void realRun() throws InterruptedException { + public void realRun() throws InterruptedException { q.transfer(SIZE); threadAssertTrue(q.isEmpty()); }}); @@ -912,7 +909,7 @@ public class LinkedTransferQueueTest ext = new LinkedTransferQueue(); Thread first = newStartedThread(new CheckedRunnable() { - void realRun() throws InterruptedException { + public void realRun() throws InterruptedException { Integer i = SIZE + 1; q.transfer(i); threadAssertTrue(!q.contains(i)); @@ -921,7 +918,7 @@ public class LinkedTransferQueueTest ext Thread interruptedThread = newStartedThread( new CheckedInterruptedRunnable() { - void realRun() throws InterruptedException { + public void realRun() throws InterruptedException { while (q.size() == 0) Thread.yield(); q.transfer(SIZE); @@ -947,7 +944,7 @@ public class LinkedTransferQueueTest ext final LinkedTransferQueue q = new LinkedTransferQueue(); Thread t = newStartedThread(new CheckedRunnable() { - void realRun() throws InterruptedException { + public void realRun() throws InterruptedException { q.transfer(four); threadAssertFalse(q.contains(four)); threadAssertEquals(three, q.poll()); @@ -968,7 +965,7 @@ public class LinkedTransferQueueTest ext = new LinkedTransferQueue(); Thread t = newStartedThread(new CheckedRunnable() { - void realRun() throws InterruptedException { + public void realRun() throws InterruptedException { q.transfer(SIZE); checkEmpty(q); }}); @@ -1010,7 +1007,7 @@ public class LinkedTransferQueueTest ext final LinkedTransferQueue q = new LinkedTransferQueue(); Thread t = newStartedThread(new CheckedRunnable() { - void realRun() { + public void realRun() { while (! q.hasWaitingConsumer()) Thread.yield(); threadAssertTrue(q.hasWaitingConsumer()); @@ -1019,7 +1016,7 @@ public class LinkedTransferQueueTest ext threadAssertTrue(q.tryTransfer(hotPotato)); }}); - assertTrue(q.poll(MEDIUM_DELAY_MS, MILLISECONDS) == hotPotato); + assertSame(hotPotato, q.poll(MEDIUM_DELAY_MS, MILLISECONDS)); checkEmpty(q); t.join(); } @@ -1033,7 +1030,7 @@ public class LinkedTransferQueueTest ext final LinkedTransferQueue q = new LinkedTransferQueue(); Thread t = newStartedThread(new CheckedRunnable() { - void realRun() { + public void realRun() { while (! q.hasWaitingConsumer()) Thread.yield(); threadAssertTrue(q.hasWaitingConsumer()); @@ -1042,7 +1039,7 @@ public class LinkedTransferQueueTest ext threadAssertTrue(q.tryTransfer(hotPotato)); }}); - assertTrue(q.take() == hotPotato); + assertSame(q.take(), hotPotato); checkEmpty(q); t.join(); } @@ -1055,7 +1052,7 @@ public class LinkedTransferQueueTest ext final LinkedTransferQueue q = new LinkedTransferQueue(); Thread toInterrupt = newStartedThread(new CheckedInterruptedRunnable() { - void realRun() throws InterruptedException { + public void realRun() throws InterruptedException { q.tryTransfer(new Object(), LONG_DELAY_MS, MILLISECONDS); }}); @@ -1071,10 +1068,9 @@ public class LinkedTransferQueueTest ext final LinkedTransferQueue q = new LinkedTransferQueue(); Thread t = newStartedThread(new CheckedRunnable() { - void realRun() throws InterruptedException { - threadAssertFalse - (q.tryTransfer(new Object(), - SHORT_DELAY_MS, MILLISECONDS)); + public void realRun() throws InterruptedException { + assertFalse(q.tryTransfer(new Object(), + SHORT_DELAY_MS, MILLISECONDS)); }}); Thread.sleep(SMALL_DELAY_MS); @@ -1091,10 +1087,9 @@ public class LinkedTransferQueueTest ext assertTrue(q.offer(four)); Thread t = newStartedThread(new CheckedRunnable() { - void realRun() throws InterruptedException { - threadAssertTrue(q.tryTransfer(five, - MEDIUM_DELAY_MS, MILLISECONDS)); - threadAssertTrue(q.isEmpty()); + public void realRun() throws InterruptedException { + assertTrue(q.tryTransfer(five, MEDIUM_DELAY_MS, MILLISECONDS)); + assertTrue(q.isEmpty()); }}); Thread.sleep(SHORT_DELAY_MS);