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

Comparing jsr166/src/test/tck/RecursiveActionTest.java (file contents):
Revision 1.49 by jsr166, Sat Mar 18 18:20:00 2017 UTC vs.
Revision 1.54 by jsr166, Mon May 28 21:49:32 2018 UTC

# Line 4 | Line 4
4   * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7 < import static java.util.concurrent.TimeUnit.SECONDS;
7 > import static java.util.concurrent.TimeUnit.MILLISECONDS;
8  
9   import java.util.Arrays;
10   import java.util.HashSet;
# Line 73 | Line 73 | public class RecursiveActionTest extends
73  
74              Thread.currentThread().interrupt();
75              try {
76 <                a.get(5L, SECONDS);
76 >                a.get(randomTimeout(), randomTimeUnit());
77                  shouldThrow();
78              } catch (InterruptedException success) {
79              } catch (Throwable fail) { threadUnexpectedException(fail); }
80          }
81  
82          try {
83 <            a.get(0L, SECONDS);
83 >            a.get(randomExpiredTimeout(), randomTimeUnit());
84              shouldThrow();
85          } catch (TimeoutException success) {
86          } catch (Throwable fail) { threadUnexpectedException(fail); }
# Line 98 | Line 98 | public class RecursiveActionTest extends
98          assertFalse(a.cancel(true));
99          try {
100              assertNull(a.get());
101 <        } catch (Throwable fail) { threadUnexpectedException(fail); }
102 <        try {
103 <            assertNull(a.get(5L, SECONDS));
101 >            assertNull(a.get(randomTimeout(), randomTimeUnit()));
102          } catch (Throwable fail) { threadUnexpectedException(fail); }
103      }
104  
# Line 125 | Line 123 | public class RecursiveActionTest extends
123          } catch (Throwable fail) { threadUnexpectedException(fail); }
124  
125          try {
126 <            a.get(5L, SECONDS);
126 >            a.get(randomTimeout(), randomTimeUnit());
127              shouldThrow();
128          } catch (CancellationException success) {
129          } catch (Throwable fail) { threadUnexpectedException(fail); }
# Line 156 | Line 154 | public class RecursiveActionTest extends
154          } catch (Throwable fail) { threadUnexpectedException(fail); }
155  
156          try {
157 <            a.get(5L, SECONDS);
157 >            a.get(randomTimeout(), randomTimeUnit());
158              shouldThrow();
159          } catch (ExecutionException success) {
160              assertSame(t.getClass(), success.getCause().getClass());
# Line 327 | Line 325 | public class RecursiveActionTest extends
325       * succeeds in the presence of interrupts
326       */
327      public void testJoinIgnoresInterruptsOutsideForkJoinPool() {
328 <        final SynchronousQueue<FibAction[]> sq =
331 <            new SynchronousQueue<FibAction[]>();
328 >        final SynchronousQueue<FibAction[]> sq = new SynchronousQueue<>();
329          RecursiveAction a = new CheckedRecursiveAction() {
330              protected void realCompute() throws InterruptedException {
331                  FibAction[] fibActions = new FibAction[6];
# Line 340 | Line 337 | public class RecursiveActionTest extends
337                  fibActions[4].cancel(true);
338                  fibActions[5].completeExceptionally(new FJException());
339  
340 <                for (int i = 0; i < fibActions.length; i++)
341 <                    fibActions[i].fork();
340 >                for (FibAction fibAction : fibActions)
341 >                    fibAction.fork();
342  
343                  sq.put(fibActions);
344  
# Line 442 | Line 439 | public class RecursiveActionTest extends
439              protected void realCompute() throws Exception {
440                  FibAction f = new FibAction(8);
441                  assertSame(f, f.fork());
442 <                assertNull(f.get(5L, SECONDS));
442 >                assertNull(f.get(LONG_DELAY_MS, MILLISECONDS));
443                  assertEquals(21, f.result);
444                  checkCompletedNormally(f);
445              }};
# Line 458 | Line 455 | public class RecursiveActionTest extends
455                  FibAction f = new FibAction(8);
456                  assertSame(f, f.fork());
457                  try {
458 <                    f.get(5L, null);
458 >                    f.get(randomTimeout(), null);
459                      shouldThrow();
460                  } catch (NullPointerException success) {}
461              }};
# Line 577 | Line 574 | public class RecursiveActionTest extends
574                  FailingFibAction f = new FailingFibAction(8);
575                  assertSame(f, f.fork());
576                  try {
577 <                    f.get(5L, SECONDS);
577 >                    f.get(LONG_DELAY_MS, MILLISECONDS);
578                      shouldThrow();
579                  } catch (ExecutionException success) {
580                      Throwable cause = success.getCause();
# Line 669 | Line 666 | public class RecursiveActionTest extends
666                  assertTrue(f.cancel(true));
667                  assertSame(f, f.fork());
668                  try {
669 <                    f.get(5L, SECONDS);
669 >                    f.get(LONG_DELAY_MS, MILLISECONDS);
670                      shouldThrow();
671                  } catch (CancellationException success) {
672                      checkCancelled(f);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines