use of com.hazelcast.spi.impl.DelegatingCompletableFuture in project hazelcast by hazelcast.
the class DelegatingCompletableFutureConstructorTest method test.
@Test
public void test() {
CompletableFuture<Integer> delegate = new CompletableFuture<>();
DelegatingCompletableFuture delegatingCompletableFuture = new DelegatingCompletableFuture(new DefaultSerializationServiceBuilder().build(), delegate);
DelegatingCompletableFutureConstructor constructor = new DelegatingCompletableFutureConstructor(delegatingCompletableFuture.getClass());
DelegatingCompletableFuture<Integer> cloned = (DelegatingCompletableFuture<Integer>) constructor.createNew(delegatingCompletableFuture);
delegate.complete(42);
assertTrue(cloned.isDone());
assertEquals(42, cloned.join().intValue());
}
use of com.hazelcast.spi.impl.DelegatingCompletableFuture in project hazelcast by hazelcast.
the class CancellableDelegatingFutureTest method testInnerFutureThrowsCancellationExceptionWhenOuterFutureIsCancelled.
@Test
public void testInnerFutureThrowsCancellationExceptionWhenOuterFutureIsCancelled() throws Exception {
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
final HazelcastInstance instance = factory.newHazelcastInstance();
IExecutorService executorService = instance.getExecutorService(randomString());
final CompletesOnInterruptionCallable callable = new CompletesOnInterruptionCallable();
final DelegatingCompletableFuture<Boolean> future = (DelegatingCompletableFuture<Boolean>) executorService.submit(callable);
if (future.cancel(true)) {
expected.expect(CancellationException.class);
future.getDelegate().get();
}
}
use of com.hazelcast.spi.impl.DelegatingCompletableFuture in project hazelcast by hazelcast.
the class CancellableDelegatingFutureTest method testCancellationOfDoneFutureDoesNothing.
@Test
public void testCancellationOfDoneFutureDoesNothing() throws Exception {
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
final HazelcastInstance instance = factory.newHazelcastInstance();
IExecutorService executorService = instance.getExecutorService(randomString());
final DummyCancellationCallable callable = new DummyCancellationCallable();
final DelegatingCompletableFuture<Void> future = (DelegatingCompletableFuture<Void>) executorService.submit(callable);
future.get();
future.cancel(true);
}
Aggregations