use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class PacketDispatcherImplTest method whenProblemHandlingPacket_thenSwallowed.
// when one of the handlers throws an exception, the exception is logged but not rethrown
@Test
public void whenProblemHandlingPacket_thenSwallowed() throws Exception {
Packet packet = new Packet().setPacketType(Packet.Type.OPERATION);
Mockito.doThrow(new ExpectedRuntimeException()).when(operationExecutor).handle(packet);
dispatcher.dispatch(packet);
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class HazelcastInstanceFactoryTest method test_NewInstance_failedAfterStartAndBeforeShutdown.
@Test(expected = ExpectedRuntimeException.class)
public void test_NewInstance_failedAfterStartAndBeforeShutdown() throws Exception {
NodeContext context = new TestNodeContext() {
@Override
public NodeExtension createNodeExtension(Node node) {
NodeExtension nodeExtension = super.createNodeExtension(node);
doThrow(new ExpectedRuntimeException()).when(nodeExtension).afterStart();
doThrow(new ExpectedRuntimeException()).when(nodeExtension).beforeShutdown();
return nodeExtension;
}
};
Config config = new Config();
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
hazelcastInstance = HazelcastInstanceFactory.newHazelcastInstance(config, randomString(), context);
}
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().getMulticastConfig().setEnabled(false);
hazelcastInstance = HazelcastInstanceFactory.newHazelcastInstance(config, randomString(), context);
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class HazelcastInstanceFactoryTest method test_NewInstance_failed_beforeNodeStart.
@Test(expected = ExpectedRuntimeException.class)
public void test_NewInstance_failed_beforeNodeStart() throws Exception {
NodeContext context = new TestNodeContext() {
@Override
public NodeExtension createNodeExtension(Node node) {
NodeExtension nodeExtension = super.createNodeExtension(node);
doThrow(new ExpectedRuntimeException()).when(nodeExtension).beforeStart();
return nodeExtension;
}
};
Config config = new Config();
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
hazelcastInstance = HazelcastInstanceFactory.newHazelcastInstance(config, randomString(), context);
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class AbstractInvocationFuture_AndThenTest method whenExceptionalResponseAvailableAfterSomeWaiting.
@Test
public void whenExceptionalResponseAvailableAfterSomeWaiting() {
final ExecutionCallback callback = mock(ExecutionCallback.class);
future.andThen(callback);
sleepSeconds(5);
verifyZeroInteractions(callback);
final ExpectedRuntimeException ex = new ExpectedRuntimeException();
future.complete(ex);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
verify(callback).onFailure(ex);
}
});
}
Aggregations