Search in sources :

Example 31 with RootCauseMatcher

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

the class CompletableFutureAbstractTest method thenCombineAsync_onIncompleteFuture_whenExecutionRejected.

@Test
public void thenCombineAsync_onIncompleteFuture_whenExecutionRejected() {
    CompletableFuture<Object> future = newCompletableFuture(false, 1000L);
    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 32 with RootCauseMatcher

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

the class CompletableFutureAbstractTest method applyToEitherAsync_onIncompleteFuture_whenExecutionRejected.

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

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

the class CompletableFutureAbstractTest method thenCompose_whenExceptionFromFirstStage.

@Test
public void thenCompose_whenExceptionFromFirstStage() {
    CompletableFuture<Object> future = newCompletableFuture(true, 0L);
    expectedException.expect(CompletionException.class);
    expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
    future.thenCompose(v -> null).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 34 with RootCauseMatcher

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

the class CompletableFutureAbstractTest method thenComposeAsync_whenExecutionRejected.

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

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

the class CompletableFutureAbstractTest method runAfterEitherAsync_onIncompleteFuture_whenExecutionRejected.

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

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