@Test public void periodicFixedDelayTaskWithException() { final CountDownLatch countDownLatch = new CountDownLatch(1); final ScheduledFuture<?> scheduledFuture = scheduledService.periodicFixedDelayTask(1, "Planned exception", countDownLatch); try { countDownLatch.await(200, TimeUnit.MILLISECONDS); scheduledFuture.get(200, TimeUnit.MILLISECONDS); } catch (ExecutionException e) { assertEquals("Planned exception", e.getCause().getMessage()); } catch (Exception e) { fail("Unexpected exception" + e); } if (!scheduledFuture.isCancelled()) { scheduledFuture.cancel(true); LOGGER.info("task stopped"); } }
public ScheduledFuture<?> periodicFixedDelayTask(final int value, final String errorMessage, final CountDownLatch countDownLatch) { LOGGER.info("longRunnableTask scheduled"); return executor.scheduleAtFixedRate( longRunnableTask(value, 10, errorMessage, countDownLatch), 0, 100, TimeUnit.MILLISECONDS); }
ManagedScheduledService { public ScheduledFuture<?> periodicFixedDelayTask(final int value, final String errorMessage, final CountDownLatch countDownLatch) { LOGGER.info("longRunnableTask scheduled"); return executor.scheduleAtFixedRate( longRunnableTask(value, 10, errorMessage, countDownLatch), 0, 100, TimeUnit.MILLISECONDS); } }
ManagedScheduledService { public ScheduledFuture<?> periodicFixedDelayTask(final int value, final String errorMessage, final CountDownLatch countDownLatch) { LOGGER.info("longRunnableTask scheduled"); return executor.scheduleAtFixedRate( longRunnableTask(value, 10, errorMessage, countDownLatch), 0, 100, TimeUnit.MILLISECONDS); }  }
ManagedScheduledService { public ScheduledFuture<?> periodicFixedDelayTask(final int value, final String errorMessage, final CountDownLatch countDownLatch) { LOGGER.info("longRunnableTask scheduled"); return executor.scheduleAtFixedRate( longRunnableTask(value, 10, errorMessage, countDownLatch), 0, 100, TimeUnit.MILLISECONDS); }  Future<Integer> singleFixedDelayTask(final int value,
                                                final String errorMessage); ScheduledFuture<?> periodicFixedDelayTask(final int value,
                                                     final String errorMessage,
                                                     final CountDownLatch countDownLatch); }
ManagedScheduledService { public ScheduledFuture<?> periodicFixedDelayTask(final int value, final String errorMessage, final CountDownLatch countDownLatch) { LOGGER.info("longRunnableTask scheduled"); return executor.scheduleAtFixedRate( longRunnableTask(value, 10, errorMessage, countDownLatch), 0, 100, TimeUnit.MILLISECONDS); }  Future<Integer> singleFixedDelayTask(final int value,
                                                final String errorMessage); ScheduledFuture<?> periodicFixedDelayTask(final int value,
                                                     final String errorMessage,
                                                     final CountDownLatch countDownLatch);  }