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

Comparing jsr166/src/test/tck/ForkJoinPoolTest.java (file contents):
Revision 1.65 by jsr166, Tue Oct 6 21:22:54 2015 UTC vs.
Revision 1.68 by jsr166, Thu Oct 8 03:08:37 2015 UTC

# Line 64 | Line 64 | public class ForkJoinPoolTest extends JS
64          }
65      }
66  
67 +    static class MyError extends Error {}
68 +
69      // to test handlers
70      static class FailingFJWSubclass extends ForkJoinWorkerThread {
71          public FailingFJWSubclass(ForkJoinPool p) { super(p) ; }
72 <        protected void onStart() { super.onStart(); throw new Error(); }
72 >        protected void onStart() { super.onStart(); throw new MyError(); }
73      }
74  
75      static class FailingThreadFactory
# Line 259 | Line 261 | public class ForkJoinPoolTest extends JS
261          final Thread.UncaughtExceptionHandler ueh =
262              new Thread.UncaughtExceptionHandler() {
263                  public void uncaughtException(Thread t, Throwable e) {
264 +                    threadAssertTrue(e instanceof MyError);
265 +                    threadAssertTrue(t instanceof FailingFJWSubclass);
266                      uehInvoked.countDown();
267                  }};
268          ForkJoinPool p = new ForkJoinPool(1, new FailingThreadFactory(),
# Line 266 | Line 270 | public class ForkJoinPoolTest extends JS
270          try (PoolCleaner cleaner = cleaner(p)) {
271              assertSame(ueh, p.getUncaughtExceptionHandler());
272              try {
273 <                try {
274 <                    p.execute(new FibTask(8));
271 <                    await(uehInvoked);
272 <                } catch (RejectedExecutionException ok) {}
273 >                p.execute(new FibTask(8));
274 >                await(uehInvoked);
275              } finally {
276                  p.shutdownNow(); // failure might have prevented processing task
277              }
# Line 819 | Line 821 | public class ForkJoinPoolTest extends JS
821      public void testTimedInvokeAny4() throws Throwable {
822          ExecutorService e = new ForkJoinPool(1);
823          try (PoolCleaner cleaner = cleaner(e)) {
824 +            long startTime = System.nanoTime();
825              List<Callable<String>> l = new ArrayList<Callable<String>>();
826              l.add(new NPETask());
827              try {
828 <                e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
828 >                e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS);
829                  shouldThrow();
830              } catch (ExecutionException success) {
831                  assertTrue(success.getCause() instanceof NullPointerException);
832              }
833 +            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
834          }
835      }
836  
# Line 836 | Line 840 | public class ForkJoinPoolTest extends JS
840      public void testTimedInvokeAny5() throws Throwable {
841          ExecutorService e = new ForkJoinPool(1);
842          try (PoolCleaner cleaner = cleaner(e)) {
843 +            long startTime = System.nanoTime();
844              List<Callable<String>> l = new ArrayList<Callable<String>>();
845              l.add(new StringTask());
846              l.add(new StringTask());
847 <            String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
847 >            String result = e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS);
848              assertSame(TEST_STRING, result);
849 +            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
850          }
851      }
852  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines