Search in sources :

Example 1 with DelegatingCompletableFutureConstructor

use of com.hazelcast.test.starter.constructor.DelegatingCompletableFutureConstructor 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());
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) DelegatingCompletableFuture(com.hazelcast.spi.impl.DelegatingCompletableFuture) CompletableFuture(java.util.concurrent.CompletableFuture) DelegatingCompletableFutureConstructor(com.hazelcast.test.starter.constructor.DelegatingCompletableFutureConstructor) DelegatingCompletableFuture(com.hazelcast.spi.impl.DelegatingCompletableFuture) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)1 DelegatingCompletableFuture (com.hazelcast.spi.impl.DelegatingCompletableFuture)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 DelegatingCompletableFutureConstructor (com.hazelcast.test.starter.constructor.DelegatingCompletableFutureConstructor)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Test (org.junit.Test)1