@Test
public void testStopFailurePropagate() throws InterruptedException, TimeoutException, ExecutionException {
CountDownLatch startLatch = new CountDownLatch(1);
final RetryOnStartFailureService service = new RetryOnStartFailureService(
createServiceSupplier(0, startLatch, new CountDownLatch(1), true),
RetryStrategies.fixDelay(10, TimeUnit.MILLISECONDS));
service.startAndWait();
Assert.assertTrue(startLatch.await(1, TimeUnit.SECONDS));
Tasks.waitFor(true, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return service.getStartedService() != null;
}
}, 5, TimeUnit.SECONDS, 100, TimeUnit.MILLISECONDS);
try {
service.stopAndWait();
Assert.fail("Expected failure in stopping");
} catch (Exception e) {
Assert.assertEquals("Intentional failure to shutdown", Throwables.getRootCause(e).getMessage());
}
}