use of org.eclipse.rdf4j.query.QueryLanguage in project rdf4j by eclipse.
the class ContextAwareConnectionTest method testTupleQuery.
@Test
public void testTupleQuery() throws Exception {
RepositoryConnection stub = new RepositoryConnectionStub() {
@Override
public TupleQuery prepareTupleQuery(QueryLanguage ql, String query, String baseURI) throws MalformedQueryException, RepositoryException {
assertEquals(SPARQL, ql);
assertEquals(queryString, query);
return new TupleQueryStub() {
@Override
public void setDataset(Dataset dataset) {
Set<IRI> contexts = Collections.singleton(context);
assertEquals(contexts, dataset.getDefaultGraphs());
super.setDataset(dataset);
}
};
}
};
Repository repo = stub.getRepository();
ContextAwareConnection con = new ContextAwareConnection(repo, stub);
con.setReadContexts(context);
con.setQueryLanguage(SERQL);
con.prepareTupleQuery(SPARQL, queryString, null);
}
use of org.eclipse.rdf4j.query.QueryLanguage in project rdf4j by eclipse.
the class ContextAwareConnectionTest method testGraphQuery.
@Test
public void testGraphQuery() throws Exception {
RepositoryConnection stub = new RepositoryConnectionStub() {
@Override
public GraphQuery prepareGraphQuery(QueryLanguage ql, String query, String baseURI) throws MalformedQueryException, RepositoryException {
assertEquals(SPARQL, ql);
assertEquals(queryString, query);
return new GraphQueryStub() {
@Override
public void setDataset(Dataset dataset) {
Set<IRI> contexts = Collections.singleton(context);
assertEquals(contexts, dataset.getDefaultGraphs());
super.setDataset(dataset);
}
};
}
};
Repository repo = stub.getRepository();
ContextAwareConnection con = new ContextAwareConnection(repo, stub);
con.setReadContexts(context);
con.setQueryLanguage(SERQL);
con.prepareGraphQuery(SPARQL, queryString, null);
}
use of org.eclipse.rdf4j.query.QueryLanguage in project rdf4j by eclipse.
the class InterceptorTest method testUpdate.
@Test
public void testUpdate() throws Exception {
final Update updateStub = new UpdateStub() {
public void execute() throws UpdateExecutionException {
fail();
}
};
final RepositoryConnection stub = new RepositoryConnectionStub() {
public Update prepareUpdate(QueryLanguage ql, String query, String baseURI) throws MalformedQueryException, RepositoryException {
return updateStub;
}
};
Repository repo = stub.getRepository();
InterceptingRepositoryConnection con = new InterceptingRepositoryConnectionWrapper(repo, stub);
con.addRepositoryConnectionInterceptor(new RepositoryConnectionInterceptorAdapter() {
public boolean execute(RepositoryConnection conn, QueryLanguage ql, String update, String baseURI, Update operation) {
assertEquals(stub, conn);
assertEquals(SPARQL, ql);
assertEquals("DELETE DATA { <> <> <> }", update);
assertEquals("http://example.com/", baseURI);
assertEquals(updateStub, operation);
return true;
}
});
Update update = con.prepareUpdate(SPARQL, "DELETE DATA { <> <> <> }", "http://example.com/");
update.execute();
}
use of org.eclipse.rdf4j.query.QueryLanguage in project rdf4j by eclipse.
the class ContextAwareConnectionTest method testQuery.
@Test
public void testQuery() throws Exception {
RepositoryConnection stub = new RepositoryConnectionStub() {
@Override
public Query prepareQuery(QueryLanguage ql, String query, String baseURI) throws MalformedQueryException, RepositoryException {
assertEquals(SPARQL, ql);
assertEquals(queryString, query);
return new QueryStub() {
@Override
public void setDataset(Dataset dataset) {
Set<IRI> contexts = Collections.singleton(context);
assertEquals(contexts, dataset.getDefaultGraphs());
super.setDataset(dataset);
}
};
}
};
Repository repo = stub.getRepository();
ContextAwareConnection con = new ContextAwareConnection(repo, stub);
con.setReadContexts(context);
con.setQueryLanguage(SERQL);
con.prepareQuery(SPARQL, queryString, null);
}
use of org.eclipse.rdf4j.query.QueryLanguage in project rdf4j by eclipse.
the class NotifyingTest method testUpdate.
@Test
public void testUpdate() throws Exception {
final Update updateStub = new UpdateStub();
final RepositoryConnection stub = new RepositoryConnectionStub() {
public Update prepareUpdate(QueryLanguage ql, String query, String baseURI) throws MalformedQueryException, RepositoryException {
return updateStub;
}
};
Repository repo = stub.getRepository();
NotifyingRepositoryConnection con = new NotifyingRepositoryConnectionWrapper(repo, stub);
con.addRepositoryConnectionListener(new RepositoryConnectionListenerAdapter() {
public void execute(RepositoryConnection conn, QueryLanguage ql, String update, String baseURI, Update operation) {
assertEquals(stub, conn);
assertEquals(SPARQL, ql);
assertEquals("DELETE DATA { <> <> <> }", update);
assertEquals("http://example.com/", baseURI);
assertEquals(updateStub, operation);
}
});
Update update = con.prepareUpdate(SPARQL, "DELETE DATA { <> <> <> }", "http://example.com/");
update.execute();
}
Aggregations