use of com.hazelcast.core.ExecutionCallback in project hazelcast by hazelcast.
the class AbstractInvocationFuture_AndThenTest method whenExceptionalResponseAvailableAfterSomeWaiting_MemberLeftException.
@Test
public void whenExceptionalResponseAvailableAfterSomeWaiting_MemberLeftException() {
final ExecutionCallback callback = mock(ExecutionCallback.class);
future.andThen(callback);
final MemberLeftException ex = new MemberLeftException();
future.complete(ex);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
verify(callback).onFailure(ex);
}
});
}
use of com.hazelcast.core.ExecutionCallback in project hazelcast by hazelcast.
the class AbstractInvocationFuture_AndThenTest method whenResponseAvailableAfterSomeWaiting.
@Test
public void whenResponseAvailableAfterSomeWaiting() {
final ExecutionCallback callback = mock(ExecutionCallback.class);
future.andThen(callback);
sleepSeconds(5);
verifyZeroInteractions(callback);
future.complete(value);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
verify(callback).onResponse(value);
}
});
}
use of com.hazelcast.core.ExecutionCallback in project hazelcast by hazelcast.
the class AbstractInvocationFuture_AndThenTest method whenCustomerExecutor.
@Test
public void whenCustomerExecutor() {
Executor defaultExecutor = mock(Executor.class);
Executor customExecutor = mock(Executor.class);
TestFuture future = new TestFuture(defaultExecutor, logger);
final ExecutionCallback callback = mock(ExecutionCallback.class);
future.andThen(callback, customExecutor);
future.complete(value);
verify(customExecutor).execute(any(Runnable.class));
verifyZeroInteractions(defaultExecutor);
}
use of com.hazelcast.core.ExecutionCallback in project hazelcast by hazelcast.
the class AbstractInvocationFuture_ClosedExecutorTest method whenCompleteBeforeShutdown_thenCallback.
@Test
public void whenCompleteBeforeShutdown_thenCallback() {
ExecutorService executorService = Executors.newSingleThreadExecutor();
TestFuture future = new TestFuture(executorService, logger);
future.complete(new Object());
executorService.shutdown();
final AtomicBoolean onFailure = new AtomicBoolean();
future.andThen(new ExecutionCallback() {
@Override
public void onResponse(Object response) {
}
@Override
public void onFailure(Throwable t) {
if (t instanceof RejectedExecutionException) {
onFailure.set(true);
}
}
});
assertTrue(onFailure.get());
}
Aggregations