@Test public void exceptionIsThrownOnUnwrap() throws Exception { final UnsupportedOperationException testedException = new UnsupportedOperationException("Test exception!"); Callable<Boolean> task = new Callable<Boolean>() { @Override public Boolean call() throws Exception { throw testedException; } }; Future<AsyncResult<Boolean>> resultFuture = AsyncRunner.submit(null, task); AsyncResult<Boolean> result = resultFuture.get(); exception.expect(AsyncExecutionException.class); result.unwrap(); }
public static <RESULT> Future<AsyncResult<RESULT>> submit(Callback<RESULT> callback, Callable<RESULT> task) { if (executor == null) { executor = new DefaultAsyncExecutor(); LOGGER.log(Level.INFO, "AsyncExecutor was not set, default executor {0} will be used.", executor.getClass().getSimpleName()); } return executor.submit(callback, task); }
AsyncRunner { public static <RESULT> Future<AsyncResult<RESULT>> submit(Callback<RESULT> callback, Callable<RESULT> task) { if (executor == null) { executor = new DefaultAsyncExecutor(); LOGGER.log(Level.INFO, "AsyncExecutor was not set, default executor {0} will be used.", executor.getClass().getSimpleName()); } return executor.submit(callback, task); } }
AsyncRunner { public static <RESULT> Future<AsyncResult<RESULT>> submit(Callback<RESULT> callback, Callable<RESULT> task) { if (executor == null) { executor = new DefaultAsyncExecutor(); LOGGER.log(Level.INFO, "AsyncExecutor was not set, default executor {0} will be used.", executor.getClass().getSimpleName()); } return executor.submit(callback, task); } private  AsyncRunner(); }
AsyncRunner { public static <RESULT> Future<AsyncResult<RESULT>> submit(Callback<RESULT> callback, Callable<RESULT> task) { if (executor == null) { executor = new DefaultAsyncExecutor(); LOGGER.log(Level.INFO, "AsyncExecutor was not set, default executor {0} will be used.", executor.getClass().getSimpleName()); } return executor.submit(callback, task); } private  AsyncRunner(); static Future<AsyncResult<RESULT>> submit(Callback<RESULT> callback, Callable<RESULT> task); static RESULT run(Callable<RESULT> task); static RESULT run(Callable<RESULT> task, long timeout, TimeUnit unit); static void setExecutor(AsyncExecutor executor); }
AsyncRunner { public static <RESULT> Future<AsyncResult<RESULT>> submit(Callback<RESULT> callback, Callable<RESULT> task) { if (executor == null) { executor = new DefaultAsyncExecutor(); LOGGER.log(Level.INFO, "AsyncExecutor was not set, default executor {0} will be used.", executor.getClass().getSimpleName()); } return executor.submit(callback, task); } private  AsyncRunner(); static Future<AsyncResult<RESULT>> submit(Callback<RESULT> callback, Callable<RESULT> task); static RESULT run(Callable<RESULT> task); static RESULT run(Callable<RESULT> task, long timeout, TimeUnit unit); static void setExecutor(AsyncExecutor executor);  }