public void testRunnableExecution() throws InterruptedException { final String uuid = UUID.randomUUID().toString(); try { DistributedExecutorService des = createDES(getCache()); BoringRunnable runnable = new BoringRunnable(uuid); des.execute(runnable); eventually(() -> counterMap.get(uuid) != null && counterMap.get(uuid).get() >= 1); } finally { counterMap.remove(uuid); } }
/** * Helper public method (used by CDI module), disabled as some IDEs invoke it as a test method */ @Test(enabled = false) // Disable explicitly to avoid TestNG thinking this is a test!! public void basicInvocation(Callable<Integer> call, Object... keys) throws Exception { DistributedExecutorService des = createDES(getCache()); Future<Integer> future = des.submit(call, keys); Integer r = future.get(); assertEquals((Integer) 1, r); }
public void testInvokeAnyEmptyTasks() throws Exception { DistributedExecutorService des = createDES(getCache()); expectException(IllegalArgumentException.class, () -> des.invokeAny(new ArrayList<SimpleCallable>())); }
/** * Tests Callable isolation as it gets invoked across the cluster * https://issues.jboss.org/browse/ISPN-1041 */ public void testCallableIsolation() throws Exception { DistributedExecutorService des = createDES(getCache()); List<CompletableFuture<Integer>> list = des.submitEverywhere(new SimpleCallableWithField()); assert list != null && !list.isEmpty(); for (Future<Integer> f : list) { assertEquals((Integer) 0, f.get()); } }
public void testNullRunnableExecution() { DistributedExecutorService des = createDES(getCache()); BoringRunnable runnable = null; expectException(IllegalArgumentException.class, () -> des.execute(runnable)); }
public void testRunnableInvocation() throws Exception { DistributedExecutorService des = createDES(getCache()); Future<?> future = des.submit(new BoringRunnable()); Object object = future.get(); assertEquals(null, object); }
public void testBasicDistributedCallableEverywhereWithKeysAndNullTask() throws Exception { DistributedExecutorService des = createDES(getCache()); DistributedTask task = null; expectException(NullPointerException.class, () -> des.submitEverywhere(task, "key1", "key2")); }
public void testBasicDistributedCallableEverywhereWithNullTask() throws Exception { DistributedExecutorService des = createDES(getCache()); DistributedTask task = null; expectException(NullPointerException.class, () -> des.submitEverywhere(task)); }
public void testRunnableInvocationWith2Params() throws Exception { DistributedExecutorService des = createDES(getCache()); Integer result = 5; Future<Integer> future = des.submit(new BoringRunnable(), result); assertEquals(result, future.get()); }
public void testInvokeAny() throws Exception { DistributedExecutorService des = createDES(getCache()); List<SimpleCallable> tasks = new ArrayList<>(); tasks.add(new SimpleCallable()); Integer result = des.invokeAny(tasks); assertEquals((Integer) 1, result); tasks = new ArrayList<>(); tasks.add(new SimpleCallable()); tasks.add(new SimpleCallable()); result = des.invokeAny(tasks); assertEquals((Integer) 1, result); }
public void testInvokeAnyWithTimeout() throws Exception { DistributedExecutorService des = createDES(getCache()); List<SimpleCallable> tasks = new ArrayList<>(); tasks.add(new SimpleCallable()); Integer result = des.invokeAny(tasks, 1000, TimeUnit.MILLISECONDS); assertEquals((Integer) 1, result); tasks = new ArrayList<>(); tasks.add(new SimpleCallable()); tasks.add(new SimpleCallable()); result = des.invokeAny(tasks, 1000, TimeUnit.MILLISECONDS); assertEquals((Integer) 1, result); }
public void testInvokeAnyNoTask() throws Exception { DistributedExecutorService des = createDES(getCache()); expectException(NullPointerException.class, () -> des.invokeAny(null)); }
public void testInvokeAnyTimedSleepingTasks() throws Exception { DistributedExecutorService des = createDES(getCache()); List<SleepingSimpleCallable> tasks = new ArrayList<>(); tasks.add(new SleepingSimpleCallable(latchHolder)); expectException(TimeoutException.class, () -> des.invokeAny(tasks, 100, TimeUnit.MILLISECONDS)); latchHolder.get().open(); }
public void testBasicDistributedCallableWithNullTask() throws Exception { Cache<Object, Object> c1 = getCache(); DistributedExecutorService des = createDES(getCache()); DistributedTask task = null; expectException(NullPointerException.class, () -> des.submit(task, "key1", "key2")); }
public void testExceptionCallableWithTimedCall() throws Exception { DistributedExecutorService des = createDES(getCache()); Future<Integer> future = des.submit(new ExceptionThrowingCallable(latchHolder, true)); expectException(TimeoutException.class, () -> future.get(100, TimeUnit.MILLISECONDS)); latchHolder.get().open(); }
public void testBasicTargetDistributedCallableWithNullExecutionPolicy() throws Exception { Cache<Object, Object> cache1 = getCache(); //initiate task from cache1 and select cache2 as target DistributedExecutorService des = createDES(cache1); //the same using DistributedTask API DistributedTaskBuilder<Boolean> taskBuilder = des.createDistributedTaskBuilder(new SimpleDistributedCallable(false)); expectException(IllegalArgumentException.class, () -> taskBuilder.executionPolicy(null)); }
public void testSleepingCallableWithTimeoutExc() throws Exception { DistributedExecutorService des = createDES(getCache()); Future<Integer> future = des.submit(new SleepingSimpleCallable(latchHolder)); log.tracef("Sleeping task submitted"); expectException(TimeoutException.class, () -> future.get(100, TimeUnit.MILLISECONDS)); latchHolder.get().open(); }
public void testExceptionCallableWithTimedCallDistApi() throws Exception { DistributedExecutorService des = createDES(getCache()); DistributedTaskBuilder<Integer> taskBuilder = des.createDistributedTaskBuilder(new ExceptionThrowingCallable(latchHolder, true)); DistributedTask<Integer> distributedTask = taskBuilder.build(); Future<Integer> future = des.submit(distributedTask); expectException(TimeoutException.class, () -> future.get(10, TimeUnit.MILLISECONDS)); latchHolder.get().open(); }
public void testSleepingCallableWithTimeoutExcDistApi() throws Exception { DistributedExecutorService des = createDES(getCache()); DistributedTaskBuilder<Integer> taskBuilder = des.createDistributedTaskBuilder(new SleepingSimpleCallable(latchHolder)); DistributedTask<Integer> distributedTask = taskBuilder.build(); Future<Integer> future = des.submit(distributedTask); log.tracef("Sleeping task submitted"); expectException(TimeoutException.class, () -> future.get(100, TimeUnit.MILLISECONDS)); latchHolder.get().open(); }
public void testBasicDistributedCallableWithNullKeys() throws Exception { Cache<Object, Object> c1 = getCache(); c1.put("key1", "value1"); c1.put("key2", "value2"); c1.put("key3", "value3"); c1.put("key4", "value4"); DistributedExecutorService des = createDES(getCache()); des.submit(new SimpleDistributedCallable(false)); }