Search in sources :

Example 6 with RootCauseMatcher

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();
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) SleepingTask(com.hazelcast.executor.ExecutorServiceTestSupport.SleepingTask) BasicTestCallable(com.hazelcast.executor.ExecutorServiceTestSupport.BasicTestCallable) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) RootCauseMatcher(com.hazelcast.util.RootCauseMatcher) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 7 with RootCauseMatcher

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);
}
Also used : RootCauseMatcher(com.hazelcast.util.RootCauseMatcher) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 8 with RootCauseMatcher

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();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) RootCauseMatcher(com.hazelcast.util.RootCauseMatcher) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 9 with RootCauseMatcher

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();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ICountDownLatch(com.hazelcast.core.ICountDownLatch) RootCauseMatcher(com.hazelcast.util.RootCauseMatcher) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

ParallelTest (com.hazelcast.test.annotation.ParallelTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9 RootCauseMatcher (com.hazelcast.util.RootCauseMatcher)9 Test (org.junit.Test)9 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 ICountDownLatch (com.hazelcast.core.ICountDownLatch)2 DurableExecutorService (com.hazelcast.durableexecutor.DurableExecutorService)2 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)2 FailingCallable (com.hazelcast.client.executor.tasks.FailingCallable)1 PartitioningStrategyConfig (com.hazelcast.config.PartitioningStrategyConfig)1 BasicTestCallable (com.hazelcast.executor.ExecutorServiceTestSupport.BasicTestCallable)1 SleepingTask (com.hazelcast.executor.ExecutorServiceTestSupport.SleepingTask)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1