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.75 by jsr166, Thu Oct 8 03:03:36 2015 UTC vs.
Revision 1.78 by jsr166, Sun Oct 25 02:58:25 2015 UTC

# Line 164 | Line 164 | public class ScheduledExecutorTest exten
164                      normalizedTime <= cycles)
165                      return;
166              }
167 <            throw new AssertionError("unexpected execution rate");
167 >            fail("unexpected execution rate");
168          }
169      }
170  
# Line 190 | Line 190 | public class ScheduledExecutorTest exten
190                      normalizedTime <= cycles)
191                      return;
192              }
193 <            throw new AssertionError("unexpected execution rate");
193 >            fail("unexpected execution rate");
194          }
195      }
196  
# Line 1065 | Line 1065 | public class ScheduledExecutorTest exten
1065      public void testTimedInvokeAny5() throws Exception {
1066          final ExecutorService e = new ScheduledThreadPoolExecutor(2);
1067          try (PoolCleaner cleaner = cleaner(e)) {
1068 +            long startTime = System.nanoTime();
1069              List<Callable<String>> l = new ArrayList<Callable<String>>();
1070              l.add(new StringTask());
1071              l.add(new StringTask());
1072 <            String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1072 >            String result = e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS);
1073              assertSame(TEST_STRING, result);
1074 +            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1075          }
1076      }
1077  
# Line 1204 | Line 1206 | public class ScheduledExecutorTest exten
1206          }
1207      }
1208  
1209 +    /**
1210 +     * A fixed delay task with overflowing period should not prevent a
1211 +     * one-shot task from executing.
1212 +     * https://bugs.openjdk.java.net/browse/JDK-8051859
1213 +     */
1214 +    public void testScheduleWithFixedDelay_overflow() throws Exception {
1215 +        final CountDownLatch delayedDone = new CountDownLatch(1);
1216 +        final CountDownLatch immediateDone = new CountDownLatch(1);
1217 +        final ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
1218 +        try (PoolCleaner cleaner = cleaner(p)) {
1219 +            final Runnable immediate = new Runnable() { public void run() {
1220 +                immediateDone.countDown();
1221 +            }};
1222 +            final Runnable delayed = new Runnable() { public void run() {
1223 +                delayedDone.countDown();
1224 +                p.submit(immediate);
1225 +            }};
1226 +            p.scheduleWithFixedDelay(delayed, 0L, Long.MAX_VALUE, SECONDS);
1227 +            await(delayedDone);
1228 +            await(immediateDone);
1229 +        }
1230 +    }
1231 +
1232   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines