use of com.hazelcast.test.ExpectedRuntimeException 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.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class HazelcastInstanceFactoryTest method test_NewInstance_failed_beforeNodeShutdown.
@Test(expected = ExpectedRuntimeException.class)
public void test_NewInstance_failed_beforeNodeShutdown() throws Exception {
NodeContext context = new TestNodeContext() {
@Override
public NodeExtension createNodeExtension(Node node) {
NodeExtension nodeExtension = super.createNodeExtension(node);
doAnswer(new Answer() {
final AtomicBoolean throwException = new AtomicBoolean(false);
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
if (throwException.compareAndSet(false, true)) {
throw new ExpectedRuntimeException();
}
return null;
}
}).when(nodeExtension).beforeShutdown(true);
return nodeExtension;
}
};
Config config = new Config();
config.getNetworkConfig().getJoin().getAutoDetectionConfig().setEnabled(false);
hazelcastInstance = HazelcastInstanceFactory.newHazelcastInstance(config, randomString(), context);
try {
hazelcastInstance.getLifecycleService().terminate();
} catch (ExpectedRuntimeException expected) {
hazelcastInstance.getLifecycleService().terminate();
throw expected;
}
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class HazelcastInstanceFactoryTest method test_NewInstance_failed_beforeJoin.
@Test(expected = ExpectedRuntimeException.class)
public void test_NewInstance_failed_beforeJoin() throws Exception {
NodeContext context = new TestNodeContext() {
@Override
public NodeExtension createNodeExtension(Node node) {
NodeExtension nodeExtension = super.createNodeExtension(node);
doThrow(new ExpectedRuntimeException()).when(nodeExtension).beforeJoin();
return nodeExtension;
}
};
Config config = new Config();
config.getNetworkConfig().getJoin().getAutoDetectionConfig().setEnabled(false);
hazelcastInstance = HazelcastInstanceFactory.newHazelcastInstance(config, randomString(), context);
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class RenderTest method whenException.
@Test
public void whenException() {
MetricsCollector renderer = mock(MetricsCollector.class);
final ExpectedRuntimeException ex = new ExpectedRuntimeException();
metricsRegistry.registerStaticProbe(this, "foo", ProbeLevel.MANDATORY, (LongProbeFunction<RenderTest>) source -> {
throw ex;
});
metricsRegistry.collect(renderer);
verify(renderer).collectException(metricDescriptor("foo"), ex);
verifyNoMoreInteractions(renderer);
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class JobTest method when_jobFailed_then_jobStatusIsCompletedEventually.
@Test
public void when_jobFailed_then_jobStatusIsCompletedEventually() throws InterruptedException {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS((SupplierEx<Processor>) () -> new MockP().setCompleteError(new ExpectedRuntimeException()), NODE_COUNT)));
// When
Job job = instance().getJet().newJob(dag);
// Then
try {
job.getFuture().get();
fail();
} catch (ExecutionException expected) {
assertEquals(FAILED, job.getStatus());
}
}
Aggregations