@Test
  public void testExecutorServiceStats() throws InterruptedException, ExecutionException {
    final IExecutorService executorService =
        createSingleNodeExecutorService("testExecutorServiceStats");
    final int k = 10;
    final CountDownLatch latch = new CountDownLatch(k);
    final int executionTime = 200;
    for (int i = 0; i < k; i++) {
      executorService.execute(
          new Runnable() {
            public void run() {
              try {
                Thread.sleep(executionTime);
              } catch (InterruptedException e) {
                e.printStackTrace();
              }
              latch.countDown();
            }
          });
    }
    latch.await(2, TimeUnit.MINUTES);

    final Future<Boolean> f = executorService.submit(new CancellationAwareTask(10000));
    Thread.sleep(1000);
    f.cancel(true);
    try {
      f.get();
    } catch (CancellationException e) {
    }

    final LocalExecutorStats stats = executorService.getLocalExecutorStats();
    assertEquals(k + 1, stats.getStartedTaskCount());
    assertEquals(k, stats.getCompletedTaskCount());
    assertEquals(0, stats.getPendingTaskCount());
    assertEquals(1, stats.getCancelledTaskCount());
  }