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

Comparing jsr166/src/test/tck/ThreadPoolExecutorTest.java (file contents):
Revision 1.115 by jsr166, Mon Mar 20 00:21:54 2017 UTC vs.
Revision 1.118 by jsr166, Mon May 29 19:15:03 2017 UTC

# Line 90 | Line 90 | public class ThreadPoolExecutorTest exte
90              final Runnable task = new CheckedRunnable() {
91                  public void realRun() { done.countDown(); }};
92              p.execute(task);
93 <            assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS));
93 >            await(done);
94          }
95      }
96  
# Line 184 | Line 184 | public class ThreadPoolExecutorTest exte
184                  public void realRun() throws InterruptedException {
185                      threadStarted.countDown();
186                      assertEquals(0, p.getCompletedTaskCount());
187 <                    threadProceed.await();
187 >                    await(threadProceed);
188                      threadDone.countDown();
189                  }});
190              await(threadStarted);
191              assertEquals(0, p.getCompletedTaskCount());
192              threadProceed.countDown();
193 <            threadDone.await();
193 >            await(threadDone);
194              long startTime = System.nanoTime();
195              while (p.getCompletedTaskCount() != 1) {
196                  if (millisElapsedSince(startTime) > LONG_DELAY_MS)
# Line 274 | Line 274 | public class ThreadPoolExecutorTest exte
274      }
275  
276      /**
277 +     * The default rejected execution handler is AbortPolicy.
278 +     */
279 +    public void testDefaultRejectedExecutionHandler() {
280 +        final ThreadPoolExecutor p =
281 +            new ThreadPoolExecutor(1, 2,
282 +                                   LONG_DELAY_MS, MILLISECONDS,
283 +                                   new ArrayBlockingQueue<Runnable>(10));
284 +        try (PoolCleaner cleaner = cleaner(p)) {
285 +            assertTrue(p.getRejectedExecutionHandler()
286 +                       instanceof ThreadPoolExecutor.AbortPolicy);
287 +        }
288 +    }
289 +
290 +    /**
291       * getRejectedExecutionHandler returns handler in constructor if not set
292       */
293      public void testGetRejectedExecutionHandler() {
# Line 456 | Line 470 | public class ThreadPoolExecutorTest exte
470              assertFalse(p.awaitTermination(Long.MIN_VALUE, MILLISECONDS));
471              assertFalse(p.awaitTermination(-1L, NANOSECONDS));
472              assertFalse(p.awaitTermination(-1L, MILLISECONDS));
473 <            assertFalse(p.awaitTermination(0L, NANOSECONDS));
474 <            assertFalse(p.awaitTermination(0L, MILLISECONDS));
473 >            assertFalse(p.awaitTermination(randomExpiredTimeout(),
474 >                                           randomTimeUnit()));
475              long timeoutNanos = 999999L;
476              long startTime = System.nanoTime();
477              assertFalse(p.awaitTermination(timeoutNanos, NANOSECONDS));
# Line 1927 | Line 1941 | public class ThreadPoolExecutorTest exte
1941                      public void realRun() {
1942                          done.countDown();
1943                      }});
1944 <            assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS));
1944 >            await(done);
1945          }
1946      }
1947  
# Line 2020 | Line 2034 | public class ThreadPoolExecutorTest exte
2034                  }
2035              }
2036              // enough time to run all tasks
2037 <            assertTrue(done.await(nTasks * SHORT_DELAY_MS, MILLISECONDS));
2037 >            await(done, nTasks * SHORT_DELAY_MS);
2038          }
2039      }
2040  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines