Query query = QueryFactory.read(queryFile) ;
Dataset ds = DatasetFactory.create(defaultGraphURIs, namedGraphURIs) ;
// ---- First, get the expected results by executing in-memory or from a results file.
ResultSetRewindable rs1 = null ;
String expectedLabel = "" ;
if ( results != null )
{
rs1 = ResultSetFactory.makeRewindable(results.getResultSet()) ;
expectedLabel = "Results file" ;
}
else
{
QueryEngineFactory f = QueryEngineRef.getFactory() ;
QueryExecution qExec1 = new QueryExecutionBase(query, ds, null, f) ;
rs1 = ResultSetFactory.makeRewindable(qExec1.execSelect()) ;
qExec1.close() ;
expectedLabel = "Standard engine" ;
}
// ---- Second, execute in persistent graph
Dataset ds2 = dataset ; //DatasetFactory.create(model) ;
QueryExecution qExec2 = QueryExecutionFactory.create(query, ds2) ;
ResultSet rs = qExec2.execSelect() ;
ResultSetRewindable rs2 = ResultSetFactory.makeRewindable(rs) ;
// See if the same.
boolean b = ResultSetCompare.equalsByValue(rs1, rs2) ;
if ( !b )
{
rs1.reset() ;
rs2.reset() ;
System.out.println("------------------- "+this.getName());
System.out.printf("**** Expected (%s)", expectedLabel) ;
ResultSetFormatter.out(System.out, rs1) ;
System.out.println("**** Got (TDB)") ;
ResultSetFormatter.out(System.out, rs2) ;