Search in sources :

Example 11 with ExpectedRuntimeException

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

the class AbstractInvocationFuture_MiscTest method obtrudeException_whenComplete.

@Test
public void obtrudeException_whenComplete() {
    future.complete(value);
    future.obtrudeException(new ExpectedRuntimeException());
    try {
        future.joinInternal();
        fail();
    } catch (ExpectedRuntimeException e) {
        ignore(e);
    }
}
Also used : ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 12 with ExpectedRuntimeException

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

the class AbstractInvocationFuture_MiscTest method obtrudeException_whenNotComplete.

@Test
public void obtrudeException_whenNotComplete() {
    future.obtrudeException(new ExpectedRuntimeException());
    try {
        future.joinInternal();
        fail();
    } catch (ExpectedRuntimeException e) {
        ignore(e);
    }
}
Also used : ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 13 with ExpectedRuntimeException

use of com.hazelcast.test.ExpectedRuntimeException 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 14 with ExpectedRuntimeException

use of com.hazelcast.test.ExpectedRuntimeException 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 15 with ExpectedRuntimeException

use of com.hazelcast.test.ExpectedRuntimeException 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)

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