use of com.hazelcast.core.ICompletableFuture in project hazelcast by hazelcast.
the class DelegatingFutureTest method test_andThen_Object.
@Test
public void test_andThen_Object() {
Object value = "value";
ICompletableFuture future = new DelegatingFuture(new FakeCompletableFuture(value), null);
TestExecutionCallback callback = new TestExecutionCallback();
future.andThen(callback, new CallerRunsExecutor());
assertEquals(value, callback.value);
}
use of com.hazelcast.core.ICompletableFuture in project hazelcast by hazelcast.
the class CompletedFutureTest method test_andThen_Data.
@Test
public void test_andThen_Data() {
Object value = "value";
Data data = serializationService.toData(value);
ICompletableFuture future = new CompletedFuture(serializationService, data, null);
TestExecutionCallback callback = new TestExecutionCallback();
future.andThen(callback, new CallerRunsExecutor());
assertEquals(value, callback.value);
}
use of com.hazelcast.core.ICompletableFuture in project hazelcast by hazelcast.
the class InvocationFuture_CancelTest method whenCancelled_thenGetThrowsCancelled.
@Test
public void whenCancelled_thenGetThrowsCancelled() throws Exception {
// Given
ICompletableFuture future = invoke();
// When
future.cancel(true);
// Then
exceptionRule.expect(CancellationException.class);
future.get();
}
use of com.hazelcast.core.ICompletableFuture in project hazelcast by hazelcast.
the class InvocationFuture_CancelTest method whenCancelled_thenCantCancelAgain.
@Test
public void whenCancelled_thenCantCancelAgain() throws Exception {
// Given
ICompletableFuture future = invoke();
// When
future.cancel(true);
// Then
assertFalse(future.cancel(true));
}
use of com.hazelcast.core.ICompletableFuture in project hazelcast by hazelcast.
the class ExecutorServiceTest method test_registerCallback_multipleTimes_futureIsCompletedOnOtherNode.
@Test
public void test_registerCallback_multipleTimes_futureIsCompletedOnOtherNode() throws Exception {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance instance1 = factory.newHazelcastInstance();
HazelcastInstance instance2 = factory.newHazelcastInstance();
assertTrue(instance1.getCountDownLatch("latch").trySetCount(1));
String name = randomString();
IExecutorService executorService = instance2.getExecutorService(name);
ICountDownLatchAwaitCallable task = new ICountDownLatchAwaitCallable("latch");
String key = generateKeyOwnedBy(instance1);
ICompletableFuture<Boolean> future = (ICompletableFuture<Boolean>) executorService.submitToKeyOwner(task, key);
CountDownLatch latch = new CountDownLatch(2);
CountingDownExecutionCallback<Boolean> callback = new CountingDownExecutionCallback<Boolean>(latch);
future.andThen(callback);
future.andThen(callback);
instance1.getCountDownLatch("latch").countDown();
assertTrue(future.get());
assertOpenEventually(latch, 10);
}
Aggregations