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();
}
}
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());
}
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());
}
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);
}
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());
}
Aggregations