use of org.eclipse.rdf4j.repository.RepositoryConnection in project rdf4j by eclipse.
the class LocalRepositoryManagerTest method testRemoveFromSystemRepository.
@Test
public void testRemoveFromSystemRepository() {
RepositoryConfig config = manager.getRepositoryConfig(TEST_REPO);
manager.addRepositoryConfig(new RepositoryConfig(SystemRepository.ID, new SystemRepositoryConfig()));
manager.shutDown();
manager = new LocalRepositoryManager(datadir);
manager.initialize();
try (RepositoryConnection con = manager.getSystemRepository().getConnection()) {
Model model = new TreeModel();
config.setID("changed");
config.export(model, con.getValueFactory().createBNode());
con.begin();
con.add(model, con.getValueFactory().createBNode());
con.commit();
}
assertTrue(manager.hasRepositoryConfig("changed"));
try (RepositoryConnection con = manager.getSystemRepository().getConnection()) {
con.begin();
con.clear(RepositoryConfigUtil.getContext(con, config.getID()));
con.commit();
}
assertFalse(manager.hasRepositoryConfig(config.getID()));
}
use of org.eclipse.rdf4j.repository.RepositoryConnection 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();
}
}
use of org.eclipse.rdf4j.repository.RepositoryConnection in project rdf4j by eclipse.
the class LocalRepositoryManagerTest method testAddToSystemRepository.
@Test
public void testAddToSystemRepository() {
RepositoryConfig config = manager.getRepositoryConfig(TEST_REPO);
manager.addRepositoryConfig(new RepositoryConfig(SystemRepository.ID, new SystemRepositoryConfig()));
manager.shutDown();
manager = new LocalRepositoryManager(datadir);
manager.initialize();
try (RepositoryConnection con = manager.getSystemRepository().getConnection()) {
Model model = new TreeModel();
config.setID("changed");
config.export(model, con.getValueFactory().createBNode());
con.begin();
con.add(model, con.getValueFactory().createBNode());
con.commit();
}
assertTrue(manager.hasRepositoryConfig("changed"));
}
use of org.eclipse.rdf4j.repository.RepositoryConnection in project rdf4j by eclipse.
the class LocalRepositoryManagerTest method testModifySystemRepository.
@Test
public void testModifySystemRepository() {
RepositoryConfig config = manager.getRepositoryConfig(TEST_REPO);
manager.addRepositoryConfig(new RepositoryConfig(SystemRepository.ID, new SystemRepositoryConfig()));
manager.shutDown();
manager = new LocalRepositoryManager(datadir);
manager.initialize();
try (RepositoryConnection con = manager.getSystemRepository().getConnection()) {
Model model = new TreeModel();
config.setTitle("Changed");
config.export(model, con.getValueFactory().createBNode());
Resource ctx = RepositoryConfigUtil.getContext(con, config.getID());
con.begin();
con.clear(ctx);
con.add(model, ctx == null ? con.getValueFactory().createBNode() : ctx);
con.commit();
}
assertEquals("Changed", manager.getRepositoryConfig(TEST_REPO).getTitle());
}
use of org.eclipse.rdf4j.repository.RepositoryConnection in project nextprot-api by calipho-sib.
the class PhenotypicTTLIntegrationTest method doTupleQuery.
private TupleQueryResult doTupleQuery(String sparqlQuery) throws RepositoryException, QueryEvaluationException, MalformedQueryException {
RepositoryConnection conn = testRepo.getConnection();
TupleQuery query = (TupleQuery) conn.prepareQuery(QueryLanguage.SPARQL, sparqlQuery);
TupleQueryResult result = query.evaluate();
return result;
}
Aggregations