--- jsr166/src/test/tck/ArrayBlockingQueueTest.java 2009/11/16 05:30:07 1.14 +++ jsr166/src/test/tck/ArrayBlockingQueueTest.java 2009/11/21 02:07:26 1.15 @@ -14,10 +14,10 @@ import java.io.*; public class ArrayBlockingQueueTest 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(ArrayBlockingQueueTest.class); + return new TestSuite(ArrayBlockingQueueTest.class); } /** @@ -27,11 +27,11 @@ public class ArrayBlockingQueueTest exte private ArrayBlockingQueue populatedQueue(int n) { ArrayBlockingQueue q = new ArrayBlockingQueue(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; } @@ -155,7 +155,7 @@ public class ArrayBlockingQueueTest exte * offer(null) throws NPE */ public void testOfferNull() { - try { + try { ArrayBlockingQueue q = new ArrayBlockingQueue(1); q.offer(null); shouldThrow(); @@ -166,7 +166,7 @@ public class ArrayBlockingQueueTest exte * add(null) throws NPE */ public void testAddNull() { - try { + try { ArrayBlockingQueue q = new ArrayBlockingQueue(1); q.add(null); shouldThrow(); @@ -186,7 +186,7 @@ public class ArrayBlockingQueueTest exte * add succeeds if not full; throws ISE if full */ public void testAdd() { - try { + try { ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); for (int i = 0; i < SIZE; ++i) { assertTrue(q.add(new Integer(i))); @@ -194,7 +194,7 @@ public class ArrayBlockingQueueTest exte assertEquals(0, q.remainingCapacity()); q.add(new Integer(SIZE)); } catch (IllegalStateException success) { - } + } } /** @@ -285,15 +285,15 @@ public class ArrayBlockingQueueTest exte * put(null) throws NPE */ public void testPutNull() { - try { + try { ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); q.put(null); shouldThrow(); } catch (NullPointerException success) { - } + } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -311,7 +311,7 @@ public class ArrayBlockingQueueTest exte assertEquals(0, q.remainingCapacity()); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -341,7 +341,7 @@ public class ArrayBlockingQueueTest exte t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -362,7 +362,7 @@ public class ArrayBlockingQueueTest exte ++added; q.put(new Object()); ++added; - threadShouldThrow(); + threadShouldThrow(); } catch (InterruptedException e) { threadAssertTrue(added >= 2); } @@ -391,7 +391,7 @@ public class ArrayBlockingQueueTest exte q.put(new Object()); threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS/2, TimeUnit.MILLISECONDS)); q.offer(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); + threadShouldThrow(); } catch (InterruptedException success) {} } }); @@ -410,14 +410,14 @@ public class ArrayBlockingQueueTest exte * take retrieves elements in FIFO order */ public void testTake() { - try { + try { ArrayBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(i, ((Integer)q.take()).intValue()); } } catch (InterruptedException e) { - unexpectedException(); - } + unexpectedException(); + } } /** @@ -429,7 +429,7 @@ public class ArrayBlockingQueueTest exte public void run() { try { q.take(); - threadShouldThrow(); + threadShouldThrow(); } catch (InterruptedException success) { } } }); @@ -466,7 +466,7 @@ public class ArrayBlockingQueueTest exte t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -479,7 +479,7 @@ public class ArrayBlockingQueueTest exte for (int i = 0; i < SIZE; ++i) { assertEquals(i, ((Integer)q.poll()).intValue()); } - assertNull(q.poll()); + assertNull(q.poll()); } /** @@ -493,8 +493,8 @@ public class ArrayBlockingQueueTest exte } assertNull(q.poll(0, TimeUnit.MILLISECONDS)); } catch (InterruptedException e) { - unexpectedException(); - } + unexpectedException(); + } } /** @@ -508,8 +508,8 @@ public class ArrayBlockingQueueTest exte } assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); } catch (InterruptedException e) { - unexpectedException(); - } + unexpectedException(); + } } /** @@ -535,7 +535,7 @@ public class ArrayBlockingQueueTest exte t.join(); } catch (InterruptedException ie) { - unexpectedException(); + unexpectedException(); } } @@ -551,7 +551,7 @@ public class ArrayBlockingQueueTest exte 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) { } } }); @@ -578,7 +578,7 @@ public class ArrayBlockingQueueTest exte assertTrue(q.peek() == null || i != ((Integer)q.peek()).intValue()); } - assertNull(q.peek()); + assertNull(q.peek()); } /** @@ -609,7 +609,7 @@ public class ArrayBlockingQueueTest exte q.remove(); shouldThrow(); } catch (NoSuchElementException success) { - } + } } /** @@ -709,13 +709,13 @@ public class ArrayBlockingQueueTest exte */ public void testToArray() { ArrayBlockingQueue q = populatedQueue(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(); + } } /** @@ -723,36 +723,36 @@ public class ArrayBlockingQueueTest exte */ public void testToArray2() { ArrayBlockingQueue q = populatedQueue(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 { ArrayBlockingQueue q = populatedQueue(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 { ArrayBlockingQueue q = populatedQueue(SIZE); - Object o[] = q.toArray(new String[10] ); - shouldThrow(); - } catch (ArrayStoreException success) {} + Object o[] = q.toArray(new String[10] ); + shouldThrow(); + } catch (ArrayStoreException success) {} } @@ -761,14 +761,14 @@ public class ArrayBlockingQueueTest exte */ public void testIterator() { ArrayBlockingQueue q = populatedQueue(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(); + } } /**