Search in sources :

Example 11 with RepositoryConnection

use of org.eclipse.rdf4j.repository.RepositoryConnection in project rdf4j by eclipse.

the class ContextAwareConnectionTest method testBaseURI.

@Test
public void testBaseURI() throws Exception {
    RepositoryConnection stub = new RepositoryConnectionStub();
    Repository repo = stub.getRepository();
    ContextAwareConnection a = new ContextAwareConnection(repo, stub);
    ContextAwareConnection b = new ContextAwareConnection(repo, a);
    b.setBaseURI("http://example.com/");
    assertEquals("http://example.com/", b.getBaseURI());
    assertEquals("http://example.com/", a.getBaseURI());
}
Also used : RepositoryConnection(org.eclipse.rdf4j.repository.RepositoryConnection) Repository(org.eclipse.rdf4j.repository.Repository) Test(org.junit.Test)

Example 12 with RepositoryConnection

use of org.eclipse.rdf4j.repository.RepositoryConnection 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);
}
Also used : RepositoryConnection(org.eclipse.rdf4j.repository.RepositoryConnection) IRI(org.eclipse.rdf4j.model.IRI) Repository(org.eclipse.rdf4j.repository.Repository) Dataset(org.eclipse.rdf4j.query.Dataset) QueryLanguage(org.eclipse.rdf4j.query.QueryLanguage) Test(org.junit.Test)

Example 13 with RepositoryConnection

use of org.eclipse.rdf4j.repository.RepositoryConnection in project rdf4j by eclipse.

the class ContextAwareConnectionTest method testMaxQueryTime.

@Test
public void testMaxQueryTime() throws Exception {
    RepositoryConnection stub = new RepositoryConnectionStub();
    Repository repo = stub.getRepository();
    ContextAwareConnection a = new ContextAwareConnection(repo, stub);
    ContextAwareConnection b = new ContextAwareConnection(repo, a);
    b.setMaxQueryTime(1);
    assertEquals(1, b.getMaxQueryTime());
    assertEquals(1, a.getMaxQueryTime());
}
Also used : RepositoryConnection(org.eclipse.rdf4j.repository.RepositoryConnection) Repository(org.eclipse.rdf4j.repository.Repository) Test(org.junit.Test)

Example 14 with RepositoryConnection

use of org.eclipse.rdf4j.repository.RepositoryConnection in project rdf4j by eclipse.

the class ContextAwareConnectionTest method testAddContexts.

@Test
public void testAddContexts() throws Exception {
    RepositoryConnection stub = new RepositoryConnectionStub();
    Repository repo = stub.getRepository();
    ContextAwareConnection a = new ContextAwareConnection(repo, stub);
    ContextAwareConnection b = new ContextAwareConnection(repo, a);
    b.setAddContexts(context);
    assertEquals(context, b.getAddContexts()[0]);
    assertEquals(context, a.getAddContexts()[0]);
}
Also used : RepositoryConnection(org.eclipse.rdf4j.repository.RepositoryConnection) Repository(org.eclipse.rdf4j.repository.Repository) Test(org.junit.Test)

Example 15 with RepositoryConnection

use of org.eclipse.rdf4j.repository.RepositoryConnection in project rdf4j by eclipse.

the class ContextAwareConnectionTest method testInsertContexts.

@Test
public void testInsertContexts() throws Exception {
    RepositoryConnection stub = new RepositoryConnectionStub();
    Repository repo = stub.getRepository();
    ContextAwareConnection a = new ContextAwareConnection(repo, stub);
    ContextAwareConnection b = new ContextAwareConnection(repo, a);
    b.setInsertContext(context);
    assertEquals(context, b.getInsertContext());
    assertEquals(context, a.getInsertContext());
}
Also used : RepositoryConnection(org.eclipse.rdf4j.repository.RepositoryConnection) Repository(org.eclipse.rdf4j.repository.Repository) Test(org.junit.Test)

Aggregations

RepositoryConnection (org.eclipse.rdf4j.repository.RepositoryConnection)34 Test (org.junit.Test)21 Repository (org.eclipse.rdf4j.repository.Repository)18 IRI (org.eclipse.rdf4j.model.IRI)6 Resource (org.eclipse.rdf4j.model.Resource)6 Statement (org.eclipse.rdf4j.model.Statement)6 Model (org.eclipse.rdf4j.model.Model)5 QueryLanguage (org.eclipse.rdf4j.query.QueryLanguage)5 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)4 RepositoryConfig (org.eclipse.rdf4j.repository.config.RepositoryConfig)4 Value (org.eclipse.rdf4j.model.Value)3 TreeModel (org.eclipse.rdf4j.model.impl.TreeModel)3 Dataset (org.eclipse.rdf4j.query.Dataset)3 ProxyRepositoryConfig (org.eclipse.rdf4j.repository.sail.config.ProxyRepositoryConfig)3 SailRepositoryConfig (org.eclipse.rdf4j.repository.sail.config.SailRepositoryConfig)3 ValueFactory (org.eclipse.rdf4j.model.ValueFactory)2 SimpleValueFactory (org.eclipse.rdf4j.model.impl.SimpleValueFactory)2 Update (org.eclipse.rdf4j.query.Update)2 AbstractUpdate (org.eclipse.rdf4j.query.impl.AbstractUpdate)2 InterceptingRepositoryConnectionWrapper (org.eclipse.rdf4j.repository.event.base.InterceptingRepositoryConnectionWrapper)2