@Test public void startWitExecutorAndTimeoutTest() throws InterruptedException, ExecutionException, TimeoutException { StrictPriorityScheduler ps = new StrictPriorityScheduler(2); try { long start = Clock.accurateForwardProgressingMillis(); ListenableFuture<String> lf = profiler.start(ps, DELAY_TIME); String result = lf.get(10 * 1000, TimeUnit.MILLISECONDS); long end = Clock.accurateForwardProgressingMillis(); // profiler should be stopped now assertFalse(profiler.isRunning()); assertTrue(end - start >= DELAY_TIME); assertNotNull(result); } finally { ps.shutdownNow(); } }