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

Comparing jsr166/src/test/tck/ScheduledExecutorSubclassTest.java (file contents):
Revision 1.55 by jsr166, Tue Oct 6 05:56:01 2015 UTC vs.
Revision 1.59 by jsr166, Sun Oct 25 02:58:25 2015 UTC

# Line 220 | Line 220 | public class ScheduledExecutorSubclassTe
220                      normalizedTime <= cycles)
221                      return;
222              }
223 <            throw new AssertionError("unexpected execution rate");
223 >            fail("unexpected execution rate");
224          }
225      }
226  
# Line 246 | Line 246 | public class ScheduledExecutorSubclassTe
246                      normalizedTime <= cycles)
247                      return;
248              }
249 <            throw new AssertionError("unexpected execution rate");
249 >            fail("unexpected execution rate");
250          }
251      }
252  
# Line 1097 | Line 1097 | public class ScheduledExecutorSubclassTe
1097      public void testTimedInvokeAny4() throws Exception {
1098          final ExecutorService e = new CustomExecutor(2);
1099          try (PoolCleaner cleaner = cleaner(e)) {
1100 +            long startTime = System.nanoTime();
1101              List<Callable<String>> l = new ArrayList<Callable<String>>();
1102              l.add(new NPETask());
1103              try {
1104 <                e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1104 >                e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS);
1105                  shouldThrow();
1106              } catch (ExecutionException success) {
1107                  assertTrue(success.getCause() instanceof NullPointerException);
1108              }
1109 +            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1110          }
1111      }
1112  
# Line 1114 | Line 1116 | public class ScheduledExecutorSubclassTe
1116      public void testTimedInvokeAny5() throws Exception {
1117          final ExecutorService e = new CustomExecutor(2);
1118          try (PoolCleaner cleaner = cleaner(e)) {
1119 +            long startTime = System.nanoTime();
1120              List<Callable<String>> l = new ArrayList<Callable<String>>();
1121              l.add(new StringTask());
1122              l.add(new StringTask());
1123 <            String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1123 >            String result = e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS);
1124              assertSame(TEST_STRING, result);
1125 +            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1126          }
1127      }
1128  
# Line 1218 | Line 1222 | public class ScheduledExecutorSubclassTe
1222       * timed invokeAll(c) cancels tasks not completed by timeout
1223       */
1224      public void testTimedInvokeAll6() throws Exception {
1225 <        final ExecutorService e = new CustomExecutor(2);
1226 <        try (PoolCleaner cleaner = cleaner(e)) {
1227 <            for (long timeout = timeoutMillis();;) {
1225 >        for (long timeout = timeoutMillis();;) {
1226 >            final CountDownLatch done = new CountDownLatch(1);
1227 >            final Callable<String> waiter = new CheckedCallable<String>() {
1228 >                public String realCall() {
1229 >                    try { done.await(LONG_DELAY_MS, MILLISECONDS); }
1230 >                    catch (InterruptedException ok) {}
1231 >                    return "1"; }};
1232 >            final ExecutorService p = new CustomExecutor(2);
1233 >            try (PoolCleaner cleaner = cleaner(p, done)) {
1234                  List<Callable<String>> tasks = new ArrayList<>();
1235                  tasks.add(new StringTask("0"));
1236 <                tasks.add(Executors.callable(new LongPossiblyInterruptedRunnable(), TEST_STRING));
1236 >                tasks.add(waiter);
1237                  tasks.add(new StringTask("2"));
1238                  long startTime = System.nanoTime();
1239                  List<Future<String>> futures =
1240 <                    e.invokeAll(tasks, timeout, MILLISECONDS);
1240 >                    p.invokeAll(tasks, timeout, MILLISECONDS);
1241                  assertEquals(tasks.size(), futures.size());
1242                  assertTrue(millisElapsedSince(startTime) >= timeout);
1243                  for (Future future : futures)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines