use of com.hazelcast.util.RootCauseMatcher in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceTest method test_whenRingBufferIsFull_thenThrowRejectedExecutionException.
@Test
public void test_whenRingBufferIsFull_thenThrowRejectedExecutionException() throws Exception {
String key = randomString();
DurableExecutorService service = client.getDurableExecutorService(SINGLE_TASK + randomString());
service.submitToKeyOwner(new SleepingTask(100), key);
DurableExecutorServiceFuture<String> future = service.submitToKeyOwner(new BasicTestCallable(), key);
expectedException.expect(new RootCauseMatcher(RejectedExecutionException.class));
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();
}
use of com.hazelcast.util.RootCauseMatcher in project hazelcast by hazelcast.
the class ScheduledExecutorServiceBasicTest method getErroneous_durable.
@Test
public void getErroneous_durable() 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);
instances[1].getLifecycleService().shutdown();
Thread.sleep(2000);
expected.expect(ExecutionException.class);
expected.expectCause(new RootCauseMatcher(IllegalStateException.class, "Erroneous task"));
future.get();
}
Aggregations