use of com.hazelcast.util.RootCauseMatcher in project hazelcast by hazelcast.
the class LoggingScheduledExecutorTest method throwsExecutionException_withCallable_withFutureGetTimeout.
@Test
public void throwsExecutionException_withCallable_withFutureGetTimeout() throws Exception {
executor = new LoggingScheduledExecutor(logger, 1, factory);
Future<Integer> future = executor.submit(new FailedCallable());
expectedException.expect(new RootCauseMatcher(RuntimeException.class));
future.get(1, SECONDS);
assertNull(logger.getThrowable());
}
use of com.hazelcast.util.RootCauseMatcher in project hazelcast by hazelcast.
the class LoggingScheduledExecutorTest method throwsExecutionException_withCallable.
@Test
public void throwsExecutionException_withCallable() throws Exception {
executor = new LoggingScheduledExecutor(logger, 1, factory);
Future<Integer> future = executor.submit(new FailedCallable());
expectedException.expect(new RootCauseMatcher(RuntimeException.class));
future.get();
assertNull(logger.getThrowable());
}
use of com.hazelcast.util.RootCauseMatcher in project hazelcast by hazelcast.
the class ScheduledExecutorServiceBasicTest method getErroneous.
@Test
public void getErroneous() throws InterruptedException, ExecutionException {
int delay = 2;
String taskName = "Test";
String completionLatchName = "completionLatch";
HazelcastInstance[] instances = createClusterWithCount(2);
String key = generateKeyOwnedBy(instances[1]);
IScheduledExecutorService executorService = getScheduledExecutor(instances, "s");
ICountDownLatch latch = instances[1].getCountDownLatch(completionLatchName);
latch.trySetCount(1);
IScheduledFuture<Double> future = executorService.scheduleOnKeyOwner(named(taskName, new ErroneousCallableTask(completionLatchName)), key, delay, SECONDS);
latch.await(10, SECONDS);
expected.expect(ExecutionException.class);
expected.expectCause(new RootCauseMatcher(IllegalStateException.class, "Erroneous task"));
future.get();
}
use of com.hazelcast.util.RootCauseMatcher in project hazelcast by hazelcast.
the class TargetTest method testConstructor_withInvalidPartitionId.
@Test
public void testConstructor_withInvalidPartitionId() throws Exception {
// retrieve the wanted constructor and make it accessible
Constructor<Target> constructor = Target.class.getDeclaredConstructor(Target.TargetFlag.class, Integer.class);
constructor.setAccessible(true);
// we expect an IllegalArgumentException to be thrown
rule.expect(new RootCauseMatcher(IllegalArgumentException.class));
constructor.newInstance(Target.TargetFlag.PARTITION_OWNER, null);
}
use of com.hazelcast.util.RootCauseMatcher in project hazelcast by hazelcast.
the class ScheduledExecutorServiceBasicTest method schedule_getHandlerDisposeThenRecreateFutureAndGet.
@Test
public void schedule_getHandlerDisposeThenRecreateFutureAndGet() throws ExecutionException, InterruptedException {
int delay = 1;
String taskName = "Test";
HazelcastInstance[] instances = createClusterWithCount(2);
IScheduledExecutorService executorService = getScheduledExecutor(instances, "s");
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();
}
Aggregations