PlanExecutor implements JobResultReceiver, Cancelable, DependencyGraphExecutionFuture { @Override public synchronized String get() throws InterruptedException, ExecutionException { while (_executing != null) { s_logger.debug("Waiting for completion of {}", this); wait(); } if (_state == State.CANCELLED) { s_logger.info("Cancelled {}", this); throw new CancellationException(); } return getGraph().getCalculationConfiguration(); } PlanExecutor(final SingleComputationCycle cycle, final GraphExecutionPlan plan); void start(); @Override boolean cancel(final boolean mayInterruptIfRunning); @Override void resultReceived(final CalculationJobResult result); @Override synchronized boolean isCancelled(); @Override boolean isDone(); @Override synchronized String get(); @Override synchronized String get(final long timeout, final TimeUnit unit); @Override void setListener(final Listener listener); @Override String toString();  }
@Test(timeOut = 5000) public void testGet() throws Throwable { final ExecutorService threads = Executors.newSingleThreadExecutor(); try { final NormalExecutionJobDispatcher dispatcher = new NormalExecutionJobDispatcher(); final PlanExecutor executor = new PlanExecutor(createCycle(dispatcher), createPlan()); threads.submit(new Runnable() { @Override public void run() { dispatcher.execute(executor); } }); assertEquals(executor.get(), "Default"); } finally { threads.shutdownNow(); threads.awaitTermination(3, TimeUnit.SECONDS); } }
@Test(timeOut = 5000, expectedExceptions = TimeoutException.class) public void testGetWithElapsedTimeout() throws Throwable { final ExecutorService threads = Executors.newSingleThreadExecutor(); try { final NormalExecutionJobDispatcher dispatcher = new NormalExecutionJobDispatcher(); final PlanExecutor executor = new PlanExecutor(createCycle(dispatcher), createPlan()); executor.get(1, TimeUnit.SECONDS); } finally { threads.shutdownNow(); threads.awaitTermination(3, TimeUnit.SECONDS); } }