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

Comparing jsr166/src/test/tck/ScheduledExecutorTest.java (file contents):
Revision 1.73 by jsr166, Tue Oct 6 06:02:53 2015 UTC vs.
Revision 1.75 by jsr166, Thu Oct 8 03:03:36 2015 UTC

# Line 1046 | Line 1046 | public class ScheduledExecutorTest exten
1046      public void testTimedInvokeAny4() throws Exception {
1047          final ExecutorService e = new ScheduledThreadPoolExecutor(2);
1048          try (PoolCleaner cleaner = cleaner(e)) {
1049 +            long startTime = System.nanoTime();
1050              List<Callable<String>> l = new ArrayList<Callable<String>>();
1051              l.add(new NPETask());
1052              try {
1053 <                e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1053 >                e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS);
1054                  shouldThrow();
1055              } catch (ExecutionException success) {
1056                  assertTrue(success.getCause() instanceof NullPointerException);
1057              }
1058 +            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1059          }
1060      }
1061  
# Line 1168 | Line 1170 | public class ScheduledExecutorTest exten
1170       * timed invokeAll(c) cancels tasks not completed by timeout
1171       */
1172      public void testTimedInvokeAll6() throws Exception {
1173 <        final ExecutorService e = new ScheduledThreadPoolExecutor(2);
1174 <        try (PoolCleaner cleaner = cleaner(e)) {
1175 <            for (long timeout = timeoutMillis();;) {
1173 >        for (long timeout = timeoutMillis();;) {
1174 >            final CountDownLatch done = new CountDownLatch(1);
1175 >            final Callable<String> waiter = new CheckedCallable<String>() {
1176 >                public String realCall() {
1177 >                    try { done.await(LONG_DELAY_MS, MILLISECONDS); }
1178 >                    catch (InterruptedException ok) {}
1179 >                    return "1"; }};
1180 >            final ExecutorService p = new ScheduledThreadPoolExecutor(2);
1181 >            try (PoolCleaner cleaner = cleaner(p, done)) {
1182                  List<Callable<String>> tasks = new ArrayList<>();
1183                  tasks.add(new StringTask("0"));
1184 <                tasks.add(Executors.callable(new LongPossiblyInterruptedRunnable(), TEST_STRING));
1184 >                tasks.add(waiter);
1185                  tasks.add(new StringTask("2"));
1186                  long startTime = System.nanoTime();
1187                  List<Future<String>> futures =
1188 <                    e.invokeAll(tasks, timeout, MILLISECONDS);
1188 >                    p.invokeAll(tasks, timeout, MILLISECONDS);
1189                  assertEquals(tasks.size(), futures.size());
1190                  assertTrue(millisElapsedSince(startTime) >= timeout);
1191                  for (Future future : futures)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines