Example #1
0
  @Test(timeout = 1000)
  public void testAsyncThatThrowsException() throws Exception {

    AtomicInteger count = new AtomicInteger(0);

    Async<Integer> thrower =
        new Async<Integer>() {

          @Override
          public void submit(Callback<Integer> cb) {
            throw new RuntimeException("Intentionally failed for test purposes");
          }
        };

    Task throwerTask = m_coordinator.createTask(null, thrower, setter(count));
    Task incrTask = m_coordinator.createTask(null, incr(count));

    incrTask.addPrerequisite(throwerTask);

    incrTask.schedule();
    throwerTask.schedule();

    incrTask.waitFor(1500, TimeUnit.MILLISECONDS);

    assertEquals(1, count.get());
  }
Example #2
0
  @Test(timeout = 1000)
  public void testAsync() throws Exception {
    final AtomicInteger count = new AtomicInteger(0);

    Task async = m_coordinator.createTask(null, timer(500, 17), setter(count));

    async.schedule();

    async.waitFor(15000, TimeUnit.MILLISECONDS);

    assertEquals(17, count.get());
  }
Example #3
0
 private Task createTask(final Runnable runnable) {
   return m_coordinator.createTask(null, runnable);
 }