CsvMetricsService extends AbstractIdleService { @Override protected void shutDown() throws Exception { if (reporter == null) { LOGGER.info("already stopped {}", serviceName()); return; } LOGGER.info("stopping {}", serviceName()); reporter.stop(); reporter = null; LOGGER.info("stopped {}", serviceName()); } @Inject  CsvMetricsService(@Named("metrics.csv.directory") final File directory,
                             @Named("metrics.csv.interval.seconds") final int interval,
                             final MetricRegistry metricRegistry);   }
@Test public void shutdown() throws Exception { when(directory.exists()).thenReturn(false); when(directory.mkdirs()).thenReturn(true); csvMetricsService = createService(); csvMetricsService.startUp(); csvMetricsService.shutDown(); }
@Test public void shutDownAlreadyShutDown() throws Exception { when(directory.exists()).thenReturn(false); when(directory.mkdirs()).thenReturn(true); csvMetricsService = createService(); csvMetricsService.shutDown(); csvMetricsService.shutDown(); }