use of com.hazelcast.core.ExecutionCallback in project hazelcast by hazelcast.
the class DurableSingleNodeTest method executionCallback_notifiedOnSuccess.
@Test
public void executionCallback_notifiedOnSuccess() {
final CountDownLatch latch = new CountDownLatch(1);
Callable<String> task = new BasicTestCallable();
ExecutionCallback<String> executionCallback = new ExecutionCallback<String>() {
public void onResponse(String response) {
latch.countDown();
}
public void onFailure(Throwable t) {
}
};
executor.submit(task).andThen(executionCallback);
assertOpenEventually(latch);
}
use of com.hazelcast.core.ExecutionCallback in project hazelcast by hazelcast.
the class InvocationBuilderTest method getTargetExecutionCallback_whenExecutionCallbackInstance.
@Test
public void getTargetExecutionCallback_whenExecutionCallbackInstance() {
InvocationBuilder builder = new MockInvocationBuilder(null, null, 0, null);
ExecutionCallback callback = mock(ExecutionCallback.class);
builder.setExecutionCallback(callback);
assertSame(callback, builder.getTargetExecutionCallback());
}
use of com.hazelcast.core.ExecutionCallback in project hazelcast by hazelcast.
the class EntryProcessorTest method testSubmitToKeyWithCallback.
@Test
public void testSubmitToKeyWithCallback() throws Exception {
HazelcastInstance instance1 = createHazelcastInstance(getConfig());
IMap<Integer, Integer> map = instance1.getMap(MAP_NAME);
map.put(1, 1);
final CountDownLatch latch = new CountDownLatch(1);
ExecutionCallback executionCallback = new ExecutionCallback() {
@Override
public void onResponse(Object response) {
latch.countDown();
}
@Override
public void onFailure(Throwable t) {
}
};
map.submitToKey(1, new IncrementorEntryProcessor(), executionCallback);
assertTrue(latch.await(5, TimeUnit.SECONDS));
assertEquals(2, (int) map.get(1));
}
use of com.hazelcast.core.ExecutionCallback in project hazelcast by hazelcast.
the class AbstractCompletableFutureTest method andThen_whenCancelled.
@Test
public void andThen_whenCancelled() {
TestFutureImpl future = new TestFutureImpl(nodeEngine, logger);
ExecutionCallback callback = mock(ExecutionCallback.class);
future.cancel(false);
future.andThen(callback, executor);
verifyZeroInteractions(callback);
}
use of com.hazelcast.core.ExecutionCallback in project hazelcast by hazelcast.
the class AbstractCompletableFutureTest method andThen_whenResultAvailable.
@Test
public void andThen_whenResultAvailable() throws Exception {
TestFutureImpl future = new TestFutureImpl(nodeEngine, logger);
final Object result = "result";
final ExecutionCallback callback = mock(ExecutionCallback.class);
future.setResult(result);
future.andThen(callback, executor);
assertSame(result, future.get());
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
verify(callback).onResponse(result);
}
});
}
Aggregations