Search in sources :

Example 66 with RootCauseMatcher

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

the class ClientInvocationFutureTest method test_interruptionDuringJoin.

@Test
public void test_interruptionDuringJoin() {
    Thread thisThread = Thread.currentThread();
    Thread t = new Thread(() -> {
        sleepSeconds(2);
        thisThread.interrupt();
    });
    t.start();
    expected.expect(CompletionException.class);
    expected.expectCause(new RootCauseMatcher(InterruptedException.class));
    invocationFuture.join();
}
Also used : RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 67 with RootCauseMatcher

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

the class ClientDelegatingFutureTest method get_whenCompletedExceptionally.

@Test
public void get_whenCompletedExceptionally() throws Exception {
    invocationFuture.completeExceptionally(new IllegalArgumentException());
    assertTrue(delegatingFuture.isDone());
    assertTrue(delegatingFuture.isCompletedExceptionally());
    expected.expect(ExecutionException.class);
    expected.expectCause(new RootCauseMatcher(IllegalArgumentException.class));
    delegatingFuture.get();
}
Also used : RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 68 with RootCauseMatcher

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

the class ClientDurableExecutorServiceTest method test_whenRingBufferIsFull_thenThrowRejectedExecutionException.

@Test
public void test_whenRingBufferIsFull_thenThrowRejectedExecutionException() throws Exception {
    String key = randomString();
    DurableExecutorService service = client.getDurableExecutorService(SINGLE_TASK + randomString());
    service.submitToKeyOwner(new SleepingTask(100), key);
    DurableExecutorServiceFuture<String> future = service.submitToKeyOwner(new BasicTestCallable(), key);
    expectedException.expect(new RootCauseMatcher(RejectedExecutionException.class));
    future.get();
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) SleepingTask(com.hazelcast.executor.ExecutorServiceTestSupport.SleepingTask) BasicTestCallable(com.hazelcast.executor.ExecutorServiceTestSupport.BasicTestCallable) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) 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 69 with RootCauseMatcher

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

the class ClientDurableExecutorServiceTest method testSubmitFailingCallableReasonExceptionCause.

@Test
public void testSubmitFailingCallableReasonExceptionCause() throws Exception {
    DurableExecutorService service = client.getDurableExecutorService(randomString());
    Future<String> future = service.submit(new FailingCallable());
    expectedException.expect(new RootCauseMatcher(IllegalStateException.class));
    future.get();
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) FailingCallable(com.hazelcast.client.test.executor.tasks.FailingCallable) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 70 with RootCauseMatcher

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

the class ClientInvocationFutureTest method test_exceptionalCompletion_withGet.

@Test
public void test_exceptionalCompletion_withGet() throws ExecutionException, InterruptedException {
    invocationFuture.completeExceptionally(new IllegalArgumentException());
    assertTrue(invocationFuture.isDone());
    assertFalse(invocationFuture.isCancelled());
    assertTrue(invocationFuture.isCompletedExceptionally());
    expected.expect(ExecutionException.class);
    expected.expectCause(new RootCauseMatcher(IllegalArgumentException.class));
    invocationFuture.get();
}
Also used : 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