Esempio n. 1
0
  @Test
  public void isDone_shouldReturnFalse_whenTheThreadIsFinished_givenAFutureReturnedByExecute()
      throws Exception {
    Future<?> result = asyncExecutor.execute(() -> {});

    Thread.sleep(50L); // give other thread a chance to finish...

    assertTrue(result.isDone());
  }
Esempio n. 2
0
  @Test
  public void isDone_shouldReturnTrue_whenTheThreadIsAlive_givenAFutureReturnedByExecute()
      throws Exception {
    CountDownLatch latch = new CountDownLatch(1);

    Future<?> result = asyncExecutor.execute(suppressCheckedExceptions(latch::await));

    try {
      assertFalse(result.isDone());
    } finally {
      latch.countDown(); // don't want a thread waiting forever...
    }
  }