--- jsr166/src/test/tck/LinkedBlockingDequeTest.java 2009/11/16 05:30:07 1.6 +++ jsr166/src/test/tck/LinkedBlockingDequeTest.java 2009/11/21 02:33:20 1.8 @@ -7,15 +7,16 @@ import junit.framework.*; import java.util.*; import java.util.concurrent.*; +import static java.util.concurrent.TimeUnit.MILLISECONDS; import java.io.*; public class LinkedBlockingDequeTest extends JSR166TestCase { public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); + junit.textui.TestRunner.run (suite()); } public static Test suite() { - return new TestSuite(LinkedBlockingDequeTest.class); + return new TestSuite(LinkedBlockingDequeTest.class); } /** @@ -25,11 +26,11 @@ public class LinkedBlockingDequeTest ext private LinkedBlockingDeque populatedDeque(int n) { LinkedBlockingDeque q = new LinkedBlockingDeque(n); assertTrue(q.isEmpty()); - for (int i = 0; i < n; i++) - assertTrue(q.offer(new Integer(i))); + for (int i = 0; i < n; i++) + assertTrue(q.offer(new Integer(i))); assertFalse(q.isEmpty()); assertEquals(0, q.remainingCapacity()); - assertEquals(n, q.size()); + assertEquals(n, q.size()); return q; } @@ -66,7 +67,7 @@ public class LinkedBlockingDequeTest ext * offer(null) throws NPE */ public void testOfferFirstNull() { - try { + try { LinkedBlockingDeque q = new LinkedBlockingDeque(); q.offerFirst(null); shouldThrow(); @@ -100,7 +101,7 @@ public class LinkedBlockingDequeTest ext for (int i = 0; i < SIZE; ++i) { assertEquals(i, ((Integer)q.pollFirst()).intValue()); } - assertNull(q.pollFirst()); + assertNull(q.pollFirst()); } /** @@ -111,7 +112,7 @@ public class LinkedBlockingDequeTest ext for (int i = SIZE-1; i >= 0; --i) { assertEquals(i, ((Integer)q.pollLast()).intValue()); } - assertNull(q.pollLast()); + assertNull(q.pollLast()); } /** @@ -125,7 +126,7 @@ public class LinkedBlockingDequeTest ext assertTrue(q.peekFirst() == null || i != ((Integer)q.peekFirst()).intValue()); } - assertNull(q.peekFirst()); + assertNull(q.peekFirst()); } /** @@ -139,7 +140,7 @@ public class LinkedBlockingDequeTest ext assertTrue(q.peek() == null || i != ((Integer)q.peek()).intValue()); } - assertNull(q.peek()); + assertNull(q.peek()); } /** @@ -153,7 +154,7 @@ public class LinkedBlockingDequeTest ext assertTrue(q.peekLast() == null || i != ((Integer)q.peekLast()).intValue()); } - assertNull(q.peekLast()); + assertNull(q.peekLast()); } /** @@ -186,7 +187,7 @@ public class LinkedBlockingDequeTest ext shouldThrow(); } catch (NoSuchElementException success) {} - assertNull(q.peekLast()); + assertNull(q.peekLast()); } /** @@ -201,7 +202,7 @@ public class LinkedBlockingDequeTest ext q.removeFirst(); shouldThrow(); } catch (NoSuchElementException success) { - } + } } /** @@ -216,7 +217,7 @@ public class LinkedBlockingDequeTest ext q.remove(); shouldThrow(); } catch (NoSuchElementException success) { - } + } } /** @@ -255,8 +256,8 @@ public class LinkedBlockingDequeTest ext public void testAddFirst() { LinkedBlockingDeque q = populatedDeque(3); q.pollLast(); - q.addFirst(four); - assertEquals(four,q.peekFirst()); + q.addFirst(four); + assertEquals(four,q.peekFirst()); } /** @@ -265,8 +266,8 @@ public class LinkedBlockingDequeTest ext public void testAddLast() { LinkedBlockingDeque q = populatedDeque(3); q.pollLast(); - q.addLast(four); - assertEquals(four,q.peekLast()); + q.addLast(four); + assertEquals(four,q.peekLast()); } @@ -378,7 +379,7 @@ public class LinkedBlockingDequeTest ext * offer(null) throws NPE */ public void testOfferNull() { - try { + try { LinkedBlockingDeque q = new LinkedBlockingDeque(1); q.offer(null); shouldThrow(); @@ -389,7 +390,7 @@ public class LinkedBlockingDequeTest ext * add(null) throws NPE */ public void testAddNull() { - try { + try { LinkedBlockingDeque q = new LinkedBlockingDeque(1); q.add(null); shouldThrow(); @@ -400,7 +401,7 @@ public class LinkedBlockingDequeTest ext * push(null) throws NPE */ public void testPushNull() { - try { + try { LinkedBlockingDeque q = new LinkedBlockingDeque(1); q.push(null); shouldThrow(); @@ -411,7 +412,7 @@ public class LinkedBlockingDequeTest ext * push succeeds if not full; throws ISE if full */ public void testPush() { - try { + try { LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); for (int i = 0; i < SIZE; ++i) { Integer I = new Integer(i); @@ -421,7 +422,7 @@ public class LinkedBlockingDequeTest ext assertEquals(0, q.remainingCapacity()); q.push(new Integer(SIZE)); } catch (IllegalStateException success) { - } + } } /** @@ -430,8 +431,8 @@ public class LinkedBlockingDequeTest ext public void testPushWithPeek() { LinkedBlockingDeque q = populatedDeque(3); q.pollLast(); - q.push(four); - assertEquals(four,q.peekFirst()); + q.push(four); + assertEquals(four,q.peekFirst()); } @@ -447,7 +448,7 @@ public class LinkedBlockingDequeTest ext q.pop(); shouldThrow(); } catch (NoSuchElementException success) { - } + } } @@ -464,7 +465,7 @@ public class LinkedBlockingDequeTest ext * add succeeds if not full; throws ISE if full */ public void testAdd() { - try { + try { LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); for (int i = 0; i < SIZE; ++i) { assertTrue(q.add(new Integer(i))); @@ -472,7 +473,7 @@ public class LinkedBlockingDequeTest ext assertEquals(0, q.remainingCapacity()); q.add(new Integer(SIZE)); } catch (IllegalStateException success) { - } + } } /** @@ -563,15 +564,15 @@ public class LinkedBlockingDequeTest ext * put(null) throws NPE */ public void testPutNull() { - try { + try { LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); q.put(null); shouldThrow(); } catch (NullPointerException success) { - } + } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -589,7 +590,7 @@ public class LinkedBlockingDequeTest ext assertEquals(0, q.remainingCapacity()); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -619,7 +620,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -640,7 +641,7 @@ public class LinkedBlockingDequeTest ext ++added; q.put(new Object()); ++added; - threadShouldThrow(); + threadShouldThrow(); } catch (InterruptedException e) { threadAssertTrue(added >= 2); } @@ -667,9 +668,9 @@ public class LinkedBlockingDequeTest ext try { q.put(new Object()); q.put(new Object()); - threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - q.offer(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); + threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS, MILLISECONDS)); + q.offer(new Object(), LONG_DELAY_MS, MILLISECONDS); + threadShouldThrow(); } catch (InterruptedException success) {} } }); @@ -688,14 +689,14 @@ public class LinkedBlockingDequeTest ext * take retrieves elements in FIFO order */ public void testTake() { - try { + try { LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(i, ((Integer)q.take()).intValue()); } } catch (InterruptedException e) { - unexpectedException(); - } + unexpectedException(); + } } /** @@ -707,7 +708,7 @@ public class LinkedBlockingDequeTest ext public void run() { try { q.take(); - threadShouldThrow(); + threadShouldThrow(); } catch (InterruptedException success) { } } }); @@ -744,7 +745,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -757,7 +758,7 @@ public class LinkedBlockingDequeTest ext for (int i = 0; i < SIZE; ++i) { assertEquals(i, ((Integer)q.poll()).intValue()); } - assertNull(q.poll()); + assertNull(q.poll()); } /** @@ -767,12 +768,12 @@ public class LinkedBlockingDequeTest ext try { LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.poll(0, TimeUnit.MILLISECONDS)).intValue()); + assertEquals(i, ((Integer)q.poll(0, MILLISECONDS)).intValue()); } - assertNull(q.poll(0, TimeUnit.MILLISECONDS)); + assertNull(q.poll(0, MILLISECONDS)); } catch (InterruptedException e) { - unexpectedException(); - } + unexpectedException(); + } } /** @@ -782,12 +783,12 @@ public class LinkedBlockingDequeTest ext try { LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); + assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, MILLISECONDS)).intValue()); } - assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); + assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); } catch (InterruptedException e) { - unexpectedException(); - } + unexpectedException(); + } } /** @@ -800,9 +801,9 @@ public class LinkedBlockingDequeTest ext try { LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); + threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, MILLISECONDS)).intValue()); } - threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); + threadAssertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); } catch (InterruptedException success) { } }}); @@ -813,7 +814,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -826,17 +827,17 @@ public class LinkedBlockingDequeTest ext Thread t = new Thread(new Runnable() { public void run() { try { - threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); + threadAssertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); + q.poll(LONG_DELAY_MS, MILLISECONDS); + q.poll(LONG_DELAY_MS, MILLISECONDS); + threadShouldThrow(); } catch (InterruptedException success) { } } }); try { t.start(); Thread.sleep(SMALL_DELAY_MS); - assertTrue(q.offer(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); + assertTrue(q.offer(zero, SHORT_DELAY_MS, MILLISECONDS)); t.interrupt(); t.join(); } catch (Exception e) { @@ -849,15 +850,15 @@ public class LinkedBlockingDequeTest ext * putFirst(null) throws NPE */ public void testPutFirstNull() { - try { + try { LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); q.putFirst(null); shouldThrow(); } catch (NullPointerException success) { - } + } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -875,7 +876,7 @@ public class LinkedBlockingDequeTest ext assertEquals(0, q.remainingCapacity()); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -905,7 +906,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -926,7 +927,7 @@ public class LinkedBlockingDequeTest ext ++added; q.putFirst(new Object()); ++added; - threadShouldThrow(); + threadShouldThrow(); } catch (InterruptedException e) { threadAssertTrue(added >= 2); } @@ -953,9 +954,9 @@ public class LinkedBlockingDequeTest ext try { q.putFirst(new Object()); q.putFirst(new Object()); - threadAssertFalse(q.offerFirst(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - q.offerFirst(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); + threadAssertFalse(q.offerFirst(new Object(), SHORT_DELAY_MS, MILLISECONDS)); + q.offerFirst(new Object(), LONG_DELAY_MS, MILLISECONDS); + threadShouldThrow(); } catch (InterruptedException success) {} } }); @@ -974,14 +975,14 @@ public class LinkedBlockingDequeTest ext * take retrieves elements in FIFO order */ public void testTakeFirst() { - try { + try { LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(i, ((Integer)q.takeFirst()).intValue()); } } catch (InterruptedException e) { - unexpectedException(); - } + unexpectedException(); + } } /** @@ -993,7 +994,7 @@ public class LinkedBlockingDequeTest ext public void run() { try { q.takeFirst(); - threadShouldThrow(); + threadShouldThrow(); } catch (InterruptedException success) { } } }); @@ -1030,7 +1031,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -1042,12 +1043,12 @@ public class LinkedBlockingDequeTest ext try { LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.pollFirst(0, TimeUnit.MILLISECONDS)).intValue()); + assertEquals(i, ((Integer)q.pollFirst(0, MILLISECONDS)).intValue()); } - assertNull(q.pollFirst(0, TimeUnit.MILLISECONDS)); + assertNull(q.pollFirst(0, MILLISECONDS)); } catch (InterruptedException e) { - unexpectedException(); - } + unexpectedException(); + } } /** @@ -1057,12 +1058,12 @@ public class LinkedBlockingDequeTest ext try { LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.pollFirst(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); + assertEquals(i, ((Integer)q.pollFirst(SHORT_DELAY_MS, MILLISECONDS)).intValue()); } - assertNull(q.pollFirst(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); + assertNull(q.pollFirst(SHORT_DELAY_MS, MILLISECONDS)); } catch (InterruptedException e) { - unexpectedException(); - } + unexpectedException(); + } } /** @@ -1075,9 +1076,9 @@ public class LinkedBlockingDequeTest ext try { LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - threadAssertEquals(i, ((Integer)q.pollFirst(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); + threadAssertEquals(i, ((Integer)q.pollFirst(SHORT_DELAY_MS, MILLISECONDS)).intValue()); } - threadAssertNull(q.pollFirst(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); + threadAssertNull(q.pollFirst(SHORT_DELAY_MS, MILLISECONDS)); } catch (InterruptedException success) { } }}); @@ -1088,7 +1089,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -1101,17 +1102,17 @@ public class LinkedBlockingDequeTest ext Thread t = new Thread(new Runnable() { public void run() { try { - threadAssertNull(q.pollFirst(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - q.pollFirst(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - q.pollFirst(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); + threadAssertNull(q.pollFirst(SHORT_DELAY_MS, MILLISECONDS)); + q.pollFirst(LONG_DELAY_MS, MILLISECONDS); + q.pollFirst(LONG_DELAY_MS, MILLISECONDS); + threadShouldThrow(); } catch (InterruptedException success) { } } }); try { t.start(); Thread.sleep(SMALL_DELAY_MS); - assertTrue(q.offerFirst(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); + assertTrue(q.offerFirst(zero, SHORT_DELAY_MS, MILLISECONDS)); t.interrupt(); t.join(); } catch (Exception e) { @@ -1123,15 +1124,15 @@ public class LinkedBlockingDequeTest ext * putLast(null) throws NPE */ public void testPutLastNull() { - try { + try { LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); q.putLast(null); shouldThrow(); } catch (NullPointerException success) { - } + } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -1149,7 +1150,7 @@ public class LinkedBlockingDequeTest ext assertEquals(0, q.remainingCapacity()); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -1179,7 +1180,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -1200,7 +1201,7 @@ public class LinkedBlockingDequeTest ext ++added; q.putLast(new Object()); ++added; - threadShouldThrow(); + threadShouldThrow(); } catch (InterruptedException e) { threadAssertTrue(added >= 2); } @@ -1227,9 +1228,9 @@ public class LinkedBlockingDequeTest ext try { q.putLast(new Object()); q.putLast(new Object()); - threadAssertFalse(q.offerLast(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - q.offerLast(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); + threadAssertFalse(q.offerLast(new Object(), SHORT_DELAY_MS, MILLISECONDS)); + q.offerLast(new Object(), LONG_DELAY_MS, MILLISECONDS); + threadShouldThrow(); } catch (InterruptedException success) {} } }); @@ -1248,14 +1249,14 @@ public class LinkedBlockingDequeTest ext * takeLast retrieves elements in FIFO order */ public void testTakeLast() { - try { + try { LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(SIZE-i-1, ((Integer)q.takeLast()).intValue()); } } catch (InterruptedException e) { - unexpectedException(); - } + unexpectedException(); + } } /** @@ -1267,7 +1268,7 @@ public class LinkedBlockingDequeTest ext public void run() { try { q.takeLast(); - threadShouldThrow(); + threadShouldThrow(); } catch (InterruptedException success) { } } }); @@ -1304,7 +1305,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -1316,12 +1317,12 @@ public class LinkedBlockingDequeTest ext try { LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE-i-1, ((Integer)q.pollLast(0, TimeUnit.MILLISECONDS)).intValue()); + assertEquals(SIZE-i-1, ((Integer)q.pollLast(0, MILLISECONDS)).intValue()); } - assertNull(q.pollLast(0, TimeUnit.MILLISECONDS)); + assertNull(q.pollLast(0, MILLISECONDS)); } catch (InterruptedException e) { - unexpectedException(); - } + unexpectedException(); + } } /** @@ -1331,12 +1332,12 @@ public class LinkedBlockingDequeTest ext try { LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE-i-1, ((Integer)q.pollLast(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); + assertEquals(SIZE-i-1, ((Integer)q.pollLast(SHORT_DELAY_MS, MILLISECONDS)).intValue()); } - assertNull(q.pollLast(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); + assertNull(q.pollLast(SHORT_DELAY_MS, MILLISECONDS)); } catch (InterruptedException e) { - unexpectedException(); - } + unexpectedException(); + } } /** @@ -1349,9 +1350,9 @@ public class LinkedBlockingDequeTest ext try { LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - threadAssertEquals(SIZE-i-1, ((Integer)q.pollLast(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); + threadAssertEquals(SIZE-i-1, ((Integer)q.pollLast(SHORT_DELAY_MS, MILLISECONDS)).intValue()); } - threadAssertNull(q.pollLast(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); + threadAssertNull(q.pollLast(SHORT_DELAY_MS, MILLISECONDS)); } catch (InterruptedException success) { } }}); @@ -1362,7 +1363,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -1375,17 +1376,17 @@ public class LinkedBlockingDequeTest ext Thread t = new Thread(new Runnable() { public void run() { try { - threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); + threadAssertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); + q.poll(LONG_DELAY_MS, MILLISECONDS); + q.poll(LONG_DELAY_MS, MILLISECONDS); + threadShouldThrow(); } catch (InterruptedException success) { } } }); try { t.start(); Thread.sleep(SMALL_DELAY_MS); - assertTrue(q.offerLast(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); + assertTrue(q.offerLast(zero, SHORT_DELAY_MS, MILLISECONDS)); t.interrupt(); t.join(); } catch (Exception e) { @@ -1507,13 +1508,13 @@ public class LinkedBlockingDequeTest ext */ public void testToArray() { LinkedBlockingDeque q = populatedDeque(SIZE); - Object[] o = q.toArray(); - try { - for (int i = 0; i < o.length; i++) - assertEquals(o[i], q.take()); - } catch (InterruptedException e) { - unexpectedException(); - } + Object[] o = q.toArray(); + try { + for (int i = 0; i < o.length; i++) + assertEquals(o[i], q.take()); + } catch (InterruptedException e) { + unexpectedException(); + } } /** @@ -1521,36 +1522,36 @@ public class LinkedBlockingDequeTest ext */ public void testToArray2() { LinkedBlockingDeque q = populatedDeque(SIZE); - Integer[] ints = new Integer[SIZE]; - ints = (Integer[])q.toArray(ints); - try { - for (int i = 0; i < ints.length; i++) - assertEquals(ints[i], q.take()); - } catch (InterruptedException e) { - unexpectedException(); - } + Integer[] ints = new Integer[SIZE]; + ints = (Integer[])q.toArray(ints); + try { + for (int i = 0; i < ints.length; i++) + assertEquals(ints[i], q.take()); + } catch (InterruptedException e) { + unexpectedException(); + } } /** * toArray(null) throws NPE */ public void testToArray_BadArg() { - try { + try { LinkedBlockingDeque q = populatedDeque(SIZE); - Object o[] = q.toArray(null); - shouldThrow(); - } catch (NullPointerException success) {} + Object o[] = q.toArray(null); + shouldThrow(); + } catch (NullPointerException success) {} } /** * toArray with incompatible array type throws CCE */ public void testToArray1_BadArg() { - try { + try { LinkedBlockingDeque q = populatedDeque(SIZE); - Object o[] = q.toArray(new String[10] ); - shouldThrow(); - } catch (ArrayStoreException success) {} + Object o[] = q.toArray(new String[10] ); + shouldThrow(); + } catch (ArrayStoreException success) {} } @@ -1559,14 +1560,14 @@ public class LinkedBlockingDequeTest ext */ public void testIterator() { LinkedBlockingDeque q = populatedDeque(SIZE); - Iterator it = q.iterator(); - try { - while (it.hasNext()) { - assertEquals(it.next(), q.take()); - } - } catch (InterruptedException e) { - unexpectedException(); - } + Iterator it = q.iterator(); + try { + while (it.hasNext()) { + assertEquals(it.next(), q.take()); + } + } catch (InterruptedException e) { + unexpectedException(); + } } /** @@ -1633,7 +1634,7 @@ public class LinkedBlockingDequeTest ext public void testDescendingIterator() { LinkedBlockingDeque q = populatedDeque(SIZE); int i = 0; - Iterator it = q.descendingIterator(); + Iterator it = q.descendingIterator(); while (it.hasNext()) { assertTrue(q.contains(it.next())); ++i; @@ -1715,7 +1716,7 @@ public class LinkedBlockingDequeTest ext public void run() { threadAssertFalse(q.offer(three)); try { - threadAssertTrue(q.offer(three, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS)); + threadAssertTrue(q.offer(three, MEDIUM_DELAY_MS, MILLISECONDS)); threadAssertEquals(0, q.remainingCapacity()); } catch (InterruptedException e) { @@ -1749,7 +1750,7 @@ public class LinkedBlockingDequeTest ext public void run() { threadAssertNull(q.poll()); try { - threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS)); + threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, MILLISECONDS)); threadAssertTrue(q.isEmpty()); } catch (InterruptedException e) {