JmxMetricsService extends AbstractIdleService { @Override protected void startUp() throws Exception { if (reporter != null) { LOGGER.info("already started {}", serviceName()); return; } LOGGER.info("starting {}", serviceName()); reporter = forRegistry(metricRegistry).build(); reporter.start(); LOGGER.info("started {}", serviceName()); } @Inject  JmxMetricsService(final MetricRegistry metricRegistry);   }
@Test public void startUp() throws Exception { jmxMetricsService.startUp(); }
@Test public void startUpAlreadyStarted() throws Exception { jmxMetricsService.startUp(); jmxMetricsService.startUp(); }