--- jsr166/src/test/tck/ForkJoinPoolTest.java 2010/09/17 16:49:25 1.29 +++ jsr166/src/test/tck/ForkJoinPoolTest.java 2010/11/18 19:14:34 1.34 @@ -259,10 +259,11 @@ public class ForkJoinPoolTest extends JS public void testisQuiescent() throws InterruptedException { ForkJoinPool p = new ForkJoinPool(2); try { + assertTrue(p.isQuiescent()); p.invoke(new FibTask(20)); assertSame(ForkJoinPool.defaultForkJoinWorkerThreadFactory, p.getFactory()); - Thread.sleep(MEDIUM_DELAY_MS); + Thread.sleep(SMALL_DELAY_MS); assertTrue(p.isQuiescent()); assertFalse(p.getAsyncMode()); assertEquals(0, p.getActiveThreadCount()); @@ -315,9 +316,9 @@ public class ForkJoinPoolTest extends JS try { ReentrantLock lock = new ReentrantLock(); ManagedLocker locker = new ManagedLocker(lock); - ForkJoinTask f = new LockingFibTask(30, locker, lock); + ForkJoinTask f = new LockingFibTask(20, locker, lock); p.execute(f); - assertEquals(832040, (int) f.get()); + assertEquals(6765, (int) f.get()); } finally { p.shutdownNow(); // don't wait out shutdown } @@ -329,9 +330,9 @@ public class ForkJoinPoolTest extends JS public void testPollSubmission() { SubFJP p = new SubFJP(); try { - ForkJoinTask a = p.submit(new MediumRunnable()); - ForkJoinTask b = p.submit(new MediumRunnable()); - ForkJoinTask c = p.submit(new MediumRunnable()); + ForkJoinTask a = p.submit(new ShortRunnable()); + ForkJoinTask b = p.submit(new ShortRunnable()); + ForkJoinTask c = p.submit(new ShortRunnable()); ForkJoinTask r = p.pollSubmission(); assertTrue(r == a || r == b || r == c); assertFalse(r.isDone()); @@ -346,9 +347,9 @@ public class ForkJoinPoolTest extends JS public void testDrainTasksTo() { SubFJP p = new SubFJP(); try { - ForkJoinTask a = p.submit(new MediumRunnable()); - ForkJoinTask b = p.submit(new MediumRunnable()); - ForkJoinTask c = p.submit(new MediumRunnable()); + ForkJoinTask a = p.submit(new ShortRunnable()); + ForkJoinTask b = p.submit(new ShortRunnable()); + ForkJoinTask c = p.submit(new ShortRunnable()); ArrayList al = new ArrayList(); p.drainTasksTo(al); assertTrue(al.size() > 0); @@ -370,11 +371,12 @@ public class ForkJoinPoolTest extends JS public void testExecuteRunnable() throws Throwable { ExecutorService e = new ForkJoinPool(1); try { - TrackedShortRunnable task = new TrackedShortRunnable(); - assertFalse(task.done); + TrackedRunnable task = trackedRunnable(SHORT_DELAY_MS); + assertFalse(task.isDone()); Future future = e.submit(task); - future.get(); - assertTrue(task.done); + assertNull(future.get()); + assertTrue(task.isDone()); + assertFalse(future.isCancelled()); } finally { joinPool(e); } @@ -388,8 +390,9 @@ public class ForkJoinPoolTest extends JS ExecutorService e = new ForkJoinPool(1); try { Future future = e.submit(new StringTask()); - String result = future.get(); - assertSame(TEST_STRING, result); + assertSame(TEST_STRING, future.get()); + assertTrue(future.isDone()); + assertFalse(future.isCancelled()); } finally { joinPool(e); } @@ -402,8 +405,9 @@ public class ForkJoinPoolTest extends JS ExecutorService e = new ForkJoinPool(1); try { Future future = e.submit(new NoOpRunnable()); - future.get(); + assertNull(future.get()); assertTrue(future.isDone()); + assertFalse(future.isCancelled()); } finally { joinPool(e); } @@ -416,8 +420,9 @@ public class ForkJoinPoolTest extends JS ExecutorService e = new ForkJoinPool(1); try { Future future = e.submit(new NoOpRunnable(), TEST_STRING); - String result = future.get(); - assertSame(TEST_STRING, result); + assertSame(TEST_STRING, future.get()); + assertTrue(future.isDone()); + assertFalse(future.isCancelled()); } finally { joinPool(e); } @@ -425,7 +430,7 @@ public class ForkJoinPoolTest extends JS /** - * A submitted privileged action to completion + * A submitted privileged action runs to completion */ public void testSubmitPrivilegedAction() throws Throwable { Policy savedPolicy = null; @@ -458,7 +463,7 @@ public class ForkJoinPoolTest extends JS } /** - * A submitted a privileged exception action runs to completion + * A submitted privileged exception action runs to completion */ public void testSubmitPrivilegedExceptionAction() throws Throwable { Policy savedPolicy = null; @@ -530,9 +535,8 @@ public class ForkJoinPoolTest extends JS */ public void testExecuteNullRunnable() { ExecutorService e = new ForkJoinPool(1); - TrackedShortRunnable task = null; try { - Future future = e.submit(task); + Future future = e.submit((Runnable) null); shouldThrow(); } catch (NullPointerException success) { } finally { @@ -546,9 +550,8 @@ public class ForkJoinPoolTest extends JS */ public void testSubmitNullCallable() { ExecutorService e = new ForkJoinPool(1); - StringTask t = null; try { - Future future = e.submit(t); + Future future = e.submit((Callable) null); shouldThrow(); } catch (NullPointerException success) { } finally {