QueryExecution qe = QueryExecutionFactory.create(q, ds);
ResultSetRewindable rs = ResultSetFactory.makeRewindable(qe.execSelect());
if (expected != rs.size()) {
System.err.println("Non-optimized results not as expected");
TextOutput output = new TextOutput((SerializationContext)null);
output.format(System.out, rs);
rs.reset();
}
Assert.assertEquals(expected, rs.size());
qe.close();