use of org.eclipse.rdf4j.repository.RepositoryConnection in project rdf4j by eclipse.
the class ContextAwareConnectionTest method testReadContexts.
@Test
public void testReadContexts() throws Exception {
RepositoryConnection stub = new RepositoryConnectionStub();
Repository repo = stub.getRepository();
ContextAwareConnection a = new ContextAwareConnection(repo, stub);
ContextAwareConnection b = new ContextAwareConnection(repo, a);
b.setReadContexts(context);
assertEquals(context, b.getReadContexts()[0]);
assertEquals(context, a.getReadContexts()[0]);
}
use of org.eclipse.rdf4j.repository.RepositoryConnection in project rdf4j by eclipse.
the class ContextAwareConnectionTest method testRemoveContexts.
@Test
public void testRemoveContexts() throws Exception {
RepositoryConnection stub = new RepositoryConnectionStub();
Repository repo = stub.getRepository();
ContextAwareConnection a = new ContextAwareConnection(repo, stub);
ContextAwareConnection b = new ContextAwareConnection(repo, a);
b.setRemoveContexts(context);
assertEquals(context, b.getRemoveContexts()[0]);
assertEquals(context, a.getRemoveContexts()[0]);
}
use of org.eclipse.rdf4j.repository.RepositoryConnection in project rdf4j by eclipse.
the class ContextAwareConnectionTest method testArchiveContexts.
@Test
public void testArchiveContexts() throws Exception {
RepositoryConnection stub = new RepositoryConnectionStub();
Repository repo = stub.getRepository();
ContextAwareConnection a = new ContextAwareConnection(repo, stub);
ContextAwareConnection b = new ContextAwareConnection(repo, a);
b.setArchiveContexts(context);
assertEquals(context, b.getArchiveContexts()[0]);
assertEquals(context, a.getArchiveContexts()[0]);
}
use of org.eclipse.rdf4j.repository.RepositoryConnection 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.repository.RepositoryConnection in project rdf4j by eclipse.
the class InterceptingRepositoryWrapper method getConnection.
@Override
public InterceptingRepositoryConnection getConnection() throws RepositoryException {
RepositoryConnection conn = getDelegate().getConnection();
if (activated) {
boolean denied = false;
for (RepositoryInterceptor interceptor : interceptors) {
denied = interceptor.getConnection(getDelegate(), conn);
if (denied) {
break;
}
}
if (denied) {
conn = null;
}
}
if (conn == null)
return null;
InterceptingRepositoryConnection iconn = new InterceptingRepositoryConnectionWrapper(this, conn);
for (RepositoryConnectionInterceptor conInterceptor : conInterceptors) {
iconn.addRepositoryConnectionInterceptor(conInterceptor);
}
return iconn;
}
Aggregations