Search in sources :

Example 26 with RootCauseMatcher

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

the class CompletableFutureAbstractTest method thenCombineAsync_whenExecutionRejected.

@Test
public void thenCombineAsync_whenExecutionRejected() {
    CompletableFuture<Object> future = newCompletableFuture(false, 0L);
    expectedException.expect(CompletionException.class);
    expectedException.expectCause(new RootCauseMatcher(RejectedExecutionException.class));
    future.thenCombineAsync(newCompletedFuture(null), (v, u) -> null, 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 27 with RootCauseMatcher

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

the class CompletableFutureAbstractTest method thenApply_exceptional.

@Test
public void thenApply_exceptional() {
    CompletableFuture<Object> future = newCompletableFuture(true, 0L);
    CompletableFuture<Object> chained = future.thenApply(Function.identity());
    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) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 28 with RootCauseMatcher

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

the class CompletableFutureAbstractTest method runAfterBoth_whenActionThrowsException.

@Test
public void runAfterBoth_whenActionThrowsException() {
    CompletableFuture<Object> future = newCompletableFuture(false, 1000L);
    expectedException.expect(CompletionException.class);
    expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
    future.runAfterBoth(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 29 with RootCauseMatcher

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

the class CompletableFutureAbstractTest method runAfterBothAsync_whenExecutionRejected.

@Test
public void runAfterBothAsync_whenExecutionRejected() {
    CompletableFuture<Object> future = newCompletableFuture(false, 0L);
    expectedException.expect(CompletionException.class);
    expectedException.expectCause(new RootCauseMatcher(RejectedExecutionException.class));
    future.runAfterBothAsync(newCompletedFuture(null), () -> ignore(), REJECTING_EXECUTOR).join();
}
Also used : 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 30 with RootCauseMatcher

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

the class CompletableFutureAbstractTest method thenAcceptBothAsync_whenExecutionRejected.

@Test
public void thenAcceptBothAsync_whenExecutionRejected() {
    CompletableFuture<Object> future = newCompletableFuture(false, 0L);
    expectedException.expect(CompletionException.class);
    expectedException.expectCause(new RootCauseMatcher(RejectedExecutionException.class));
    future.thenAcceptBothAsync(newCompletedFuture(null), (v, u) -> 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)

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