Search in sources :

Example 26 with Repository

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

the class LocalRepositoryManagerTest method testRestartManagerWithoutTransaction.

@Test
public void testRestartManagerWithoutTransaction() 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.add(conn.getValueFactory().createIRI("urn:sesame:test:subject"), RDF.TYPE, OWL.ONTOLOGY);
        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 27 with Repository

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

the class LocalRepositoryManagerTest method testGetRepository.

/**
 * Test method for
 * {@link org.eclipse.rdf4j.repository.manager.LocalRepositoryManager#getRepository(java.lang.String)} .
 *
 * @throws RepositoryException
 *         if a problem occurs accessing the repository
 * @throws RepositoryConfigException
 *         if a problem occurs accessing the repository
 */
@Test
public void testGetRepository() throws RepositoryConfigException, RepositoryException {
    Repository rep = manager.getRepository(TEST_REPO);
    assertNotNull("Expected repository to exist.", rep);
    assertTrue("Expected repository to be initialized.", rep.isInitialized());
    rep.shutDown();
    rep = manager.getRepository(TEST_REPO);
    assertNotNull("Expected repository to exist.", rep);
    assertTrue("Expected repository to be initialized.", rep.isInitialized());
}
Also used : 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