Search in sources :

Example 1 with Repository

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

the class LocalRepositoryManagerTest method testRestartManagerWithTransaction.

@Test
public void testRestartManagerWithTransaction() throws Exception {
    Repository rep = manager.getRepository(TEST_REPO);
    assertNotNull("Expected repository to exist.", rep);
    assertTrue("Expected repository to be initialized.", rep.isInitialized());
    RepositoryConnection conn = rep.getConnection();
    try {
        conn.begin();
        conn.add(conn.getValueFactory().createIRI("urn:sesame:test:subject"), RDF.TYPE, OWL.ONTOLOGY);
        conn.commit();
        assertEquals(1, conn.size());
    } finally {
        conn.close();
        rep.shutDown();
        manager.shutDown();
    }
    manager = new LocalRepositoryManager(datadir);
    manager.initialize();
    Repository rep2 = manager.getRepository(TEST_REPO);
    assertNotNull("Expected repository to exist.", rep2);
    assertTrue("Expected repository to be initialized.", rep2.isInitialized());
    RepositoryConnection conn2 = rep2.getConnection();
    try {
        assertEquals(1, conn2.size());
    } finally {
        conn2.close();
        rep2.shutDown();
        manager.shutDown();
    }
}
Also used : RepositoryConnection(org.eclipse.rdf4j.repository.RepositoryConnection) Repository(org.eclipse.rdf4j.repository.Repository) Test(org.junit.Test)

Example 2 with Repository

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

the class ContextAwareConnectionTest method testQueryLanguage.

@Test
public void testQueryLanguage() throws Exception {
    RepositoryConnection stub = new RepositoryConnectionStub();
    Repository repo = stub.getRepository();
    ContextAwareConnection a = new ContextAwareConnection(repo, stub);
    ContextAwareConnection b = new ContextAwareConnection(repo, a);
    b.setQueryLanguage(QueryLanguage.SERQL);
    assertEquals(QueryLanguage.SERQL, b.getQueryLanguage());
    assertEquals(QueryLanguage.SERQL, a.getQueryLanguage());
}
Also used : RepositoryConnection(org.eclipse.rdf4j.repository.RepositoryConnection) Repository(org.eclipse.rdf4j.repository.Repository) Test(org.junit.Test)

Example 3 with Repository

use of org.eclipse.rdf4j.repository.Repository 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 4 with Repository

use of org.eclipse.rdf4j.repository.Repository 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 5 with Repository

use of org.eclipse.rdf4j.repository.Repository 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)

Aggregations

Repository (org.eclipse.rdf4j.repository.Repository)27 Test (org.junit.Test)19 RepositoryConnection (org.eclipse.rdf4j.repository.RepositoryConnection)18 IRI (org.eclipse.rdf4j.model.IRI)5 QueryLanguage (org.eclipse.rdf4j.query.QueryLanguage)5 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)4 Dataset (org.eclipse.rdf4j.query.Dataset)3 IOException (java.io.IOException)2 Resource (org.eclipse.rdf4j.model.Resource)2 Value (org.eclipse.rdf4j.model.Value)2 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 DelegatingRepository (org.eclipse.rdf4j.repository.DelegatingRepository)2 InterceptingRepositoryConnectionWrapper (org.eclipse.rdf4j.repository.event.base.InterceptingRepositoryConnectionWrapper)2 NotifyingRepositoryConnectionWrapper (org.eclipse.rdf4j.repository.event.base.NotifyingRepositoryConnectionWrapper)2 RepositoryConnectionInterceptorAdapter (org.eclipse.rdf4j.repository.event.base.RepositoryConnectionInterceptorAdapter)2 RepositoryConnectionListenerAdapter (org.eclipse.rdf4j.repository.event.base.RepositoryConnectionListenerAdapter)2 HashMap (java.util.HashMap)1