--- jsr166/src/test/tck/AbstractExecutorServiceTest.java 2009/11/21 10:25:05 1.21 +++ jsr166/src/test/tck/AbstractExecutorServiceTest.java 2009/12/01 22:51:44 1.22 @@ -345,19 +345,16 @@ public class AbstractExecutorServiceTest * invokeAny(c) throws NPE if c has null elements */ public void testInvokeAny3() throws Exception { - final CountDownLatch latch = new CountDownLatch(1); ExecutorService e = new DirectExecutorService(); + List> l = new ArrayList>(); + l.add(new Callable() { + public Integer call() { return 5/0; }}); + l.add(null); try { - ArrayList> l - = new ArrayList>(); - l.add(new Callable() { - public Integer call() { return 5/0; }}); - l.add(null); e.invokeAny(l); shouldThrow(); } catch (NullPointerException success) { } finally { - latch.countDown(); joinPool(e); } } @@ -367,9 +364,9 @@ public class AbstractExecutorServiceTest */ public void testInvokeAny4() throws InterruptedException { ExecutorService e = new DirectExecutorService(); + List> l = new ArrayList>(); + l.add(new NPETask()); try { - ArrayList> l = new ArrayList>(); - l.add(new NPETask()); e.invokeAny(l); shouldThrow(); } catch (ExecutionException success) { @@ -385,7 +382,7 @@ public class AbstractExecutorServiceTest public void testInvokeAny5() throws Exception { ExecutorService e = new DirectExecutorService(); try { - ArrayList> l = new ArrayList>(); + List> l = new ArrayList>(); l.add(new StringTask()); l.add(new StringTask()); String result = e.invokeAny(l); @@ -427,10 +424,10 @@ public class AbstractExecutorServiceTest */ public void testInvokeAll3() throws InterruptedException { ExecutorService e = new DirectExecutorService(); + List> l = new ArrayList>(); + l.add(new StringTask()); + l.add(null); try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(null); e.invokeAll(l); shouldThrow(); } catch (NullPointerException success) { @@ -445,18 +442,15 @@ public class AbstractExecutorServiceTest public void testInvokeAll4() throws Exception { ExecutorService e = new DirectExecutorService(); try { - ArrayList> l = new ArrayList>(); + List> l = new ArrayList>(); l.add(new NPETask()); - List> result = e.invokeAll(l); - assertEquals(1, result.size()); - for (Future future : result) { - try { - future.get(); - shouldThrow(); - } catch (ExecutionException success) { - Throwable cause = success.getCause(); - assertTrue(cause instanceof NullPointerException); - } + List> futures = e.invokeAll(l); + assertEquals(1, futures.size()); + try { + futures.get(0).get(); + shouldThrow(); + } catch (ExecutionException success) { + assertTrue(success.getCause() instanceof NullPointerException); } } finally { joinPool(e); @@ -469,12 +463,12 @@ public class AbstractExecutorServiceTest public void testInvokeAll5() throws Exception { ExecutorService e = new DirectExecutorService(); try { - ArrayList> l = new ArrayList>(); + List> l = new ArrayList>(); l.add(new StringTask()); l.add(new StringTask()); - List> result = e.invokeAll(l); - assertEquals(2, result.size()); - for (Future future : result) + List> futures = e.invokeAll(l); + assertEquals(2, futures.size()); + for (Future future : futures) assertSame(TEST_STRING, future.get()); } finally { joinPool(e); @@ -501,9 +495,9 @@ public class AbstractExecutorServiceTest */ public void testTimedInvokeAnyNullTimeUnit() throws Exception { ExecutorService e = new DirectExecutorService(); + List> l = new ArrayList>(); + l.add(new StringTask()); try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); e.invokeAny(l, MEDIUM_DELAY_MS, null); shouldThrow(); } catch (NullPointerException success) { @@ -530,19 +524,16 @@ public class AbstractExecutorServiceTest * timed invokeAny(c) throws NPE if c has null elements */ public void testTimedInvokeAny3() throws Exception { - final CountDownLatch latch = new CountDownLatch(1); ExecutorService e = new DirectExecutorService(); + List> l = new ArrayList>(); + l.add(new Callable() { + public Integer call() { return 5/0; }}); + l.add(null); try { - ArrayList> l - = new ArrayList>(); - l.add(new Callable() { - public Integer call() { return 5/0; }}); - l.add(null); e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (NullPointerException success) { } finally { - latch.countDown(); joinPool(e); } } @@ -552,9 +543,9 @@ public class AbstractExecutorServiceTest */ public void testTimedInvokeAny4() throws Exception { ExecutorService e = new DirectExecutorService(); + List> l = new ArrayList>(); + l.add(new NPETask()); try { - ArrayList> l = new ArrayList>(); - l.add(new NPETask()); e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (ExecutionException success) { @@ -570,7 +561,7 @@ public class AbstractExecutorServiceTest public void testTimedInvokeAny5() throws Exception { ExecutorService e = new DirectExecutorService(); try { - ArrayList> l = new ArrayList>(); + List> l = new ArrayList>(); l.add(new StringTask()); l.add(new StringTask()); String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); @@ -599,9 +590,9 @@ public class AbstractExecutorServiceTest */ public void testTimedInvokeAllNullTimeUnit() throws InterruptedException { ExecutorService e = new DirectExecutorService(); + List> l = new ArrayList>(); + l.add(new StringTask()); try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); e.invokeAll(l, MEDIUM_DELAY_MS, null); shouldThrow(); } catch (NullPointerException success) { @@ -628,10 +619,10 @@ public class AbstractExecutorServiceTest */ public void testTimedInvokeAll3() throws InterruptedException { ExecutorService e = new DirectExecutorService(); + List> l = new ArrayList>(); + l.add(new StringTask()); + l.add(null); try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(null); e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (NullPointerException success) { @@ -646,17 +637,16 @@ public class AbstractExecutorServiceTest public void testTimedInvokeAll4() throws Exception { ExecutorService e = new DirectExecutorService(); try { - ArrayList> l = new ArrayList>(); + List> l = new ArrayList>(); l.add(new NPETask()); - List> result = e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS); - assertEquals(1, result.size()); - for (Future future : result) { - try { - future.get(); - shouldThrow(); - } catch (ExecutionException success) { - assertTrue(success.getCause() instanceof NullPointerException); - } + List> futures = + e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS); + assertEquals(1, futures.size()); + try { + futures.get(0).get(); + shouldThrow(); + } catch (ExecutionException success) { + assertTrue(success.getCause() instanceof NullPointerException); } } finally { joinPool(e); @@ -669,12 +659,13 @@ public class AbstractExecutorServiceTest public void testTimedInvokeAll5() throws Exception { ExecutorService e = new DirectExecutorService(); try { - ArrayList> l = new ArrayList>(); + List> l = new ArrayList>(); l.add(new StringTask()); l.add(new StringTask()); - List> result = e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS); - assertEquals(2, result.size()); - for (Future future : result) + List> futures = + e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS); + assertEquals(2, futures.size()); + for (Future future : futures) assertSame(TEST_STRING, future.get()); } finally { joinPool(e); @@ -687,13 +678,14 @@ public class AbstractExecutorServiceTest public void testTimedInvokeAll6() throws InterruptedException { ExecutorService e = new DirectExecutorService(); try { - ArrayList> l = new ArrayList>(); + List> l = new ArrayList>(); l.add(new StringTask()); l.add(Executors.callable(new MediumPossiblyInterruptedRunnable(), TEST_STRING)); l.add(new StringTask()); - List> result = e.invokeAll(l, SMALL_DELAY_MS, MILLISECONDS); - assertEquals(3, result.size()); - Iterator> it = result.iterator(); + List> futures = + e.invokeAll(l, SMALL_DELAY_MS, MILLISECONDS); + assertEquals(3, futures.size()); + Iterator> it = futures.iterator(); Future f1 = it.next(); Future f2 = it.next(); Future f3 = it.next();