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.30 by jsr166, Wed Dec 31 16:44:02 2014 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.*;
8   import java.util.concurrent.CancellationException;
9   import java.util.concurrent.ExecutionException;
10   import java.util.concurrent.ForkJoinPool;
11 < import java.util.concurrent.ForkJoinWorkerThread;
11 > import java.util.concurrent.ForkJoinTask;
12   import java.util.concurrent.RecursiveTask;
13 import java.util.concurrent.TimeUnit;
13   import java.util.concurrent.TimeoutException;
14   import static java.util.concurrent.TimeUnit.SECONDS;
15   import java.util.HashSet;
# Line 59 | Line 58 | public class RecursiveTaskTest extends J
58          assertNull(a.getException());
59          assertNull(a.getRawResult());
60  
61 <        if (! (Thread.currentThread() instanceof ForkJoinWorkerThread)) {
61 >        if (! ForkJoinTask.inForkJoinPool()) {
62              Thread.currentThread().interrupt();
63              try {
64                  a.get();
# Line 152 | Line 151 | public class RecursiveTaskTest extends J
151          assertFalse(a.isCancelled());
152          assertFalse(a.isCompletedNormally());
153          assertTrue(a.isCompletedAbnormally());
154 <        assertSame(t, a.getException());
154 >        assertSame(t.getClass(), a.getException().getClass());
155          assertNull(a.getRawResult());
156          assertFalse(a.cancel(false));
157          assertFalse(a.cancel(true));
# Line 161 | Line 160 | public class RecursiveTaskTest extends J
160              a.join();
161              shouldThrow();
162          } catch (Throwable expected) {
163 <            assertSame(t, expected);
163 >            assertSame(t.getClass(), expected.getClass());
164          }
165  
166          try {
167              a.get();
168              shouldThrow();
169          } catch (ExecutionException success) {
170 <            assertSame(t, success.getCause());
170 >            assertSame(t.getClass(), success.getCause().getClass());
171          } catch (Throwable fail) { threadUnexpectedException(fail); }
172  
173          try {
174              a.get(5L, SECONDS);
175              shouldThrow();
176          } catch (ExecutionException success) {
177 <            assertSame(t, success.getCause());
177 >            assertSame(t.getClass(), success.getCause().getClass());
178          } catch (Throwable fail) { threadUnexpectedException(fail); }
179      }
180  
181 <    static final class FJException extends RuntimeException {
182 <        FJException() { super(); }
181 >    public static final class FJException extends RuntimeException {
182 >        public FJException() { super(); }
183      }
184  
185      // An invalid return value for Fib
# Line 318 | Line 317 | public class RecursiveTaskTest extends J
317          assertEquals(21, (int) testInvokeOnPool(mainPool(), a));
318      }
319  
321
320      /**
321       * helpQuiesce returns when tasks are complete.
322       * getQueuedTaskCount returns 0 when quiescent
# Line 328 | Line 326 | public class RecursiveTaskTest extends J
326              public Integer realCompute() {
327                  FibTask f = new FibTask(8);
328                  assertSame(f, f.fork());
329 <                f.helpQuiesce();
329 >                helpQuiesce();
330                  assertEquals(0, getQueuedTaskCount());
331                  checkCompletedNormally(f, 21);
332                  return NoResult;
# Line 336 | Line 334 | public class RecursiveTaskTest extends J
334          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
335      }
336  
339
337      /**
338       * invoke task throws exception when task completes abnormally
339       */
# Line 762 | Line 759 | public class RecursiveTaskTest extends J
759          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
760      }
761  
765
762      /**
763       * invokeAll(tasks) with any null task throws NPE
764       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines