--- jsr166/src/test/tck/LinkedBlockingDequeTest.java 2005/09/16 11:16:03 1.3 +++ jsr166/src/test/tck/LinkedBlockingDequeTest.java 2009/11/16 05:30:07 1.6 @@ -11,7 +11,7 @@ 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() { @@ -25,7 +25,7 @@ public class LinkedBlockingDequeTest ext private LinkedBlockingDeque populatedDeque(int n) { LinkedBlockingDeque q = new LinkedBlockingDeque(n); assertTrue(q.isEmpty()); - for(int i = 0; i < n; i++) + for (int i = 0; i < n; i++) assertTrue(q.offer(new Integer(i))); assertFalse(q.isEmpty()); assertEquals(0, q.remainingCapacity()); @@ -70,12 +70,12 @@ public class LinkedBlockingDequeTest ext LinkedBlockingDeque q = new LinkedBlockingDeque(); q.offerFirst(null); shouldThrow(); - } catch (NullPointerException success) { - } + } catch (NullPointerException success) { + } } /** - * OfferFirst succeeds + * OfferFirst succeeds */ public void testOfferFirst() { LinkedBlockingDeque q = new LinkedBlockingDeque(); @@ -84,7 +84,7 @@ public class LinkedBlockingDequeTest ext } /** - * OfferLast succeeds + * OfferLast succeeds */ public void testOfferLast() { LinkedBlockingDeque q = new LinkedBlockingDeque(); @@ -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) { + } } /** @@ -257,7 +257,7 @@ public class LinkedBlockingDequeTest ext q.pollLast(); q.addFirst(four); assertEquals(four,q.peekFirst()); - } + } /** * peekLast returns element inserted with addLast @@ -267,7 +267,7 @@ public class LinkedBlockingDequeTest ext q.pollLast(); q.addLast(four); assertEquals(four,q.peekLast()); - } + } /** @@ -382,7 +382,7 @@ public class LinkedBlockingDequeTest ext LinkedBlockingDeque q = new LinkedBlockingDeque(1); q.offer(null); shouldThrow(); - } catch (NullPointerException success) { } + } catch (NullPointerException success) { } } /** @@ -393,7 +393,7 @@ public class LinkedBlockingDequeTest ext LinkedBlockingDeque q = new LinkedBlockingDeque(1); q.add(null); shouldThrow(); - } catch (NullPointerException success) { } + } catch (NullPointerException success) { } } /** @@ -404,7 +404,7 @@ public class LinkedBlockingDequeTest ext LinkedBlockingDeque q = new LinkedBlockingDeque(1); q.push(null); shouldThrow(); - } catch (NullPointerException success) { } + } catch (NullPointerException success) { } } /** @@ -420,8 +420,8 @@ public class LinkedBlockingDequeTest ext } assertEquals(0, q.remainingCapacity()); q.push(new Integer(SIZE)); - } catch (IllegalStateException success){ - } + } catch (IllegalStateException success) { + } } /** @@ -432,7 +432,7 @@ public class LinkedBlockingDequeTest ext q.pollLast(); 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) { + } } @@ -471,8 +471,8 @@ public class LinkedBlockingDequeTest ext } assertEquals(0, q.remainingCapacity()); q.add(new Integer(SIZE)); - } catch (IllegalStateException success){ - } + } catch (IllegalStateException success) { + } } /** @@ -567,9 +567,9 @@ public class LinkedBlockingDequeTest ext LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); q.put(null); shouldThrow(); - } - catch (NullPointerException success){ - } + } + catch (NullPointerException success) { + } catch (InterruptedException ie) { unexpectedException(); } @@ -608,13 +608,13 @@ public class LinkedBlockingDequeTest ext } q.put(new Integer(SIZE)); threadShouldThrow(); - } catch (InterruptedException ie){ + } catch (InterruptedException ie) { threadAssertEquals(added, SIZE); - } + } }}); t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); + try { + Thread.sleep(SHORT_DELAY_MS); t.interrupt(); t.join(); } @@ -641,7 +641,7 @@ public class LinkedBlockingDequeTest ext q.put(new Object()); ++added; threadShouldThrow(); - } catch (InterruptedException e){ + } 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(); } } @@ -670,16 +670,16 @@ public class LinkedBlockingDequeTest ext threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); q.offer(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); threadShouldThrow(); - } catch (InterruptedException success){} + } catch (InterruptedException success) {} } }); - + try { t.start(); Thread.sleep(SMALL_DELAY_MS); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -693,9 +693,9 @@ public class LinkedBlockingDequeTest ext for (int i = 0; i < SIZE; ++i) { assertEquals(i, ((Integer)q.take()).intValue()); } - } catch (InterruptedException e){ + } catch (InterruptedException e) { unexpectedException(); - } + } } /** @@ -708,7 +708,7 @@ public class LinkedBlockingDequeTest ext try { q.take(); threadShouldThrow(); - } catch (InterruptedException success){ } + } 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,12 +734,12 @@ public class LinkedBlockingDequeTest ext } q.take(); threadShouldThrow(); - } catch (InterruptedException success){ - } + } catch (InterruptedException success) { + } }}); t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); + try { + Thread.sleep(SHORT_DELAY_MS); t.interrupt(); t.join(); } @@ -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){ + } 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){ + } catch (InterruptedException e) { unexpectedException(); - } + } } /** @@ -803,12 +803,12 @@ 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(); - try { - Thread.sleep(SHORT_DELAY_MS); + try { + Thread.sleep(SHORT_DELAY_MS); t.interrupt(); t.join(); } @@ -830,7 +830,7 @@ public class LinkedBlockingDequeTest ext q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); threadShouldThrow(); - } catch (InterruptedException success) { } + } catch (InterruptedException success) { } } }); try { @@ -839,10 +839,10 @@ public class LinkedBlockingDequeTest ext assertTrue(q.offer(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } - } + } /** @@ -853,9 +853,9 @@ public class LinkedBlockingDequeTest ext LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); q.putFirst(null); shouldThrow(); - } - catch (NullPointerException success){ - } + } + catch (NullPointerException success) { + } catch (InterruptedException ie) { unexpectedException(); } @@ -894,13 +894,13 @@ public class LinkedBlockingDequeTest ext } q.putFirst(new Integer(SIZE)); threadShouldThrow(); - } catch (InterruptedException ie){ + } catch (InterruptedException ie) { threadAssertEquals(added, SIZE); - } + } }}); t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); + try { + Thread.sleep(SHORT_DELAY_MS); t.interrupt(); t.join(); } @@ -927,7 +927,7 @@ public class LinkedBlockingDequeTest ext q.putFirst(new Object()); ++added; threadShouldThrow(); - } catch (InterruptedException e){ + } 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(); } } @@ -956,16 +956,16 @@ public class LinkedBlockingDequeTest ext threadAssertFalse(q.offerFirst(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); q.offerFirst(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); threadShouldThrow(); - } catch (InterruptedException success){} + } catch (InterruptedException success) {} } }); - + try { t.start(); Thread.sleep(SMALL_DELAY_MS); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -979,9 +979,9 @@ public class LinkedBlockingDequeTest ext for (int i = 0; i < SIZE; ++i) { assertEquals(i, ((Integer)q.takeFirst()).intValue()); } - } catch (InterruptedException e){ + } catch (InterruptedException e) { unexpectedException(); - } + } } /** @@ -994,7 +994,7 @@ public class LinkedBlockingDequeTest ext try { q.takeFirst(); threadShouldThrow(); - } catch (InterruptedException success){ } + } 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,12 +1020,12 @@ public class LinkedBlockingDequeTest ext } q.takeFirst(); threadShouldThrow(); - } catch (InterruptedException success){ - } + } catch (InterruptedException success) { + } }}); t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); + try { + Thread.sleep(SHORT_DELAY_MS); t.interrupt(); t.join(); } @@ -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){ + } 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){ + } catch (InterruptedException e) { unexpectedException(); - } + } } /** @@ -1078,12 +1078,12 @@ 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(); - try { - Thread.sleep(SHORT_DELAY_MS); + try { + Thread.sleep(SHORT_DELAY_MS); t.interrupt(); t.join(); } @@ -1105,7 +1105,7 @@ public class LinkedBlockingDequeTest ext q.pollFirst(LONG_DELAY_MS, TimeUnit.MILLISECONDS); q.pollFirst(LONG_DELAY_MS, TimeUnit.MILLISECONDS); threadShouldThrow(); - } catch (InterruptedException success) { } + } catch (InterruptedException success) { } } }); try { @@ -1114,10 +1114,10 @@ public class LinkedBlockingDequeTest ext assertTrue(q.offerFirst(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } - } + } /** * putLast(null) throws NPE @@ -1127,9 +1127,9 @@ public class LinkedBlockingDequeTest ext LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); q.putLast(null); shouldThrow(); - } - catch (NullPointerException success){ - } + } + catch (NullPointerException success) { + } catch (InterruptedException ie) { unexpectedException(); } @@ -1168,13 +1168,13 @@ public class LinkedBlockingDequeTest ext } q.putLast(new Integer(SIZE)); threadShouldThrow(); - } catch (InterruptedException ie){ + } catch (InterruptedException ie) { threadAssertEquals(added, SIZE); - } + } }}); t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); + try { + Thread.sleep(SHORT_DELAY_MS); t.interrupt(); t.join(); } @@ -1201,7 +1201,7 @@ public class LinkedBlockingDequeTest ext q.putLast(new Object()); ++added; threadShouldThrow(); - } catch (InterruptedException e){ + } 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(); } } @@ -1230,16 +1230,16 @@ public class LinkedBlockingDequeTest ext threadAssertFalse(q.offerLast(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); q.offerLast(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); threadShouldThrow(); - } catch (InterruptedException success){} + } catch (InterruptedException success) {} } }); - + try { t.start(); Thread.sleep(SMALL_DELAY_MS); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } } @@ -1253,9 +1253,9 @@ public class LinkedBlockingDequeTest ext for (int i = 0; i < SIZE; ++i) { assertEquals(SIZE-i-1, ((Integer)q.takeLast()).intValue()); } - } catch (InterruptedException e){ + } catch (InterruptedException e) { unexpectedException(); - } + } } /** @@ -1268,7 +1268,7 @@ public class LinkedBlockingDequeTest ext try { q.takeLast(); threadShouldThrow(); - } catch (InterruptedException success){ } + } 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,12 +1294,12 @@ public class LinkedBlockingDequeTest ext } q.takeLast(); threadShouldThrow(); - } catch (InterruptedException success){ - } + } catch (InterruptedException success) { + } }}); t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); + try { + Thread.sleep(SHORT_DELAY_MS); t.interrupt(); t.join(); } @@ -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){ + } 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){ + } catch (InterruptedException e) { unexpectedException(); - } + } } /** @@ -1352,12 +1352,12 @@ 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(); - try { - Thread.sleep(SHORT_DELAY_MS); + try { + Thread.sleep(SHORT_DELAY_MS); t.interrupt(); t.join(); } @@ -1379,7 +1379,7 @@ public class LinkedBlockingDequeTest ext q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); threadShouldThrow(); - } catch (InterruptedException success) { } + } catch (InterruptedException success) { } } }); try { @@ -1388,10 +1388,10 @@ public class LinkedBlockingDequeTest ext assertTrue(q.offerLast(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); t.interrupt(); t.join(); - } catch (Exception e){ + } catch (Exception e) { unexpectedException(); } - } + } /** @@ -1424,7 +1424,7 @@ public class LinkedBlockingDequeTest ext } assertTrue(q.isEmpty()); } - + /** * contains(x) reports true when elements added but not yet removed */ @@ -1509,11 +1509,11 @@ public class LinkedBlockingDequeTest ext LinkedBlockingDeque q = populatedDeque(SIZE); Object[] o = q.toArray(); try { - for(int i = 0; i < o.length; i++) + for (int i = 0; i < o.length; i++) assertEquals(o[i], q.take()); - } catch (InterruptedException e){ + } catch (InterruptedException e) { unexpectedException(); - } + } } /** @@ -1524,11 +1524,11 @@ public class LinkedBlockingDequeTest ext Integer[] ints = new Integer[SIZE]; ints = (Integer[])q.toArray(ints); try { - for(int i = 0; i < ints.length; i++) + for (int i = 0; i < ints.length; i++) assertEquals(ints[i], q.take()); - } catch (InterruptedException e){ + } catch (InterruptedException e) { unexpectedException(); - } + } } /** @@ -1539,7 +1539,7 @@ public class LinkedBlockingDequeTest ext LinkedBlockingDeque q = populatedDeque(SIZE); Object o[] = q.toArray(null); shouldThrow(); - } catch(NullPointerException success){} + } catch (NullPointerException success) {} } /** @@ -1550,10 +1550,10 @@ public class LinkedBlockingDequeTest ext LinkedBlockingDeque q = populatedDeque(SIZE); Object o[] = q.toArray(new String[10] ); shouldThrow(); - } catch(ArrayStoreException success){} + } catch (ArrayStoreException success) {} } - + /** * iterator iterates through all elements */ @@ -1561,12 +1561,12 @@ public class LinkedBlockingDequeTest ext LinkedBlockingDeque q = populatedDeque(SIZE); Iterator it = q.iterator(); try { - while(it.hasNext()){ + while (it.hasNext()) { assertEquals(it.next(), q.take()); } - } catch (InterruptedException e){ + } catch (InterruptedException e) { unexpectedException(); - } + } } /** @@ -1581,7 +1581,7 @@ public class LinkedBlockingDequeTest ext Iterator it = q.iterator(); it.next(); it.remove(); - + it = q.iterator(); assertEquals(it.next(), one); assertEquals(it.next(), three); @@ -1634,7 +1634,7 @@ public class LinkedBlockingDequeTest ext LinkedBlockingDeque q = populatedDeque(SIZE); int i = 0; Iterator it = q.descendingIterator(); - while(it.hasNext()) { + while (it.hasNext()) { assertTrue(q.contains(it.next())); ++i; } @@ -1642,7 +1642,7 @@ public class LinkedBlockingDequeTest ext assertFalse(it.hasNext()); try { it.next(); - } catch(NoSuchElementException success) { + } catch (NoSuchElementException success) { } } @@ -1660,7 +1660,7 @@ public class LinkedBlockingDequeTest ext int i = ((Integer)(it.next())).intValue(); assertEquals(++k, i); } - + assertEquals(3, k); q.remove(); q.remove(); @@ -1700,7 +1700,7 @@ public class LinkedBlockingDequeTest ext for (int i = 0; i < SIZE; ++i) { assertTrue(s.indexOf(String.valueOf(i)) >= 0); } - } + } /** @@ -1735,7 +1735,7 @@ public class LinkedBlockingDequeTest ext } } }); - + joinPool(executor); } @@ -1769,7 +1769,7 @@ public class LinkedBlockingDequeTest ext } } }); - + joinPool(executor); } @@ -1789,47 +1789,47 @@ public class LinkedBlockingDequeTest ext ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); LinkedBlockingDeque r = (LinkedBlockingDeque)in.readObject(); assertEquals(q.size(), r.size()); - while (!q.isEmpty()) + while (!q.isEmpty()) assertEquals(q.remove(), r.remove()); - } catch(Exception e){ + } catch (Exception e) { unexpectedException(); } } /** * drainTo(null) throws NPE - */ + */ public void testDrainToNull() { LinkedBlockingDeque q = populatedDeque(SIZE); try { q.drainTo(null); shouldThrow(); - } catch(NullPointerException success) { + } catch (NullPointerException success) { } } /** * drainTo(this) throws IAE - */ + */ public void testDrainToSelf() { LinkedBlockingDeque q = populatedDeque(SIZE); try { q.drainTo(q); shouldThrow(); - } catch(IllegalArgumentException success) { + } catch (IllegalArgumentException success) { } } /** * drainTo(c) empties deque into another collection c - */ + */ public void testDrainTo() { LinkedBlockingDeque q = populatedDeque(SIZE); ArrayList l = new ArrayList(); q.drainTo(l); assertEquals(q.size(), 0); assertEquals(l.size(), SIZE); - for (int i = 0; i < SIZE; ++i) + for (int i = 0; i < SIZE; ++i) assertEquals(l.get(i), new Integer(i)); q.add(zero); q.add(one); @@ -1840,20 +1840,20 @@ public class LinkedBlockingDequeTest ext q.drainTo(l); assertEquals(q.size(), 0); assertEquals(l.size(), 2); - for (int i = 0; i < 2; ++i) + for (int i = 0; i < 2; ++i) assertEquals(l.get(i), new Integer(i)); } /** * drainTo empties full deque, unblocking a waiting put. - */ + */ public void testDrainToWithActivePut() { final LinkedBlockingDeque q = populatedDeque(SIZE); Thread t = new Thread(new Runnable() { public void run() { try { q.put(new Integer(SIZE+1)); - } catch (InterruptedException ie){ + } catch (InterruptedException ie) { threadUnexpectedException(); } } @@ -1863,53 +1863,53 @@ public class LinkedBlockingDequeTest ext ArrayList l = new ArrayList(); q.drainTo(l); assertTrue(l.size() >= SIZE); - for (int i = 0; i < SIZE; ++i) + for (int i = 0; i < SIZE; ++i) assertEquals(l.get(i), new Integer(i)); t.join(); assertTrue(q.size() + l.size() >= SIZE); - } catch(Exception e){ + } catch (Exception e) { unexpectedException(); } } /** * drainTo(null, n) throws NPE - */ + */ public void testDrainToNullN() { LinkedBlockingDeque q = populatedDeque(SIZE); try { q.drainTo(null, 0); shouldThrow(); - } catch(NullPointerException success) { + } catch (NullPointerException success) { } } /** * drainTo(this, n) throws IAE - */ + */ public void testDrainToSelfN() { LinkedBlockingDeque q = populatedDeque(SIZE); try { q.drainTo(q, 0); shouldThrow(); - } catch(IllegalArgumentException success) { + } catch (IllegalArgumentException success) { } } /** * drainTo(c, n) empties first max {n, size} elements of deque into c - */ + */ public void testDrainToN() { LinkedBlockingDeque q = new LinkedBlockingDeque(); for (int i = 0; i < SIZE + 2; ++i) { - for(int j = 0; j < SIZE; j++) + for (int j = 0; j < SIZE; j++) assertTrue(q.offer(new Integer(j))); ArrayList l = new ArrayList(); q.drainTo(l, i); int k = (i < SIZE)? i : SIZE; assertEquals(l.size(), k); assertEquals(q.size(), SIZE-k); - for (int j = 0; j < k; ++j) + for (int j = 0; j < k; ++j) assertEquals(l.get(j), new Integer(j)); while (q.poll() != null) ; }