### Question:
JaxwsClientCallback extends ClientCallback { public void handleResponse(Map<String, Object> ctx, Object[] res) { context = ctx; if (handler != null) { handler.handleResponse(new Response<T>() { protected boolean cancelled; public Map<String, Object> getContext() { return context; } public boolean cancel(boolean mayInterruptIfRunning) { cancelled = true; return true; } @SuppressWarnings("unchecked") public T get() throws InterruptedException, ExecutionException { return (T)res[0]; } @SuppressWarnings("unchecked") public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return (T)res[0]; } public boolean isCancelled() { return cancelled; } public boolean isDone() { return true; } }); } delegate.complete(res); synchronized (this) { notifyAll(); } } JaxwsClientCallback(final AsyncHandler<T> handler, Object p); void handleResponse(Map<String, Object> ctx, Object[] res); @Override void handleException(Map<String, Object> ctx, final Throwable ex);  }### Answer:
@Test public void testHandleResponseCallback() throws Exception { final CyclicBarrier barrier = new CyclicBarrier(2); Object[] result = new Object[0]; schedule(barrier, () -> callback.handleResponse(ctx, result)); barrier.await(5, TimeUnit.SECONDS); assertThat(callback.get(), equalTo(result)); assertThat(callback.get(10, TimeUnit.MILLISECONDS), equalTo(result)); assertThat(callback.isCancelled(), equalTo(false)); assertThat(callback.isDone(), equalTo(true)); }
@Test public void testGetResponseContextOnSuccessCallback() throws Exception { final CyclicBarrier barrier = new CyclicBarrier(2); Object[] result = new Object[0]; schedule(barrier, () -> callback.handleResponse(ctx, result)); barrier.await(5, TimeUnit.SECONDS); assertThat(callback.getResponseContext(), equalTo(ctx)); assertThat(callback.get(), equalTo(result)); assertThat(callback.get(10, TimeUnit.MILLISECONDS), equalTo(result)); assertThat(callback.isCancelled(), equalTo(false)); assertThat(callback.isDone(), equalTo(true)); }