--- jsr166/src/test/tck/LinkedBlockingDequeTest.java 2009/11/16 04:57:10 1.5 +++ jsr166/src/test/tck/LinkedBlockingDequeTest.java 2009/11/21 02:07:26 1.7 @@ -11,11 +11,11 @@ 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 +25,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 +66,7 @@ public class LinkedBlockingDequeTest ext * offer(null) throws NPE */ public void testOfferFirstNull() { - try { + try { LinkedBlockingDeque q = new LinkedBlockingDeque(); q.offerFirst(null); shouldThrow(); @@ -100,7 +100,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 +111,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 +125,7 @@ public class LinkedBlockingDequeTest ext assertTrue(q.peekFirst() == null || i != ((Integer)q.peekFirst()).intValue()); } - assertNull(q.peekFirst()); + assertNull(q.peekFirst()); } /** @@ -139,7 +139,7 @@ public class LinkedBlockingDequeTest ext assertTrue(q.peek() == null || i != ((Integer)q.peek()).intValue()); } - assertNull(q.peek()); + assertNull(q.peek()); } /** @@ -153,7 +153,7 @@ public class LinkedBlockingDequeTest ext assertTrue(q.peekLast() == null || i != ((Integer)q.peekLast()).intValue()); } - assertNull(q.peekLast()); + assertNull(q.peekLast()); } /** @@ -186,7 +186,7 @@ public class LinkedBlockingDequeTest ext shouldThrow(); } catch (NoSuchElementException success) {} - assertNull(q.peekLast()); + assertNull(q.peekLast()); } /** @@ -200,8 +200,8 @@ public class LinkedBlockingDequeTest ext try { q.removeFirst(); shouldThrow(); - } catch (NoSuchElementException success){ - } + } catch (NoSuchElementException success) { + } } /** @@ -215,8 +215,8 @@ public class LinkedBlockingDequeTest ext try { q.remove(); shouldThrow(); - } catch (NoSuchElementException success){ - } + } catch (NoSuchElementException success) { + } } /** @@ -255,8 +255,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 +265,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 +378,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 +389,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 +400,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 +411,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); @@ -420,8 +420,8 @@ public class LinkedBlockingDequeTest ext } assertEquals(0, q.remainingCapacity()); q.push(new Integer(SIZE)); - } catch (IllegalStateException success){ - } + } catch (IllegalStateException success) { + } } /** @@ -430,8 +430,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()); } @@ -446,8 +446,8 @@ public class LinkedBlockingDequeTest ext try { q.pop(); shouldThrow(); - } catch (NoSuchElementException success){ - } + } catch (NoSuchElementException success) { + } } @@ -464,15 +464,15 @@ 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))); } assertEquals(0, q.remainingCapacity()); q.add(new Integer(SIZE)); - } catch (IllegalStateException success){ - } + } catch (IllegalStateException success) { + } } /** @@ -563,15 +563,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 (NullPointerException success) { + } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -589,7 +589,7 @@ public class LinkedBlockingDequeTest ext assertEquals(0, q.remainingCapacity()); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -608,7 +608,7 @@ public class LinkedBlockingDequeTest ext } q.put(new Integer(SIZE)); threadShouldThrow(); - } catch (InterruptedException ie){ + } catch (InterruptedException ie) { threadAssertEquals(added, SIZE); } }}); @@ -619,7 +619,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -640,8 +640,8 @@ public class LinkedBlockingDequeTest ext ++added; q.put(new Object()); ++added; - threadShouldThrow(); - } catch (InterruptedException e){ + threadShouldThrow(); + } catch (InterruptedException e) { threadAssertTrue(added >= 2); } } @@ -652,7 +652,7 @@ public class LinkedBlockingDequeTest ext q.take(); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -669,8 +669,8 @@ public class LinkedBlockingDequeTest ext q.put(new Object()); threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); q.offer(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch (InterruptedException success){} + threadShouldThrow(); + } catch (InterruptedException success) {} } }); @@ -679,7 +679,7 @@ public class LinkedBlockingDequeTest ext Thread.sleep(SMALL_DELAY_MS); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -688,14 +688,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(); - } + } catch (InterruptedException e) { + unexpectedException(); + } } /** @@ -707,8 +707,8 @@ public class LinkedBlockingDequeTest ext public void run() { try { q.take(); - threadShouldThrow(); - } catch (InterruptedException success){ } + threadShouldThrow(); + } catch (InterruptedException success) { } } }); try { @@ -716,7 +716,7 @@ public class LinkedBlockingDequeTest ext Thread.sleep(SHORT_DELAY_MS); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -734,7 +734,7 @@ public class LinkedBlockingDequeTest ext } q.take(); threadShouldThrow(); - } catch (InterruptedException success){ + } catch (InterruptedException success) { } }}); t.start(); @@ -744,7 +744,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -757,7 +757,7 @@ public class LinkedBlockingDequeTest ext for (int i = 0; i < SIZE; ++i) { assertEquals(i, ((Integer)q.poll()).intValue()); } - assertNull(q.poll()); + assertNull(q.poll()); } /** @@ -770,9 +770,9 @@ public class LinkedBlockingDequeTest ext assertEquals(i, ((Integer)q.poll(0, TimeUnit.MILLISECONDS)).intValue()); } assertNull(q.poll(0, TimeUnit.MILLISECONDS)); - } catch (InterruptedException e){ - unexpectedException(); - } + } catch (InterruptedException e) { + unexpectedException(); + } } /** @@ -785,9 +785,9 @@ public class LinkedBlockingDequeTest ext assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); } assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (InterruptedException e){ - unexpectedException(); - } + } catch (InterruptedException e) { + unexpectedException(); + } } /** @@ -803,7 +803,7 @@ public class LinkedBlockingDequeTest ext threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); } threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (InterruptedException success){ + } catch (InterruptedException success) { } }}); t.start(); @@ -813,7 +813,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -829,7 +829,7 @@ public class LinkedBlockingDequeTest ext threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); + threadShouldThrow(); } catch (InterruptedException success) { } } }); @@ -839,7 +839,7 @@ public class LinkedBlockingDequeTest ext assertTrue(q.offer(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -849,15 +849,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 (NullPointerException success) { + } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -875,7 +875,7 @@ public class LinkedBlockingDequeTest ext assertEquals(0, q.remainingCapacity()); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -894,7 +894,7 @@ public class LinkedBlockingDequeTest ext } q.putFirst(new Integer(SIZE)); threadShouldThrow(); - } catch (InterruptedException ie){ + } catch (InterruptedException ie) { threadAssertEquals(added, SIZE); } }}); @@ -905,7 +905,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -926,8 +926,8 @@ public class LinkedBlockingDequeTest ext ++added; q.putFirst(new Object()); ++added; - threadShouldThrow(); - } catch (InterruptedException e){ + threadShouldThrow(); + } catch (InterruptedException e) { threadAssertTrue(added >= 2); } } @@ -938,7 +938,7 @@ public class LinkedBlockingDequeTest ext q.take(); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -955,8 +955,8 @@ public class LinkedBlockingDequeTest ext q.putFirst(new Object()); threadAssertFalse(q.offerFirst(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); q.offerFirst(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch (InterruptedException success){} + threadShouldThrow(); + } catch (InterruptedException success) {} } }); @@ -965,7 +965,7 @@ public class LinkedBlockingDequeTest ext Thread.sleep(SMALL_DELAY_MS); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -974,14 +974,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(); - } + } catch (InterruptedException e) { + unexpectedException(); + } } /** @@ -993,8 +993,8 @@ public class LinkedBlockingDequeTest ext public void run() { try { q.takeFirst(); - threadShouldThrow(); - } catch (InterruptedException success){ } + threadShouldThrow(); + } catch (InterruptedException success) { } } }); try { @@ -1002,7 +1002,7 @@ public class LinkedBlockingDequeTest ext Thread.sleep(SHORT_DELAY_MS); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -1020,7 +1020,7 @@ public class LinkedBlockingDequeTest ext } q.takeFirst(); threadShouldThrow(); - } catch (InterruptedException success){ + } catch (InterruptedException success) { } }}); t.start(); @@ -1030,7 +1030,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -1045,9 +1045,9 @@ public class LinkedBlockingDequeTest ext assertEquals(i, ((Integer)q.pollFirst(0, TimeUnit.MILLISECONDS)).intValue()); } assertNull(q.pollFirst(0, TimeUnit.MILLISECONDS)); - } catch (InterruptedException e){ - unexpectedException(); - } + } catch (InterruptedException e) { + unexpectedException(); + } } /** @@ -1060,9 +1060,9 @@ public class LinkedBlockingDequeTest ext assertEquals(i, ((Integer)q.pollFirst(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); } assertNull(q.pollFirst(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (InterruptedException e){ - unexpectedException(); - } + } catch (InterruptedException e) { + unexpectedException(); + } } /** @@ -1078,7 +1078,7 @@ public class LinkedBlockingDequeTest ext threadAssertEquals(i, ((Integer)q.pollFirst(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); } threadAssertNull(q.pollFirst(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (InterruptedException success){ + } catch (InterruptedException success) { } }}); t.start(); @@ -1088,7 +1088,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -1104,7 +1104,7 @@ public class LinkedBlockingDequeTest ext threadAssertNull(q.pollFirst(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); q.pollFirst(LONG_DELAY_MS, TimeUnit.MILLISECONDS); q.pollFirst(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); + threadShouldThrow(); } catch (InterruptedException success) { } } }); @@ -1114,7 +1114,7 @@ public class LinkedBlockingDequeTest ext assertTrue(q.offerFirst(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -1123,15 +1123,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 (NullPointerException success) { + } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -1149,7 +1149,7 @@ public class LinkedBlockingDequeTest ext assertEquals(0, q.remainingCapacity()); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -1168,7 +1168,7 @@ public class LinkedBlockingDequeTest ext } q.putLast(new Integer(SIZE)); threadShouldThrow(); - } catch (InterruptedException ie){ + } catch (InterruptedException ie) { threadAssertEquals(added, SIZE); } }}); @@ -1179,7 +1179,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -1200,8 +1200,8 @@ public class LinkedBlockingDequeTest ext ++added; q.putLast(new Object()); ++added; - threadShouldThrow(); - } catch (InterruptedException e){ + threadShouldThrow(); + } catch (InterruptedException e) { threadAssertTrue(added >= 2); } } @@ -1212,7 +1212,7 @@ public class LinkedBlockingDequeTest ext q.take(); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -1229,8 +1229,8 @@ public class LinkedBlockingDequeTest ext q.putLast(new Object()); threadAssertFalse(q.offerLast(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); q.offerLast(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch (InterruptedException success){} + threadShouldThrow(); + } catch (InterruptedException success) {} } }); @@ -1239,7 +1239,7 @@ public class LinkedBlockingDequeTest ext Thread.sleep(SMALL_DELAY_MS); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -1248,14 +1248,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(); - } + } catch (InterruptedException e) { + unexpectedException(); + } } /** @@ -1267,8 +1267,8 @@ public class LinkedBlockingDequeTest ext public void run() { try { q.takeLast(); - threadShouldThrow(); - } catch (InterruptedException success){ } + threadShouldThrow(); + } catch (InterruptedException success) { } } }); try { @@ -1276,7 +1276,7 @@ public class LinkedBlockingDequeTest ext Thread.sleep(SHORT_DELAY_MS); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -1294,7 +1294,7 @@ public class LinkedBlockingDequeTest ext } q.takeLast(); threadShouldThrow(); - } catch (InterruptedException success){ + } catch (InterruptedException success) { } }}); t.start(); @@ -1304,7 +1304,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -1319,9 +1319,9 @@ public class LinkedBlockingDequeTest ext assertEquals(SIZE-i-1, ((Integer)q.pollLast(0, TimeUnit.MILLISECONDS)).intValue()); } assertNull(q.pollLast(0, TimeUnit.MILLISECONDS)); - } catch (InterruptedException e){ - unexpectedException(); - } + } catch (InterruptedException e) { + unexpectedException(); + } } /** @@ -1334,9 +1334,9 @@ public class LinkedBlockingDequeTest ext assertEquals(SIZE-i-1, ((Integer)q.pollLast(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); } assertNull(q.pollLast(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (InterruptedException e){ - unexpectedException(); - } + } catch (InterruptedException e) { + unexpectedException(); + } } /** @@ -1352,7 +1352,7 @@ public class LinkedBlockingDequeTest ext threadAssertEquals(SIZE-i-1, ((Integer)q.pollLast(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); } threadAssertNull(q.pollLast(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (InterruptedException success){ + } catch (InterruptedException success) { } }}); t.start(); @@ -1362,7 +1362,7 @@ public class LinkedBlockingDequeTest ext t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -1378,7 +1378,7 @@ public class LinkedBlockingDequeTest ext threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); + threadShouldThrow(); } catch (InterruptedException success) { } } }); @@ -1388,7 +1388,7 @@ public class LinkedBlockingDequeTest ext assertTrue(q.offerLast(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -1507,13 +1507,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 +1521,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 +1559,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 +1633,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; @@ -1791,7 +1791,7 @@ public class LinkedBlockingDequeTest ext assertEquals(q.size(), r.size()); while (!q.isEmpty()) assertEquals(q.remove(), r.remove()); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -1853,7 +1853,7 @@ public class LinkedBlockingDequeTest ext public void run() { try { q.put(new Integer(SIZE+1)); - } catch (InterruptedException ie){ + } catch (InterruptedException ie) { threadUnexpectedException(); } } @@ -1867,7 +1867,7 @@ public class LinkedBlockingDequeTest ext assertEquals(l.get(i), new Integer(i)); t.join(); assertTrue(q.size() + l.size() >= SIZE); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } }