use of org.eclipse.rdf4j.repository.event.base.RepositoryConnectionListenerAdapter in project rdf4j by eclipse.
the class NotifyingTest method testRemove.
@Test
public void testRemove() throws Exception {
ValueFactory vf = SimpleValueFactory.getInstance();
final IRI uri = vf.createIRI("http://example.com/");
final RepositoryConnection stub = new RepositoryConnectionStub() {
protected void removeWithoutCommit(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException {
}
};
Repository repo = stub.getRepository();
NotifyingRepositoryConnection con = new NotifyingRepositoryConnectionWrapper(repo, stub);
con.addRepositoryConnectionListener(new RepositoryConnectionListenerAdapter() {
public void remove(RepositoryConnection conn, Resource subject, IRI predicate, Value object, Resource... contexts) {
assertEquals(stub, conn);
assertEquals(uri, subject);
assertEquals(uri, predicate);
assertEquals(uri, object);
assertEquals(0, contexts.length);
}
});
con.remove(con.getValueFactory().createStatement(uri, uri, uri));
}
use of org.eclipse.rdf4j.repository.event.base.RepositoryConnectionListenerAdapter 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