ServiceWrapper extends AbstractIdleService { protected void main() { try { logger.info("Bidder initializing..."); startAsync().awaitRunning(); } finally { if (isRunning()) { if (isAlive()) { logger.info("Bidder initialization complete."); return; } } else { logger.error("Bidder initialization failure: {}", this.failureCause()); } } if (runtime != null) { runtime.exit(1); } } ServiceWrapper(String[] args); boolean isAlive();  }
@Test public void test_Ok() { TestService service = new TestService(new String[]{}, false, false); service.main(); service.stopAsync().awaitTerminated(); }
@Test(expected = IllegalStateException.class) public void test_failStartup() { TestService service = new TestService(new String[]{}, true, false); service.main(); }
@Test(expected = IllegalStateException.class) public void test_failShutdown() { TestService service = new TestService(new String[]{}, false, true); service.main(); service.stopAsync().awaitTerminated(); }
@Test(expected = IllegalStateException.class) public void test_failParams() { TestService service = new TestService(new String[]{ "--help" }, false, true); service.main(); service.stopAsync().awaitTerminated(); }