@Override
  protected Promise<R> run(final Context context) throws Exception {
    Executor executor = (Executor) context.getEngineProperty(CALLABLE_SERVICE_EXECUTOR);
    if (executor == null) {
      throw new IllegalStateException(
          "To use AsyncCallableTask you must first register an executor with the engine using AsyncCallableTask.register");
    }

    final SettablePromise<R> promise = Promises.settable();
    executor.execute(() -> {
      try {
        promise.done(_syncJob.call());
      } catch (Throwable t) {
        promise.fail(t);
      }
    } );
    return promise;
  }
@SuppressWarnings("deprecation")
  @Test
  public void testTaskWithoutExecutor() throws InterruptedException {
    final int numCores = Runtime.getRuntime().availableProcessors();
    final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(numCores + 1);
    final Engine engine = new EngineBuilder().setTaskExecutor(scheduler).setTimerScheduler(scheduler).build();

    try {
      final Task<Integer> task = new AsyncCallableTask<Integer>(new Callable<Integer>() {
        @Override
        public Integer call() throws Exception {
          return 1;
        }
      });
      engine.run(task);

      assertTrue(task.await(5, TimeUnit.SECONDS));

      assertTrue(task.isFailed());
      assertTrue(task.getError() instanceof IllegalStateException);
    } finally {
      engine.shutdown();
      engine.awaitTermination(1, TimeUnit.SECONDS);
      scheduler.shutdownNow();
    }
  }