/** * Wait until the operation is somehow finished */ public final DeferredResult join() throws InterruptedException { join(0); return this; }
public <T> T await() throws InterruptedException { join(); return (T) result; }
public <T> T await(long millis) throws InterruptedException { return join(millis) ? (T) result : null; }
/** * waits until the operation is finished and return it's result on success, or throws an error on failure. * * @throws Error or {@link Failure} if operation fails */ public <T> T waitSuccess() throws Error, InterruptedException { join(); if (isSuccess()) return (T) result; if (result instanceof Exception) throw new Error((Exception) result); throw new Failure(result); }
a.send("ping").success((Object data) -> lastObject = data).join(); assertEquals("pong", lastObject); a.send("bad", null, null).failure((Object data) -> lastObject = data).join(); assertTrue(lastObject instanceof Farcall.RemoteException); }).failure((err) -> { fail(err.toString()); }).join(); HashMap<String, Object> res = (HashMap<String, Object>) lastObject; assertEquals(2, res.size());