public void testStart_failed() throws Exception { final Exception exception = new Exception("deliberate"); AbstractIdleService service = new DefaultService() { @Override protected void startUp() throws Exception { throw exception; } }; try { service.startAsync().awaitRunning(); fail(); } catch (RuntimeException e) { assertThat(e).hasCauseThat().isSameAs(exception); } assertEquals(Service.State.FAILED, service.state()); }
public void testStop_failed() throws Exception { final Exception exception = new Exception("deliberate"); AbstractIdleService service = new DefaultService() { @Override protected void shutDown() throws Exception { throw exception; } }; service.startAsync().awaitRunning(); try { service.stopAsync().awaitTerminated(); fail(); } catch (RuntimeException e) { assertThat(e).hasCauseThat().isSameAs(exception); } assertEquals(Service.State.FAILED, service.state()); } }
public void testStart_failed() throws Exception { final Exception exception = new Exception("deliberate"); AbstractIdleService service = new DefaultService() { @Override protected void startUp() throws Exception { throw exception; } }; try { service.startAsync().awaitRunning(); fail(); } catch (RuntimeException e) { assertSame(exception, e.getCause()); } assertEquals(Service.State.FAILED, service.state()); }
public void testStop_failed() throws Exception { final Exception exception = new Exception("deliberate"); AbstractIdleService service = new DefaultService() { @Override protected void shutDown() throws Exception { throw exception; } }; service.startAsync().awaitRunning(); try { service.stopAsync().awaitTerminated(); fail(); } catch (RuntimeException e) { assertSame(exception, e.getCause()); } assertEquals(Service.State.FAILED, service.state()); } }