use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class NioThreadAbstractTest method whenHandlerThrowException_thenHandlerOnFailureCalledWithThatException.
@Test
public void whenHandlerThrowException_thenHandlerOnFailureCalledWithThatException() throws Exception {
startThread();
SelectionKey selectionKey = mock(SelectionKey.class);
selectionKey.attach(handler);
when(selectionKey.isValid()).thenReturn(true);
doThrow(new ExpectedRuntimeException()).when(handler).process();
selector.scheduleSelectAction(selectionKey);
assertTrueEventually(new AssertTask() {
@Override
public void run() {
verify(handler).onError(isA(ExpectedRuntimeException.class));
}
});
assertStillRunning();
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class InboundResponseHandler_NotifyTest method errorResponse_whenInvocationMissing_thenNothingBadHappens.
@Test
public void errorResponse_whenInvocationMissing_thenNothingBadHappens() {
Invocation invocation = newInvocation();
invocationRegistry.register(invocation);
long callId = invocation.op.getCallId();
invocationRegistry.deregister(invocation);
inboundResponseHandler.notifyErrorResponse(callId, new ExpectedRuntimeException(), null);
assertInvocationDeregisteredEventually(callId);
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method thenCompose_whenActionThrowsException.
@Test
public void thenCompose_whenActionThrowsException() {
CompletableFuture<Object> future = newCompletableFuture(false, 1000L);
expectedException.expect(CompletionException.class);
expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
future.thenCompose(v -> {
throw new ExpectedRuntimeException();
}).join();
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method handleAsync_withExceptionFromBiFunction.
@Test
public void handleAsync_withExceptionFromBiFunction() {
CompletableFuture<Object> future = newCompletableFuture(false, 1000L);
CompletableFuture<Object> chained = future.handleAsync((v, t) -> {
throw new ExpectedRuntimeException();
});
assertTrueEventually(() -> assertTrue(chained.isCompletedExceptionally()));
expectedException.expect(CompletionException.class);
expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
chained.join();
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class AbstractInvocationFuture_GetSafely method whenRuntimeException.
@Test
public void whenRuntimeException() throws Exception {
ExpectedRuntimeException ex = new ExpectedRuntimeException();
future.completeExceptionally(ex);
Future joinFuture = spawn(() -> future.join());
assertCompletesEventually(joinFuture);
try {
joinFuture.get();
fail();
} catch (ExecutionException e) {
CompletionException wrapper = assertInstanceOf(CompletionException.class, e.getCause());
assertSame(ex, wrapper.getCause());
}
}
Aggregations