  @Test
  public void testExecute () throws Exception
  {

    final During during = new During (
        Executors.newCachedThreadPool (),
        new ConditionalTask ()
        {
          @Override
          public void evaluate (ConditionalCallback callback)
          {
            callback.done (remaining_ > 0);
          }
        },
        new Task () {
          @Override
          public void run (Object unused, CompletionCallback callback)
          {
            Assert.assertNull (unused);

            // Decrement the remaining.
            -- remaining_;

            callback.done ("DONE");
          }
        });

    synchronized (during)
    {
      Future future = during.execute (new CompletionCallback <Object> ()
      {
        @Override
        public void onComplete (Object result)
        {
          Assert.assertEquals ("DONE", result);
          callbackCalled_ = true;

          synchronized (during)
          {
            during.notify ();
          }
        }

        @Override
        public void onFail (Throwable e)
        {
          Assert.fail ();
        }

        @Override
        public void onCancel ()
        {
          Assert.fail ();
        }
      });

      if (!future.isDone ())
        during.wait (5000);

      Assert.assertTrue (this.callbackCalled_);
      Assert.assertEquals (0, this.remaining_);
      Assert.assertTrue (future.isDone ());
    }
  }