--- jsr166/src/test/tck/ForkJoinPoolTest.java 2009/08/04 21:10:19 1.8 +++ jsr166/src/test/tck/ForkJoinPoolTest.java 2009/11/21 20:10:48 1.12 @@ -170,8 +170,7 @@ public class ForkJoinPoolTest extends JS try { new ForkJoinPool(-1); shouldThrow(); - } - catch (IllegalArgumentException success) {} + } catch (IllegalArgumentException success) {} } /** @@ -181,8 +180,7 @@ public class ForkJoinPoolTest extends JS try { new ForkJoinPool(1, null); shouldThrow(); - } catch (NullPointerException success) { - } + } catch (NullPointerException success) {} } @@ -592,6 +590,7 @@ public class ForkJoinPoolTest extends JS Object result = future.get(); shouldThrow(); } catch (ExecutionException success) { + assertTrue(success.getCause() instanceof IndexOutOfBoundsException); } finally { Policy.setPolicy(savedPolicy); } @@ -606,8 +605,7 @@ public class ForkJoinPoolTest extends JS TrackedShortRunnable task = null; Future future = e.submit(task); shouldThrow(); - } catch (NullPointerException success) { - } + } catch (NullPointerException success) {} } @@ -620,8 +618,7 @@ public class ForkJoinPoolTest extends JS StringTask t = null; Future future = e.submit(t); shouldThrow(); - } catch (NullPointerException success) { - } + } catch (NullPointerException success) {} } @@ -666,7 +663,9 @@ public class ForkJoinPoolTest extends JS }}).get(); shouldThrow(); } catch (ExecutionException success) { + assertTrue(success.getCause() instanceof ArithmeticException); } + joinPool(p); } @@ -699,13 +698,12 @@ public class ForkJoinPoolTest extends JS } /** - * invokeAny(c) throws NullPointerException if c has null elements + * invokeAny(c) throws NullPointerException if c has a single null element */ public void testInvokeAny3() throws Throwable { ExecutorService e = new ForkJoinPool(1); try { ArrayList> l = new ArrayList>(); - l.add(new StringTask()); l.add(null); e.invokeAny(l); shouldThrow(); @@ -716,16 +714,40 @@ public class ForkJoinPoolTest extends JS } /** - * invokeAny(c) throws ExecutionException if no task in c completes + * invokeAny(c) throws NullPointerException if c has null elements */ public void testInvokeAny4() throws Throwable { ExecutorService e = new ForkJoinPool(1); try { ArrayList> l = new ArrayList>(); + l.add(new Callable() { + public String call() { + // The delay gives the pool a chance to notice + // the null element. + sleepTillInterrupted(SMALL_DELAY_MS); + return "foo"; + }}); + l.add(null); + e.invokeAny(l); + shouldThrow(); + } catch (NullPointerException success) { + } finally { + joinPool(e); + } + } + + /** + * invokeAny(c) throws ExecutionException if no task in c completes + */ + public void testInvokeAny5() throws Throwable { + ExecutorService e = new ForkJoinPool(1); + try { + ArrayList> l = new ArrayList>(); l.add(new NPETask()); e.invokeAny(l); shouldThrow(); } catch (ExecutionException success) { + assertTrue(success.getCause() instanceof NullPointerException); } finally { joinPool(e); } @@ -734,7 +756,7 @@ public class ForkJoinPoolTest extends JS /** * invokeAny(c) returns result of some task in c if at least one completes */ - public void testInvokeAny5() throws Throwable { + public void testInvokeAny6() throws Throwable { ExecutorService e = new ForkJoinPool(1); try { ArrayList> l = new ArrayList>(); @@ -807,6 +829,7 @@ public class ForkJoinPoolTest extends JS future.get(); shouldThrow(); } catch (ExecutionException success) { + assertTrue(success.getCause() instanceof NullPointerException); } finally { joinPool(e); } @@ -904,6 +927,7 @@ public class ForkJoinPoolTest extends JS e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (ExecutionException success) { + assertTrue(success.getCause() instanceof NullPointerException); } finally { joinPool(e); } @@ -1002,6 +1026,7 @@ public class ForkJoinPoolTest extends JS future.get(); shouldThrow(); } catch (ExecutionException success) { + assertTrue(success.getCause() instanceof NullPointerException); } finally { joinPool(e); }