ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/RecursiveTaskTest.java
(Generate patch)

Comparing jsr166/src/test/tck/RecursiveTaskTest.java (file contents):
Revision 1.24 by jsr166, Mon Nov 22 07:45:50 2010 UTC vs.
Revision 1.32 by jsr166, Sat Apr 25 04:55:31 2015 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7 < import junit.framework.*;
7 > import static java.util.concurrent.TimeUnit.SECONDS;
8 >
9 > import java.util.HashSet;
10   import java.util.concurrent.CancellationException;
11   import java.util.concurrent.ExecutionException;
12   import java.util.concurrent.ForkJoinPool;
13 < import java.util.concurrent.ForkJoinWorkerThread;
13 > import java.util.concurrent.ForkJoinTask;
14   import java.util.concurrent.RecursiveTask;
13 import java.util.concurrent.TimeUnit;
15   import java.util.concurrent.TimeoutException;
16 < import static java.util.concurrent.TimeUnit.SECONDS;
17 < import java.util.HashSet;
16 >
17 > import junit.framework.Test;
18 > import junit.framework.TestSuite;
19  
20   public class RecursiveTaskTest extends JSR166TestCase {
21  
22      public static void main(String[] args) {
23 <        junit.textui.TestRunner.run(suite());
23 >        main(suite(), args);
24      }
25      public static Test suite() {
26          return new TestSuite(RecursiveTaskTest.class);
# Line 59 | Line 61 | public class RecursiveTaskTest extends J
61          assertNull(a.getException());
62          assertNull(a.getRawResult());
63  
64 <        if (! (Thread.currentThread() instanceof ForkJoinWorkerThread)) {
64 >        if (! ForkJoinTask.inForkJoinPool()) {
65              Thread.currentThread().interrupt();
66              try {
67                  a.get();
# Line 152 | Line 154 | public class RecursiveTaskTest extends J
154          assertFalse(a.isCancelled());
155          assertFalse(a.isCompletedNormally());
156          assertTrue(a.isCompletedAbnormally());
157 <        assertSame(t, a.getException());
157 >        assertSame(t.getClass(), a.getException().getClass());
158          assertNull(a.getRawResult());
159          assertFalse(a.cancel(false));
160          assertFalse(a.cancel(true));
# Line 161 | Line 163 | public class RecursiveTaskTest extends J
163              a.join();
164              shouldThrow();
165          } catch (Throwable expected) {
166 <            assertSame(t, expected);
166 >            assertSame(t.getClass(), expected.getClass());
167          }
168  
169          try {
170              a.get();
171              shouldThrow();
172          } catch (ExecutionException success) {
173 <            assertSame(t, success.getCause());
173 >            assertSame(t.getClass(), success.getCause().getClass());
174          } catch (Throwable fail) { threadUnexpectedException(fail); }
175  
176          try {
177              a.get(5L, SECONDS);
178              shouldThrow();
179          } catch (ExecutionException success) {
180 <            assertSame(t, success.getCause());
180 >            assertSame(t.getClass(), success.getCause().getClass());
181          } catch (Throwable fail) { threadUnexpectedException(fail); }
182      }
183  
184 <    static final class FJException extends RuntimeException {
185 <        FJException() { super(); }
184 >    public static final class FJException extends RuntimeException {
185 >        public FJException() { super(); }
186      }
187  
188      // An invalid return value for Fib
# Line 318 | Line 320 | public class RecursiveTaskTest extends J
320          assertEquals(21, (int) testInvokeOnPool(mainPool(), a));
321      }
322  
321
323      /**
324       * helpQuiesce returns when tasks are complete.
325       * getQueuedTaskCount returns 0 when quiescent
# Line 328 | Line 329 | public class RecursiveTaskTest extends J
329              public Integer realCompute() {
330                  FibTask f = new FibTask(8);
331                  assertSame(f, f.fork());
332 <                f.helpQuiesce();
332 >                helpQuiesce();
333                  assertEquals(0, getQueuedTaskCount());
334                  checkCompletedNormally(f, 21);
335                  return NoResult;
# Line 336 | Line 337 | public class RecursiveTaskTest extends J
337          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
338      }
339  
339
340      /**
341       * invoke task throws exception when task completes abnormally
342       */
# Line 762 | Line 762 | public class RecursiveTaskTest extends J
762          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
763      }
764  
765
765      /**
766       * invokeAll(tasks) with any null task throws NPE
767       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines