use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class InboundResponseHandler_NotifyTest method errorResponse_whenInvocationExists.
// ==================== errorResponse ======================
@Test
public void errorResponse_whenInvocationExists() {
Invocation invocation = newInvocation();
invocationRegistry.register(invocation);
long callId = invocation.op.getCallId();
inboundResponseHandler.notifyErrorResponse(callId, new ExpectedRuntimeException(), null);
try {
invocation.future.joinInternal();
fail();
} catch (ExpectedRuntimeException expected) {
}
assertInvocationDeregisteredEventually(callId);
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class OperationServiceImpl_invokeOnTargetTest method whenExceptionThrownInOperationRun.
@Test
public void whenExceptionThrownInOperationRun() {
DummyOperation operation = new DummyOperation(new ExceptionThrowingCallable());
InternalCompletableFuture<String> invocation = operationService.invokeOnTarget(null, operation, getAddress(remote));
try {
invocation.joinInternal();
fail();
} catch (ExpectedRuntimeException expected) {
}
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class Invocation_OffloadedTest method whenStartThrowsException_thenExceptionPropagated.
@Test(expected = ExpectedRuntimeException.class)
public void whenStartThrowsException_thenExceptionPropagated() {
InternalCompletableFuture f = localOperationService.invokeOnPartition(new OffloadingOperation(op -> new Offload(op) {
@Override
public void start() {
throw new ExpectedRuntimeException();
}
}));
assertCompletesEventually(f);
f.joinInternal();
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class MapTransactionTest method testFailingMapStore.
@Test
public // TODO: @mm - Review following case...
void testFailingMapStore() throws TransactionException {
final String map = "map";
final String anotherMap = "anotherMap";
Config config = getConfig();
config.getMapConfig(map).setMapStoreConfig(new MapStoreConfig().setEnabled(true).setImplementation(new MapStoreAdapter() {
public void store(Object key, Object value) {
throw new ExpectedRuntimeException("Map store intentionally failed :) ");
}
}));
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
final HazelcastInstance h1 = factory.newHazelcastInstance(config);
final HazelcastInstance h2 = factory.newHazelcastInstance(config);
try {
h1.executeTransaction(options, new TransactionalTask<Boolean>() {
public Boolean execute(TransactionalTaskContext context) throws TransactionException {
assertNull(context.getMap(map).put("1", "value1"));
assertNull(context.getMap(anotherMap).put("1", "value1"));
return true;
}
});
fail();
} catch (ExpectedRuntimeException expected) {
}
assertNull(h2.getMap(map).get("1"));
assertEquals("value1", h2.getMap(anotherMap).get("1"));
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class InternalCompletableFutureTest method newCompletableFuture.
@Override
protected InternalCompletableFuture<Object> newCompletableFuture(boolean exceptional, long completeAfterMillis) {
InternalCompletableFuture<Object> future = incompleteFuture();
Executor completionExecutor;
if (completeAfterMillis <= 0) {
completionExecutor = CALLER_RUNS;
} else {
completionExecutor = new Executor() {
@Override
public void execute(Runnable command) {
new Thread(() -> {
sleepAtLeastMillis(completeAfterMillis);
command.run();
}, "test-completion-thread").start();
}
};
}
if (exceptional) {
completionExecutor.execute(() -> future.completeExceptionally(new ExpectedRuntimeException()));
} else {
completionExecutor.execute(completeNormally(future));
}
return future;
}
Aggregations