@Test public void shouldRescheduleWithADelay() throws ExecutionException, InterruptedException { given(scheduledService.scheduleAtFixedRate(any(Runnable.class), anyLong(), anyLong(), any(TimeUnit.class))) .willReturn(mock(ScheduledFuture.class)); given(mockMonitor.isShutdown()).willReturn(false).willReturn(false).willReturn(true); watchDog.startReaper(); ArgumentCaptor<Long> captor = ArgumentCaptor.forClass(Long.class); verify(scheduledService).scheduleAtFixedRate(eq(mockReaper), captor.capture(), anyLong(), any(TimeUnit.class)); Long delay = captor.getValue(); assertThat(delay).isGreaterThan(0); }
public void startReaper() { if (monitor.isShutdown()) { log("Not scheduling the Watch Dog, shutdown in progress."); return; } log("Scheduling the CTS Reaper every " + config.getRunPeriod() + "ms"); workerPool.submit(new WatchDog()); }
CTSReaperWatchDog { public void startReaper() { if (monitor.isShutdown()) { log("Not scheduling the Watch Dog, shutdown in progress."); return; } log("Scheduling the CTS Reaper every " + config.getRunPeriod() + "ms"); workerPool.submit(new WatchDog()); } }
CTSReaperWatchDog { public void startReaper() { if (monitor.isShutdown()) { log("Not scheduling the Watch Dog, shutdown in progress."); return; } log("Scheduling the CTS Reaper every " + config.getRunPeriod() + "ms"); workerPool.submit(new WatchDog()); } @Inject  CTSReaperWatchDog(CTSReaper reaper, CoreTokenConfig config,
                             ReaperShutdownMonitor monitor,
                             @Named(CoreTokenConstants.CTS_SCHEDULED_SERVICE) ScheduledExecutorService scheduledService,
                             @Named(CoreTokenConstants.CTS_WORKER_POOL) ExecutorService workerPool,
                             @Named(CoreTokenConstants.CTS_REAPER_DEBUG) Debug debug); }
CTSReaperWatchDog { public void startReaper() { if (monitor.isShutdown()) { log("Not scheduling the Watch Dog, shutdown in progress."); return; } log("Scheduling the CTS Reaper every " + config.getRunPeriod() + "ms"); workerPool.submit(new WatchDog()); } @Inject  CTSReaperWatchDog(CTSReaper reaper, CoreTokenConfig config,
                             ReaperShutdownMonitor monitor,
                             @Named(CoreTokenConstants.CTS_SCHEDULED_SERVICE) ScheduledExecutorService scheduledService,
                             @Named(CoreTokenConstants.CTS_WORKER_POOL) ExecutorService workerPool,
                             @Named(CoreTokenConstants.CTS_REAPER_DEBUG) Debug debug); void startReaper(); }
CTSReaperWatchDog { public void startReaper() { if (monitor.isShutdown()) { log("Not scheduling the Watch Dog, shutdown in progress."); return; } log("Scheduling the CTS Reaper every " + config.getRunPeriod() + "ms"); workerPool.submit(new WatchDog()); } @Inject  CTSReaperWatchDog(CTSReaper reaper, CoreTokenConfig config,
                             ReaperShutdownMonitor monitor,
                             @Named(CoreTokenConstants.CTS_SCHEDULED_SERVICE) ScheduledExecutorService scheduledService,
                             @Named(CoreTokenConstants.CTS_WORKER_POOL) ExecutorService workerPool,
                             @Named(CoreTokenConstants.CTS_REAPER_DEBUG) Debug debug); void startReaper();  }