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

Comparing jsr166/src/test/tck/CountedCompleterTest.java (file contents):
Revision 1.25 by jsr166, Sun Oct 18 19:22:36 2015 UTC vs.
Revision 1.34 by jsr166, Sat Oct 21 06:53:36 2017 UTC

# Line 5 | Line 5
5   */
6  
7   import static java.util.concurrent.TimeUnit.MILLISECONDS;
8 import static java.util.concurrent.TimeUnit.SECONDS;
8  
9   import java.util.HashSet;
10   import java.util.concurrent.CancellationException;
# Line 77 | Line 76 | public class CountedCompleterTest extend
76          assertNull(a.getRawResult());
77  
78          try {
79 <            a.get(0L, SECONDS);
79 >            a.get(randomExpiredTimeout(), randomTimeUnit());
80              shouldThrow();
81          } catch (TimeoutException success) {
82          } catch (Throwable fail) { threadUnexpectedException(fail); }
# Line 95 | Line 94 | public class CountedCompleterTest extend
94              Thread.currentThread().interrupt();
95              long startTime = System.nanoTime();
96              assertNull(a.join());
97 <            assertTrue(millisElapsedSince(startTime) < SMALL_DELAY_MS);
97 >            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
98              Thread.interrupted();
99          }
100  
# Line 103 | Line 102 | public class CountedCompleterTest extend
102              Thread.currentThread().interrupt();
103              long startTime = System.nanoTime();
104              a.quietlyJoin();        // should be no-op
105 <            assertTrue(millisElapsedSince(startTime) < SMALL_DELAY_MS);
105 >            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
106              Thread.interrupted();
107          }
108  
# Line 111 | Line 110 | public class CountedCompleterTest extend
110          assertFalse(a.cancel(true));
111          try {
112              assertNull(a.get());
113 <        } catch (Throwable fail) { threadUnexpectedException(fail); }
114 <        try {
116 <            assertNull(a.get(5L, SECONDS));
117 <        } catch (Throwable fail) { threadUnexpectedException(fail); }
113 >            assertNull(a.get(randomTimeout(), randomTimeUnit()));
114 >        } catch (Exception fail) { threadUnexpectedException(fail); }
115      }
116  
117      void checkCancelled(CountedCompleter a) {
# Line 138 | Line 135 | public class CountedCompleterTest extend
135          {
136              long startTime = System.nanoTime();
137              a.quietlyJoin();        // should be no-op
138 <            assertTrue(millisElapsedSince(startTime) < SMALL_DELAY_MS);
138 >            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
139          }
140  
141          try {
# Line 148 | Line 145 | public class CountedCompleterTest extend
145          } catch (Throwable fail) { threadUnexpectedException(fail); }
146  
147          try {
148 <            a.get(5L, SECONDS);
148 >            a.get(randomTimeout(), randomTimeUnit());
149              shouldThrow();
150          } catch (CancellationException success) {
151          } catch (Throwable fail) { threadUnexpectedException(fail); }
# Line 176 | Line 173 | public class CountedCompleterTest extend
173          {
174              long startTime = System.nanoTime();
175              a.quietlyJoin();        // should be no-op
176 <            assertTrue(millisElapsedSince(startTime) < SMALL_DELAY_MS);
176 >            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
177          }
178  
179          try {
# Line 187 | Line 184 | public class CountedCompleterTest extend
184          } catch (Throwable fail) { threadUnexpectedException(fail); }
185  
186          try {
187 <            a.get(5L, SECONDS);
187 >            a.get(randomTimeout(), randomTimeUnit());
188              shouldThrow();
189          } catch (ExecutionException success) {
190              assertSame(t.getClass(), success.getCause().getClass());
# Line 210 | Line 207 | public class CountedCompleterTest extend
207          final AtomicInteger onCompletionN = new AtomicInteger(0);
208          final AtomicInteger onExceptionalCompletionN = new AtomicInteger(0);
209          final AtomicInteger setRawResultN = new AtomicInteger(0);
210 <        final AtomicReference<Object> rawResult = new AtomicReference<Object>(null);
210 >        final AtomicReference<Object> rawResult = new AtomicReference<>(null);
211          int computeN() { return computeN.get(); }
212          int onCompletionN() { return onCompletionN.get(); }
213          int onExceptionalCompletionN() { return onExceptionalCompletionN.get(); }
# Line 356 | Line 353 | public class CountedCompleterTest extend
353          assertEquals(1, a.getPendingCount());
354          a.addToPendingCount(27);
355          assertEquals(28, a.getPendingCount());
356 +        a.addToPendingCount(-28);
357 +        assertEquals(0, a.getPendingCount());
358      }
359  
360      /**
# Line 497 | Line 496 | public class CountedCompleterTest extend
496      }
497  
498      /**
499 <     * quietlyCompleteRoot completes root task
499 >     * quietlyCompleteRoot completes root task and only root task
500       */
501      public void testQuietlyCompleteRoot() {
502          NoopCC a = new NoopCC();
# Line 700 | Line 699 | public class CountedCompleterTest extend
699                  CCF f = new LCCF(8);
700                  assertSame(f, f.fork());
701                  try {
702 <                    f.get(5L, null);
702 >                    f.get(randomTimeout(), null);
703                      shouldThrow();
704                  } catch (NullPointerException success) {}
705              }};
# Line 1422 | Line 1421 | public class CountedCompleterTest extend
1421                  CCF f = new LCCF(8);
1422                  assertSame(f, f.fork());
1423                  try {
1424 <                    f.get(5L, null);
1424 >                    f.get(randomTimeout(), null);
1425                      shouldThrow();
1426                  } catch (NullPointerException success) {}
1427              }};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines