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

Comparing jsr166/src/test/tck/ForkJoinTaskTest.java (file contents):
Revision 1.36 by jsr166, Mon Jul 22 18:01:03 2013 UTC vs.
Revision 1.44 by jsr166, Tue Oct 6 00:36:55 2015 UTC

# Line 3 | Line 3
3   * Expert Group and released to the public domain, as explained at
4   * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6 < import java.util.concurrent.ExecutionException;
6 >
7 > import static java.util.concurrent.TimeUnit.MILLISECONDS;
8 > import static java.util.concurrent.TimeUnit.SECONDS;
9 >
10 > import java.util.HashSet;
11   import java.util.concurrent.CancellationException;
12 + import java.util.concurrent.ExecutionException;
13   import java.util.concurrent.ForkJoinPool;
14   import java.util.concurrent.ForkJoinTask;
10 import java.util.concurrent.ForkJoinWorkerThread;
15   import java.util.concurrent.RecursiveAction;
12 import java.util.concurrent.TimeUnit;
16   import java.util.concurrent.TimeoutException;
17   import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
18 < import static java.util.concurrent.TimeUnit.MILLISECONDS;
19 < import static java.util.concurrent.TimeUnit.SECONDS;
20 < import java.util.HashSet;
18 < import junit.framework.*;
18 >
19 > import junit.framework.Test;
20 > import junit.framework.TestSuite;
21  
22   public class ForkJoinTaskTest extends JSR166TestCase {
23  
24      public static void main(String[] args) {
25 <        junit.textui.TestRunner.run(suite());
25 >        main(suite(), args);
26      }
27  
28      public static Test suite() {
# Line 46 | Line 48 | public class ForkJoinTaskTest extends JS
48      }
49  
50      private void testInvokeOnPool(ForkJoinPool pool, RecursiveAction a) {
51 <        try {
51 >        try (PoolCleaner cleaner = cleaner(pool)) {
52              assertFalse(a.isDone());
53              assertFalse(a.isCompletedNormally());
54              assertFalse(a.isCompletedAbnormally());
# Line 62 | Line 64 | public class ForkJoinTaskTest extends JS
64              assertFalse(a.isCancelled());
65              assertNull(a.getException());
66              assertNull(a.getRawResult());
65        } finally {
66            joinPool(pool);
67          }
68      }
69  
# Line 96 | Line 96 | public class ForkJoinTaskTest extends JS
96  
97          {
98              Thread.currentThread().interrupt();
99 <            long t0 = System.nanoTime();
99 >            long startTime = System.nanoTime();
100              assertSame(expected, a.join());
101 <            assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
101 >            assertTrue(millisElapsedSince(startTime) < SMALL_DELAY_MS);
102              Thread.interrupted();
103          }
104  
105          {
106              Thread.currentThread().interrupt();
107 <            long t0 = System.nanoTime();
107 >            long startTime = System.nanoTime();
108              a.quietlyJoin();        // should be no-op
109 <            assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
109 >            assertTrue(millisElapsedSince(startTime) < SMALL_DELAY_MS);
110              Thread.interrupted();
111          }
112  
# Line 139 | Line 139 | public class ForkJoinTaskTest extends JS
139          Thread.interrupted();
140  
141          {
142 <            long t0 = System.nanoTime();
142 >            long startTime = System.nanoTime();
143              a.quietlyJoin();        // should be no-op
144 <            assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
144 >            assertTrue(millisElapsedSince(startTime) < SMALL_DELAY_MS);
145          }
146  
147          try {
# Line 177 | Line 177 | public class ForkJoinTaskTest extends JS
177          Thread.interrupted();
178  
179          {
180 <            long t0 = System.nanoTime();
180 >            long startTime = System.nanoTime();
181              a.quietlyJoin();        // should be no-op
182 <            assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
182 >            assertTrue(millisElapsedSince(startTime) < SMALL_DELAY_MS);
183          }
184  
185          try {
# Line 216 | Line 216 | public class ForkJoinTaskTest extends JS
216              AtomicIntegerFieldUpdater.newUpdater(BinaryAsyncAction.class,
217                                                   "controlState");
218  
219 <        private BinaryAsyncAction parent;
219 >        private volatile BinaryAsyncAction parent;
220  
221 <        private BinaryAsyncAction sibling;
221 >        private volatile BinaryAsyncAction sibling;
222  
223          protected BinaryAsyncAction() {
224          }
# Line 918 | Line 918 | public class ForkJoinTaskTest extends JS
918      }
919  
920      /**
921 <     * invokeAll(collection)  throws exception if any task does
921 >     * invokeAll(collection) throws exception if any task does
922       */
923      public void testAbnormalInvokeAllCollection() {
924          RecursiveAction a = new CheckedRecursiveAction() {
# Line 1585 | Line 1585 | public class ForkJoinTaskTest extends JS
1585      }
1586  
1587      /**
1588 <     * invokeAll(collection)  throws exception if any task does
1588 >     * invokeAll(collection) throws exception if any task does
1589       */
1590      public void testAbnormalInvokeAllCollectionSingleton() {
1591          RecursiveAction a = new CheckedRecursiveAction() {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines