Search in sources :

Example 1 with CompletableFutureTestUtil

use of com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil in project hazelcast by hazelcast.

the class CompletableFutureAbstractTest method thenRunAsync_exceptional.

@Test
public void thenRunAsync_exceptional() {
    CompletableFuture<Object> future = newCompletableFuture(true, 1000L);
    CompletableFuture<Void> chained = future.thenRunAsync(CompletableFutureTestUtil::ignore);
    assertTrueEventually(() -> assertTrue(chained.isDone()));
    assertTrue(chained.isCompletedExceptionally());
    expectedException.expect(CompletionException.class);
    expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
    chained.join();
}
Also used : ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) CompletableFutureTestUtil(com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with CompletableFutureTestUtil

use of com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil in project hazelcast by hazelcast.

the class CompletableFutureAbstractTest method thenRun_exceptional.

@Test
public void thenRun_exceptional() {
    CompletableFuture<Object> future = newCompletableFuture(true, 0L);
    CompletableFuture<Void> chained = future.thenRun(CompletableFutureTestUtil::ignore);
    assertTrueEventually(() -> assertTrue(chained.isDone()));
    assertTrue(chained.isCompletedExceptionally());
    expectedException.expect(CompletionException.class);
    expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
    chained.join();
}
Also used : ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) CompletableFutureTestUtil(com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

RootCauseMatcher (com.hazelcast.internal.util.RootCauseMatcher)2 CompletableFutureTestUtil (com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil)2 ExpectedRuntimeException (com.hazelcast.test.ExpectedRuntimeException)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2