Search in sources :

Example 1 with FailingCallable

use of com.hazelcast.client.executor.tasks.FailingCallable in project hazelcast by hazelcast.

the class ClientDurableExecutorServiceTest method testSubmitFailingCallableException_withExecutionCallback.

@Test
public void testSubmitFailingCallableException_withExecutionCallback() throws Exception {
    DurableExecutorService service = client.getDurableExecutorService(randomString());
    final CountDownLatch latch = new CountDownLatch(1);
    service.submit(new FailingCallable()).andThen(new ExecutionCallback<String>() {

        @Override
        public void onResponse(String response) {
        }

        @Override
        public void onFailure(Throwable t) {
            latch.countDown();
        }
    });
    assertTrue(latch.await(10, TimeUnit.SECONDS));
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) CountDownLatch(java.util.concurrent.CountDownLatch) FailingCallable(com.hazelcast.client.executor.tasks.FailingCallable) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with FailingCallable

use of com.hazelcast.client.executor.tasks.FailingCallable in project hazelcast by hazelcast.

the class ClientExecutorServiceTest method testSubmitFailingCallableReasonExceptionCause.

@Test(expected = IllegalStateException.class)
public void testSubmitFailingCallableReasonExceptionCause() throws Throwable {
    IExecutorService service = client.getExecutorService(randomString());
    Future<String> failingFuture = service.submit(new FailingCallable());
    try {
        failingFuture.get();
    } catch (ExecutionException e) {
        throw e.getCause();
    }
}
Also used : IExecutorService(com.hazelcast.core.IExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutionException(java.util.concurrent.ExecutionException) FailingCallable(com.hazelcast.client.executor.tasks.FailingCallable) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with FailingCallable

use of com.hazelcast.client.executor.tasks.FailingCallable in project hazelcast by hazelcast.

the class ClientDurableExecutorServiceTest method testSubmitFailingCallableException.

@Test
public void testSubmitFailingCallableException() throws Exception {
    DurableExecutorService service = client.getDurableExecutorService(randomString());
    Future<String> failingFuture = service.submit(new FailingCallable());
    expectedException.expect(ExecutionException.class);
    failingFuture.get();
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) FailingCallable(com.hazelcast.client.executor.tasks.FailingCallable) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 4 with FailingCallable

use of com.hazelcast.client.executor.tasks.FailingCallable in project hazelcast by hazelcast.

the class ClientDurableExecutorServiceTest method testSubmitFailingCallableReasonExceptionCause.

@Test
public void testSubmitFailingCallableReasonExceptionCause() throws Exception {
    DurableExecutorService service = client.getDurableExecutorService(randomString());
    Future<String> future = service.submit(new FailingCallable());
    expectedException.expect(new RootCauseMatcher(IllegalStateException.class));
    future.get();
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) RootCauseMatcher(com.hazelcast.util.RootCauseMatcher) FailingCallable(com.hazelcast.client.executor.tasks.FailingCallable) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 5 with FailingCallable

use of com.hazelcast.client.executor.tasks.FailingCallable in project hazelcast by hazelcast.

the class ClientExecutorServiceTest method testSubmitFailingCallableException.

@Test(expected = ExecutionException.class)
public void testSubmitFailingCallableException() throws ExecutionException, InterruptedException {
    IExecutorService service = client.getExecutorService(randomString());
    Future<String> failingFuture = service.submit(new FailingCallable());
    failingFuture.get();
}
Also used : IExecutorService(com.hazelcast.core.IExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) FailingCallable(com.hazelcast.client.executor.tasks.FailingCallable) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

FailingCallable (com.hazelcast.client.executor.tasks.FailingCallable)6 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)6 ParallelTest (com.hazelcast.test.annotation.ParallelTest)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Test (org.junit.Test)6 IExecutorService (com.hazelcast.core.IExecutorService)3 DurableExecutorService (com.hazelcast.durableexecutor.DurableExecutorService)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 RootCauseMatcher (com.hazelcast.util.RootCauseMatcher)1 ExecutionException (java.util.concurrent.ExecutionException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1