throws Exception
{
MemoryStore store = new MemoryStore(dataDir);
store.initialize();
ValueFactory factory = store.getValueFactory();
URI foo = factory.createURI("http://www.foo.example/foo");
URI bar = factory.createURI("http://www.foo.example/bar");
SailConnection con = store.getConnection();
con.addStatement(foo, RDF.TYPE, bar);
con.commit();
ParsedTupleQuery query = QueryParserUtil.parseTupleQuery(QueryLanguage.SERQL,
"SELECT X, P, Y FROM {X} P {Y}", null);
TupleExpr tupleExpr = query.getTupleExpr();
CloseableIteration<? extends BindingSet, QueryEvaluationException> iter = con.evaluate(tupleExpr, null,
EmptyBindingSet.getInstance(), false);
BindingSet bindingSet = iter.next();
assertEquals(bindingSet.getValue("X"), foo);
assertEquals(bindingSet.getValue("P"), RDF.TYPE);
assertEquals(bindingSet.getValue("Y"), bar);
iter.close();
con.close();
store.shutDown();
store = new MemoryStore(dataDir);
store.initialize();
factory = store.getValueFactory();
foo = factory.createURI("http://www.foo.example/foo");
bar = factory.createURI("http://www.foo.example/bar");
con = store.getConnection();
iter = con.evaluate(tupleExpr, null, EmptyBindingSet.getInstance(), false);