use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method handleAsync_whenExecutionRejected.
@Test
public void handleAsync_whenExecutionRejected() {
CompletableFuture<Object> future = newCompletableFuture(false, 0L);
expectedException.expect(CompletionException.class);
expectedException.expectCause(new RootCauseMatcher(RejectedExecutionException.class));
future.handleAsync((v, t) -> null, REJECTING_EXECUTOR).join();
}
use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method handleAsync_withExecutor_withExceptionFromBiFunction.
@Test
public void handleAsync_withExecutor_withExceptionFromBiFunction() {
CompletableFuture<Object> future = newCompletableFuture(false, 0L);
CompletableFuture<Object> chained = future.handleAsync((v, t) -> {
throw new ExpectedRuntimeException();
}, countingExecutor);
assertTrueEventually(() -> assertTrue(chained.isCompletedExceptionally()));
expectedException.expect(CompletionException.class);
expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
chained.join();
}
use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class ScheduledExecutorServiceBasicTest method schedule_getHandlerDisposeThenRecreateFutureAndGet.
@Test
public void schedule_getHandlerDisposeThenRecreateFutureAndGet() throws Exception {
int delay = 1;
String taskName = "Test";
HazelcastInstance[] instances = createClusterWithCount(2);
IScheduledExecutorService executorService = getScheduledExecutor(instances, ANY_EXECUTOR_NAME);
IScheduledFuture<Double> first = executorService.schedule(named(taskName, new PlainCallableTask()), delay, SECONDS);
ScheduledTaskHandler handler = first.getHandler();
first.dispose();
expected.expect(ExecutionException.class);
expected.expectCause(new RootCauseMatcher(StaleTaskException.class));
executorService.getScheduledFuture(handler).get();
}
use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class MemberAddressProviderTest method instanceFailsToStartWhenAssignedUnbindableAddress.
@Test
public void instanceFailsToStartWhenAssignedUnbindableAddress() {
final MemberAddressProvider mock = mock(MemberAddressProvider.class);
when(mock.getBindAddress()).thenReturn(new InetSocketAddress("1.2.3.4", 9999));
when(mock.getPublicAddress()).thenReturn(new InetSocketAddress("1.2.3.4", 0));
final Config config = getConfig(mock);
// we expect an BindException to be thrown (wrapped in an IllegalStateException)
rule.expect(HazelcastException.class);
rule.expect(new RootCauseMatcher(BindException.class));
Hazelcast.newHazelcastInstance(config);
}
use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class PromoteLiteMemberTest method notExistingMember_promotion_shouldFail.
@Test
public void notExistingMember_promotion_shouldFail() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance hz1 = factory.newHazelcastInstance(new Config());
HazelcastInstance hz2 = factory.newHazelcastInstance(new Config());
PromoteLiteMemberOp op = new PromoteLiteMemberOp();
op.setCallerUuid(UuidUtil.newUnsecureUUID());
InternalCompletableFuture<MembersView> future = getOperationService(hz2).invokeOnTarget(ClusterServiceImpl.SERVICE_NAME, op, getAddress(hz1));
exception.expect(CompletionException.class);
exception.expect(new RootCauseMatcher(IllegalStateException.class));
future.join();
}
Aggregations