/** * Checks the response to an HTTP request. * * @param c command * @param expStatus expected status * @param itemsCount expected number of items * @throws QueryException query exception */ private void checkResponse(final Command c, final int expStatus, final int itemsCount) throws QueryException { assertTrue(c.result() instanceof ItemIter); final ItemIter res = (ItemIter) c.result(); assertEquals(itemsCount, res.size()); assertTrue(res.item[0] instanceof FElem); final FElem response = (FElem) res.item[0]; assertNotNull(response.attr()); final NodeIter resAttr = response.attr(); Nod attr = null; while ((attr = resAttr.next()) != null) { if (Token.eq(attr.nname(), STATUS)) assertTrue(eq(attr.atom(), token(expStatus))); } }
/** * Recursive step iterator. * * @param l current step * @param nc node cache * @param ctx query context * @throws QueryException query exception */ private void iter(final int l, final NodeCache nc, final QueryContext ctx) throws QueryException { // cast is safe (steps will always return a {@link NodIter} instance final NodeIter ni = (NodeIter) ctx.iter(steps[l]); final boolean more = l + 1 != steps.length; for (ANode node; (node = ni.next()) != null; ) { if (more) { ctx.value = node; iter(l + 1, nc, ctx); } else { ctx.checkStop(); nc.add(node); } } }