{
String query = readQuery();
// Create a repository with the query data
Sail sail = new MemoryStore();
if ("RDF".equals(entailment)) {
// do not add inferencers
}
else if ("RDFS".equals(entailment)) {
sail = new ForwardChainingRDFSInferencer(sail);
}
else if ("RDFS-VP".equals(entailment)) {
sail = new ForwardChainingRDFSInferencer(sail);
sail = new DirectTypeHierarchyInferencer(sail);
}
else {
sail.shutDown();
fail("Invalid value for entailment level:" + entailment);
}
Repository dataRep = new SailRepository(sail);
dataRep.initialize();
RepositoryConnection dataCon = dataRep.getConnection();
// Add unnamed gaph
dataCon.add(new URL(dataFile), null, RDFFormat.forFileName(dataFile));
// add named graphs
for (String graphName : graphNames) {
dataCon.add(new URL(graphName), null, RDFFormat.forFileName(graphName), new URIImpl(graphName));
}
// Evaluate the query on the query data
GraphQueryResult result = dataCon.prepareGraphQuery(QueryLanguage.SERQL, query).evaluate();
Collection<Statement> actualStatements = Iterations.addAll(result, new ArrayList<Statement>(1));
result.close();
dataCon.close();
dataRep.shutDown();
// Create a repository with the expected result data
Repository expectedResultRep = new SailRepository(new MemoryStore());
expectedResultRep.initialize();
RepositoryConnection erCon = expectedResultRep.getConnection();
erCon.add(new URL(resultFile), null, RDFFormat.forFileName(resultFile));