BackgroundScannerRunner implements Shutdownable { @Override public void shutdown() throws Exception { Shutdownables.shutdown(new ShutdownableIndex(BackgroundScannerRunner.class, ImmutableMap.of("runner", this.runner, "executorService", shutdownAndAwaitTermination(executorService)))); } BackgroundScannerRunner(RunnerFactory runnerFactory, BackgroundScanner backgroundScanner, BackgroundScannerOptions backgroundScannerOptions); @Override void shutdown();  }
@Test public void testWithSuccessfulBackgroundScanner() throws Exception { SuccessfulBackgroundScanner backgroundScanner = new SuccessfulBackgroundScanner(); BackgroundScannerRunner backgroundScannerRunner = backgroundScannerRunnerFactory.create(backgroundScanner, new BackgroundScannerOptions()); backgroundScanner.countDownLatch.await(); backgroundScannerRunner.shutdown(); }
@Test public void testWithFailingBackgroundScanner() throws Exception { FailingBackgroundScanner backgroundScanner = new FailingBackgroundScanner(); BackgroundScannerRunner backgroundScannerRunner = backgroundScannerRunnerFactory.create(backgroundScanner, new BackgroundScannerOptions()); backgroundScanner.countDownLatch.await(); await().until(() -> { assertThat(backgroundScanner.scans.get(), greaterThanOrEqualTo(2)); } ); backgroundScannerRunner.shutdown(); }
@Test public void testWithBlockingBackgroundScanner() throws Exception { BlockingBackgroundScanner backgroundScanner = new BlockingBackgroundScanner(); BackgroundScannerRunner backgroundScannerRunner = backgroundScannerRunnerFactory.create(backgroundScanner, new BackgroundScannerOptions()); backgroundScanner.countDownLatch.await(); backgroundScannerRunner.shutdown(); }