private String toString(TupleQueryResult results) throws QueryResultHandlerException, TupleQueryResultHandlerException, QueryEvaluationException, UnsupportedEncodingException { TupleQueryResultFormat format = getTupleFormat(); ByteArrayOutputStream out = new ByteArrayOutputStream(4096); TupleQueryResultWriter writer = QueryResultIO.createTupleWriter(format, out); writer.startDocument(); writer.startHeader(); writer.handleLinks(Arrays.<String>asList()); QueryResults.report(results, writer); return out.toString("UTF-8"); }
protected void assertQueryResultsEqual(TupleQueryResult expected, TupleQueryResult output) throws QueryEvaluationException, TupleQueryResultHandlerException, QueryResultHandlerException, UnsupportedEncodingException { MutableTupleQueryResult r1 = new MutableTupleQueryResult(expected); MutableTupleQueryResult r2 = new MutableTupleQueryResult(output); if (!QueryResults.equals(r1, r2)) { r1.beforeFirst(); r2.beforeFirst(); assertEquals(toString(r1), toString(r2)); r2.beforeFirst(); fail(toString(r2)); } }