/** * Compares results. * * @param expected expected result * @param returned returned result * @throws Exception exception */ private static void compare(final ItemList expected, final ItemList returned) throws Exception { // Compare response with expected result assertEquals("Different number of results", expected.size(), returned.size()); final long es = expected.size(); for (int e = 0; e < es; e++) { final Item exp = expected.get(e), ret = returned.get(e); if (!new DeepEqual().equal(exp, ret)) { final TokenBuilder tb = new TokenBuilder("Result ").addLong(e).add(" differs:\nReturned: "); tb.addExt(ret.serialize()).add("\nExpected: ").addExt(exp.serialize()); fail(tb.toString()); } } }
/** * Performs a test on the specified data. * * @param data data to be tested * @throws IOException I/O exception */ private static void run(final byte[] data) throws IOException { final TokenBuilder tb = new TokenBuilder(); final TextInput ti = new TextInput(new IOContent(data)); ti.read(); ti.reset(); for (int b; (b = ti.read()) != -1; ) tb.add(b); try { ti.reset(); assertTrue( "Mark should not be supported for data size of " + data.length, data.length < IO.BLOCKSIZE); tb.reset(); for (int b; (b = ti.read()) != -1; ) tb.add(b); assertSame(data, tb.finish()); } catch (final IOException ex) { assertTrue( "Mark could not be reset for data size of " + data.length, data.length >= IO.BLOCKSIZE); } }