}
void runTestSelect(Query query, QueryExecution qe) throws Exception
{
// Do the query!
ResultSetRewindable resultsActual = ResultSetFactory.makeRewindable(qe.execSelect()) ;
// Turn into a resettable version
//ResultSetRewindable results = ResultSetFactory.makeRewindable(resultsActual) ;
qe.close() ;
if ( results == null )
return ;
if ( true )
{
// Assumes resultSetCompare can cope with full isomorphism possibilities.
ResultSetRewindable resultsExpected ;
if ( results.isResultSet() )
resultsExpected = ResultSetFactory.makeRewindable(results.getResultSet()) ;
else if ( results.isModel() )
resultsExpected = ResultSetFactory.makeRewindable(results.getModel()) ;
else
{
fail("Wrong result type for SELECT query") ;
resultsExpected = null ; // Keep the compiler happy
}
if ( query.isReduced() )
{
// Reduced - best we can do is DISTINCT
resultsExpected = unique(resultsExpected) ;
resultsActual = unique(resultsActual) ;
}
boolean b = resultSetEquivalent(query, resultsExpected, resultsActual) ;
if ( ! b )
{
resultsExpected.reset() ;
resultsActual.reset() ;
boolean b2 = resultSetEquivalent(query, resultsExpected, resultsActual) ;
printFailedResultSetTest(query, qe, resultsExpected, resultsActual) ;
}
assertTrue("Results do not match: "+testItem.getName(), b) ;
return ;
}
// TEMPOPRARY
// Later (when result set compare can cope with full bNode isomorphism)
// always convert a result set model to a result set and test.
if ( results.isResultSet() )
{
ResultSetRewindable resultsExpected = ResultSetFactory.makeRewindable(results.getResultSet()) ;
if ( query.isReduced() )
{
// Reduced - best we can do is DISTINCT
resultsExpected = unique(resultsExpected) ;
resultsActual = unique(resultsActual) ;
}
boolean b = resultSetEquivalent(query, resultsExpected, resultsActual) ;
if ( ! b )
printFailedResultSetTest(query, qe, resultsExpected, resultsActual) ;
assertTrue("Results do not match: "+testItem.getName(), b) ;
}
else if ( results.isModel() )
{
// TEMPORARY
// A lot of early tests were written using RDF-encoded result sets.
// Choosing to do model->result set is delayed.
// The results might have been for CONSTRUCT/DESCRIBE
// What's more the this can cope with isomorphism of bNodes.
Model resultsExpected = results.getModel() ;
if ( query.isReduced() )
{
// Reduced - best we can do is DISTINCT
ResultSetRewindable x = ResultSetFactory.makeRewindable(resultsExpected) ;
resultsExpected = ResultSetFormatter.toModel(unique(x)) ;
resultsActual = unique(resultsActual) ;
}
//System.err.println(getName()+": Result set model testing") ;