com.google.common.util.concurrent.ListeningScheduledExecutorService

Here are the examples of the java api class com.google.common.util.concurrent.ListeningScheduledExecutorService taken from open source projects.

1. TestingExecutorsTest#testNoOpScheduledExecutorInvokeAll()

Project: guava
Source File: TestingExecutorsTest.java
View license
public void testNoOpScheduledExecutorInvokeAll() throws ExecutionException, InterruptedException {
    ListeningScheduledExecutorService executor = TestingExecutors.noOpScheduledExecutor();
    taskDone = false;
    Callable<Boolean> task = new Callable<Boolean>() {

        @Override
        public Boolean call() {
            taskDone = true;
            return taskDone;
        }
    };
    List<Future<Boolean>> futureList = executor.invokeAll(ImmutableList.of(task), 10, TimeUnit.MILLISECONDS);
    Future<Boolean> future = futureList.get(0);
    assertFalse(taskDone);
    assertTrue(future.isDone());
    try {
        future.get();
        fail();
    } catch (CancellationException e) {
    }
}

2. TestingExecutorsTest#testNoOpScheduledExecutorShutdown()

Project: guava
Source File: TestingExecutorsTest.java
View license
public void testNoOpScheduledExecutorShutdown() {
    ListeningScheduledExecutorService executor = TestingExecutors.noOpScheduledExecutor();
    assertFalse(executor.isShutdown());
    assertFalse(executor.isTerminated());
    executor.shutdown();
    assertTrue(executor.isShutdown());
    assertTrue(executor.isTerminated());
}