Search in sources :

Example 16 with ExpectedRuntimeException

use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.

the class CompletableFutureAbstractTest method applyToEither_whenActionThrowsException.

@Test
public void applyToEither_whenActionThrowsException() {
    CompletableFuture<Object> future = newCompletableFuture(false, 1000L);
    CompletableFuture<Long> nextStage = future.applyToEither(new CompletableFuture<Long>(), (v) -> {
        throw new ExpectedRuntimeException();
    });
    assertTrueEventually(() -> assertTrue(nextStage.isDone()));
    expectedException.expect(CompletionException.class);
    expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
    nextStage.join();
}
Also used : ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 17 with ExpectedRuntimeException

use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.

the class CompletableFutureAbstractTest method runAfterEither_whenActionThrowsException.

@Test
public void runAfterEither_whenActionThrowsException() {
    CompletableFuture<Object> future = newCompletableFuture(false, 1000L);
    expectedException.expect(CompletionException.class);
    expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
    future.runAfterEither(newCompletedFuture(null), () -> {
        throw new ExpectedRuntimeException();
    }).join();
}
Also used : ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 18 with ExpectedRuntimeException

use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.

the class CompletableFutureAbstractTest method acceptEither_whenActionThrowsException.

@Test
public void acceptEither_whenActionThrowsException() {
    CompletableFuture<Object> future = newCompletableFuture(false, 1000L);
    CompletableFuture<Void> nextStage = future.acceptEither(new CompletableFuture<>(), (v) -> {
        throw new ExpectedRuntimeException();
    });
    assertTrueEventually(() -> assertTrue(nextStage.isDone()));
    expectedException.expect(CompletionException.class);
    expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
    nextStage.join();
}
Also used : ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 19 with ExpectedRuntimeException

use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.

the class CompletableFutureAbstractTest method thenAccept_whenActionThrowsException.

private void thenAccept_whenActionThrowsException(long completionDelay) {
    CompletableFuture<Object> future = newCompletableFuture(false, completionDelay);
    CompletableFuture<Void> chained = future.thenAccept(value -> {
        throw new ExpectedRuntimeException();
    });
    assertTrueEventually(() -> assertTrue(future.isDone()));
    assertTrueEventually(() -> assertTrue(chained.isDone()));
    assertFalse(future.isCompletedExceptionally());
    assertTrue(chained.isCompletedExceptionally());
    expectedException.expect(CompletionException.class);
    expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
    chained.join();
}
Also used : ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher)

Example 20 with ExpectedRuntimeException

use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.

the class CompletableFutureAbstractTest method thenApply_whenActionThrowsException.

public void thenApply_whenActionThrowsException(long completionDelay) {
    CompletableFuture<Object> future = newCompletableFuture(false, completionDelay);
    CompletableFuture<Void> chained = future.thenApply(value -> {
        throw new ExpectedRuntimeException();
    });
    assertTrueEventually(() -> assertTrue(future.isDone()));
    assertTrueEventually(() -> assertTrue(chained.isDone()));
    assertFalse(future.isCompletedExceptionally());
    assertTrue(chained.isCompletedExceptionally());
    expectedException.expect(CompletionException.class);
    expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
    chained.join();
}
Also used : ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher)

Aggregations

ExpectedRuntimeException (com.hazelcast.test.ExpectedRuntimeException)50 Test (org.junit.Test)44 QuickTest (com.hazelcast.test.annotation.QuickTest)36 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)27 RootCauseMatcher (com.hazelcast.internal.util.RootCauseMatcher)16 Config (com.hazelcast.config.Config)11 ExecutionException (java.util.concurrent.ExecutionException)7 Executor (java.util.concurrent.Executor)6 HazelcastParallelClassRunner (com.hazelcast.test.HazelcastParallelClassRunner)5 CompletionException (java.util.concurrent.CompletionException)5 TestNodeContext (com.hazelcast.instance.TestNodeContext)4 SlowTest (com.hazelcast.test.annotation.SlowTest)4 Category (org.junit.experimental.categories.Category)4 RunWith (org.junit.runner.RunWith)4 CALLER_RUNS (com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS)3 Job (com.hazelcast.jet.Job)3 MockP (com.hazelcast.jet.core.TestProcessors.MockP)3 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)3 InternalCompletableFuture.newCompletedFuture (com.hazelcast.spi.impl.InternalCompletableFuture.newCompletedFuture)3 CompletableFutureTestUtil (com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil)3