Scheduler { public void shutdown() throws InterruptedException { logger.info("shutting down scheduler"); scheduler.shutdown(); try { boolean success = scheduler.awaitTermination(5000, TimeUnit.MILLISECONDS); if (!success) logger.warn("failed to terminate scheduler"); } finally { jobExecutor.shutdown(); } } Scheduler(LogManager logManager);   Scheduler(LogManager logManager, ScheduledExecutorService scheduler, ExecutorService jobExecutor); void start(); void shutdown(); void awaitTermination(long timeoutInMs); void addFixedRateTask(String name, Job job, Duration rate); void addTriggerTask(String name, Job job, Trigger trigger); void triggerNow(String name); final Map<String, Task> tasks; public Clock clock; }
@Test void shutdown() throws InterruptedException { when(schedulerExecutor.awaitTermination(anyLong(), eq(TimeUnit.MILLISECONDS))).thenReturn(Boolean.TRUE); scheduler.shutdown(); verify(schedulerExecutor).shutdown(); verify(jobExecutor).shutdown(); }