/** * Test futures chaining. * * @throws Exception In case of any exception. */ @Test public void testChaining() throws Exception { checkChaining(null); ExecutorService exec = Executors.newFixedThreadPool(1); try { checkChaining(exec); GridFinishedFuture<Integer> fut = new GridFinishedFuture<>(1); IgniteInternalFuture<Object> chain = fut.chain(new CX1<IgniteInternalFuture<Integer>, Object>() { @Override public Object applyx(IgniteInternalFuture<Integer> fut) throws IgniteCheckedException { return fut.get() + 1; } }, exec); assertEquals(2, chain.get()); } finally { exec.shutdown(); } }
assertEquals(0, latch.getCount()); assertTrue(called.get());
IgniteInternalFuture<Object> chain = exec != null ? fut.chain(passThrough, exec) : fut.chain(passThrough); assertFalse(fut.isDone()); assertFalse(chain.isDone()); fail("Expects timeout exception."); info("Expected timeout exception: " + e.getMessage()); assertEquals("result", exec == null ? chain.get(1) : chain.get()); chain.get(); fail("Expects failed with exception."); info("Expected exception: " + e.getMessage()); fail("Expects failed with error."); info("Expected error: " + e.getMessage()); chain.get(); fail("Expects failed with error."); info("Expected error: " + e.getMessage());
info("Caught expected exception: " + e); assertEquals("Finished", o); assertEquals("Finished", o); info("Caught expected exception: " + e); info("Caught expected exception: " + e);
assertNull(fut.get()); assertEquals("test", fut.get()); assertEquals("test", fut.get());