public void testTimeout() { // Create a service whose executor will never run its commands Service service = new AbstractScheduledService() { @Override protected Scheduler scheduler() { return Scheduler.newFixedDelaySchedule(0, 1, TimeUnit.NANOSECONDS); } @Override protected ScheduledExecutorService executor() { return TestingExecutors.noOpScheduledExecutor(); } @Override protected void runOneIteration() throws Exception {} @Override protected String serviceName() { return "Foo"; } }; try { service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS); fail("Expected timeout"); } catch (TimeoutException e) { assertThat(e).hasMessage("Timed out waiting for Foo [STARTING] to reach the RUNNING state."); } }
public void testTimeout() { // Create a service whose executor will never run its commands Service service = new AbstractExecutionThreadService() { @Override protected void run() throws Exception {} @Override protected ScheduledExecutorService executor() { return TestingExecutors.noOpScheduledExecutor(); } @Override protected String serviceName() { return "Foo"; } }; try { service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS); fail("Expected timeout"); } catch (TimeoutException e) { assertThat(e).hasMessage("Timed out waiting for Foo [STARTING] to reach the RUNNING state."); } }