Search in sources :

Example 36 with RootCauseMatcher

use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.

the class CompletableFutureAbstractTest method thenCombine_whenActionThrowsException.

@Test
public void thenCombine_whenActionThrowsException() {
    CompletableFuture<Object> future = newCompletableFuture(false, 1000L);
    expectedException.expect(CompletionException.class);
    expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
    future.thenCombine(newCompletedFuture(null), (t, u) -> {
        throw new ExpectedRuntimeException();
    }).join();
}
Also used : ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) RunWith(org.junit.runner.RunWith) CompletableFuture(java.util.concurrent.CompletableFuture) Function(java.util.function.Function) CountingExecutor(com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil.CountingExecutor) Assert.assertSame(org.junit.Assert.assertSame) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) HazelcastTestSupport.assertOpenEventually(com.hazelcast.test.HazelcastTestSupport.assertOpenEventually) ExpectedException(org.junit.rules.ExpectedException) CALLER_RUNS(com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS) InternalCompletableFuture.newCompletedFuture(com.hazelcast.spi.impl.InternalCompletableFuture.newCompletedFuture) HazelcastTestSupport.assertTrueEventually(com.hazelcast.test.HazelcastTestSupport.assertTrueEventually) CancellationException(java.util.concurrent.CancellationException) Executor(java.util.concurrent.Executor) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) CompletionException(java.util.concurrent.CompletionException) HazelcastTestSupport.assertInstanceOf(com.hazelcast.test.HazelcastTestSupport.assertInstanceOf) Category(org.junit.experimental.categories.Category) CountDownLatch(java.util.concurrent.CountDownLatch) Rule(org.junit.Rule) CompletionStage(java.util.concurrent.CompletionStage) Assert.assertNull(org.junit.Assert.assertNull) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) CompletableFutureTestUtil.ignore(com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil.ignore) Assert.assertFalse(org.junit.Assert.assertFalse) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) CompletableFutureTestUtil(com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) 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 37 with RootCauseMatcher

use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.

the class CompletableFutureAbstractTest method whenCompleteAsync_whenExecutionRejected.

@Test
public void whenCompleteAsync_whenExecutionRejected() {
    CompletableFuture<Object> future = newCompletableFuture(false, 0L);
    expectedException.expect(CompletionException.class);
    expectedException.expectCause(new RootCauseMatcher(RejectedExecutionException.class));
    future.whenCompleteAsync((v, t) -> ignore(), REJECTING_EXECUTOR).join();
}
Also used : ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) RunWith(org.junit.runner.RunWith) CompletableFuture(java.util.concurrent.CompletableFuture) Function(java.util.function.Function) CountingExecutor(com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil.CountingExecutor) Assert.assertSame(org.junit.Assert.assertSame) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) HazelcastTestSupport.assertOpenEventually(com.hazelcast.test.HazelcastTestSupport.assertOpenEventually) ExpectedException(org.junit.rules.ExpectedException) CALLER_RUNS(com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS) InternalCompletableFuture.newCompletedFuture(com.hazelcast.spi.impl.InternalCompletableFuture.newCompletedFuture) HazelcastTestSupport.assertTrueEventually(com.hazelcast.test.HazelcastTestSupport.assertTrueEventually) CancellationException(java.util.concurrent.CancellationException) Executor(java.util.concurrent.Executor) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) CompletionException(java.util.concurrent.CompletionException) HazelcastTestSupport.assertInstanceOf(com.hazelcast.test.HazelcastTestSupport.assertInstanceOf) Category(org.junit.experimental.categories.Category) CountDownLatch(java.util.concurrent.CountDownLatch) Rule(org.junit.Rule) CompletionStage(java.util.concurrent.CompletionStage) Assert.assertNull(org.junit.Assert.assertNull) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) CompletableFutureTestUtil.ignore(com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil.ignore) Assert.assertFalse(org.junit.Assert.assertFalse) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) CompletableFutureTestUtil(com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 38 with RootCauseMatcher

use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.

the class CompletableFutureAbstractTest method thenAcceptBoth_whenActionThrowsException.

@Test
public void thenAcceptBoth_whenActionThrowsException() {
    CompletableFuture<Object> future = newCompletableFuture(false, 1000L);
    expectedException.expect(CompletionException.class);
    expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
    future.thenAcceptBoth(newCompletedFuture(null), (v, u) -> {
        throw new ExpectedRuntimeException();
    }).join();
}
Also used : ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) RunWith(org.junit.runner.RunWith) CompletableFuture(java.util.concurrent.CompletableFuture) Function(java.util.function.Function) CountingExecutor(com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil.CountingExecutor) Assert.assertSame(org.junit.Assert.assertSame) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) HazelcastTestSupport.assertOpenEventually(com.hazelcast.test.HazelcastTestSupport.assertOpenEventually) ExpectedException(org.junit.rules.ExpectedException) CALLER_RUNS(com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS) InternalCompletableFuture.newCompletedFuture(com.hazelcast.spi.impl.InternalCompletableFuture.newCompletedFuture) HazelcastTestSupport.assertTrueEventually(com.hazelcast.test.HazelcastTestSupport.assertTrueEventually) CancellationException(java.util.concurrent.CancellationException) Executor(java.util.concurrent.Executor) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) CompletionException(java.util.concurrent.CompletionException) HazelcastTestSupport.assertInstanceOf(com.hazelcast.test.HazelcastTestSupport.assertInstanceOf) Category(org.junit.experimental.categories.Category) CountDownLatch(java.util.concurrent.CountDownLatch) Rule(org.junit.Rule) CompletionStage(java.util.concurrent.CompletionStage) Assert.assertNull(org.junit.Assert.assertNull) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) CompletableFutureTestUtil.ignore(com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil.ignore) Assert.assertFalse(org.junit.Assert.assertFalse) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) CompletableFutureTestUtil(com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) 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 39 with RootCauseMatcher

use of com.hazelcast.internal.util.RootCauseMatcher 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 40 with RootCauseMatcher

use of com.hazelcast.internal.util.RootCauseMatcher 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)

Aggregations

RootCauseMatcher (com.hazelcast.internal.util.RootCauseMatcher)122 QuickTest (com.hazelcast.test.annotation.QuickTest)118 Test (org.junit.Test)118 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)106 ExpectedRuntimeException (com.hazelcast.test.ExpectedRuntimeException)64 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)31 CompletableFutureTestUtil (com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil)26 CancellationException (java.util.concurrent.CancellationException)25 CountDownLatch (java.util.concurrent.CountDownLatch)25 CALLER_RUNS (com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS)24 InternalCompletableFuture.newCompletedFuture (com.hazelcast.spi.impl.InternalCompletableFuture.newCompletedFuture)24 CountingExecutor (com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil.CountingExecutor)24 CompletableFutureTestUtil.ignore (com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil.ignore)24 HazelcastParallelClassRunner (com.hazelcast.test.HazelcastParallelClassRunner)24 HazelcastTestSupport.assertInstanceOf (com.hazelcast.test.HazelcastTestSupport.assertInstanceOf)24 HazelcastTestSupport.assertOpenEventually (com.hazelcast.test.HazelcastTestSupport.assertOpenEventually)24 HazelcastTestSupport.assertTrueEventually (com.hazelcast.test.HazelcastTestSupport.assertTrueEventually)24 CompletableFuture (java.util.concurrent.CompletableFuture)24 CompletionException (java.util.concurrent.CompletionException)24 CompletionStage (java.util.concurrent.CompletionStage)24