void runTestSelect(Query query, QueryExecution qe) throws Exception {
    // Do the query!
    ResultSetRewindable resultsActual = ResultSetFactory.makeRewindable(qe.execSelect());

    qe.close();

    if (results == null) return;

    // 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);
    }

    // Hack for CSV : tests involving bNodes need manually checking.
    if (testItem.getResultFile().endsWith(".csv")) {
      resultsActual = convertToStrings(resultsActual);
      resultsActual.reset();

      int nActual = ResultSetFormatter.consume(resultsActual);
      int nExpected = ResultSetFormatter.consume(resultsExpected);
      resultsActual.reset();
      resultsExpected.reset();
      assertEquals("CSV: Different number of rows", nExpected, nActual);
      boolean b = resultSetEquivalent(query, resultsExpected, resultsActual);
      if (!b) System.out.println("Manual check of CSV results required: " + testItem.getName());
      return;
    }

    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;
  }
  private Dataset setUpDataset(Query query, TestItem testItem) {
    try {
      // testItem.requiresTextIndex()

      if (doesQueryHaveDataset(query) && doesTestItemHaveDataset(testItem)) {
        // Only warn if there are results to test
        // Syntax tests may have FROM etc and a manifest data file.
        if (testItem.getResultFile() != null)
          Log.warn(this, testItem.getName() + " : query data source and also in test file");
      }

      // In test file?
      if (doesTestItemHaveDataset(testItem))
        // Not specified in the query - get from test item and load
        return createDataset(testItem.getDefaultGraphURIs(), testItem.getNamedGraphURIs());

      // Check 3 - were there any at all?

      if (!doesQueryHaveDataset(query)) fail("No dataset");

      // Left to query
      return null;

    } catch (JenaException jEx) {
      fail("JenaException creating data source: " + jEx.getMessage());
      return null;
    }
  }
  private void compareGraphResults(Model resultsActual, Query query) {
    if (results != null) {
      try {
        if (!results.isGraph()) fail("Expected results are not a graph: " + testItem.getName());

        Model resultsExpected = results.getModel();
        if (!resultsExpected.isIsomorphicWith(resultsActual)) {
          printFailedModelTest(query, resultsExpected, resultsActual);
          fail("Results do not match: " + testItem.getName());
        }
      } catch (Exception ex) {
        String typeName = (query.isConstructType() ? "construct" : "describe");
        fail("Exception in result testing (" + typeName + "): " + ex);
      }
    }
  }
  private String makeDescription() {
    String tmp = "";
    if (testItem.getDefaultGraphURIs() != null) {
      for (Iterator<String> iter = testItem.getDefaultGraphURIs().iterator(); iter.hasNext(); )
        tmp = tmp + iter.next();
    }
    if (testItem.getNamedGraphURIs() != null) {
      for (Iterator<String> iter = testItem.getNamedGraphURIs().iterator(); iter.hasNext(); )
        tmp = tmp + iter.next();
    }

    String d = "Test " + testNumber + " :: " + testItem.getName();
    // +" :: QueryFile="+testItem.getQueryFile()+
    //          ", DataFile="+tmp+", ResultsFile="+testItem.getResultFile() ;
    return d;
  }
 @Override
 public String toString() {
   if (testItem.getName() != null) return testItem.getName();
   return super.getName();
 }