use of org.openrdf.repository.sail.SailRepositoryConnection in project incubator-rya by apache.
the class RyaMongoDbSailFactoryTest method testCreateMongoDbSail.
@Test
public void testCreateMongoDbSail() throws Exception {
Sail sail = null;
SailRepository repo = null;
SailRepositoryConnection conn = null;
try {
sail = RyaSailFactory.getInstance(conf);
repo = new SailRepository(sail);
conn = repo.getConnection();
} finally {
if (conn != null) {
conn.close();
}
if (repo != null) {
repo.shutDown();
}
if (sail != null) {
sail.shutDown();
}
}
}
use of org.openrdf.repository.sail.SailRepositoryConnection in project incubator-rya by apache.
the class RyaMongoDbSailFactoryTest method testAddStatement.
@Test
public void testAddStatement() throws Exception {
Sail sail = null;
SailRepository repo = null;
SailRepositoryConnection conn = null;
try {
sail = RyaSailFactory.getInstance(conf);
repo = new SailRepository(sail);
conn = repo.getConnection();
final ValueFactory vf = conn.getValueFactory();
final Statement s = vf.createStatement(vf.createURI("u:a"), vf.createURI("u:b"), vf.createURI("u:c"));
assertFalse(conn.hasStatement(s, false));
conn.add(s);
Assert.assertTrue(conn.hasStatement(s, false));
} finally {
if (conn != null) {
conn.close();
}
if (repo != null) {
repo.shutDown();
}
if (sail != null) {
sail.shutDown();
}
}
}
use of org.openrdf.repository.sail.SailRepositoryConnection in project incubator-rya by apache.
the class RyaMongoDbSailFactoryTest method testReuseSail.
@Test
public void testReuseSail() throws Exception {
Sail sail = null;
SailRepository repo = null;
SailRepositoryConnection conn = null;
try {
sail = RyaSailFactory.getInstance(conf);
repo = new SailRepository(sail);
conn = repo.getConnection();
final ValueFactory vf = conn.getValueFactory();
final Statement s = vf.createStatement(vf.createURI("u:a"), vf.createURI("u:b"), vf.createURI("u:c"));
assertFalse(conn.hasStatement(s, false));
conn.add(s);
Assert.assertTrue(conn.hasStatement(s, false));
conn.remove(s);
Assert.assertFalse(conn.hasStatement(s, false));
} finally {
if (conn != null) {
conn.close();
}
if (repo != null) {
repo.shutDown();
}
if (sail != null) {
sail.shutDown();
}
}
// Reuse Sail after shutdown
try {
sail = RyaSailFactory.getInstance(conf);
repo = new SailRepository(sail);
conn = repo.getConnection();
final ValueFactory vf = conn.getValueFactory();
final Statement s = vf.createStatement(vf.createURI("u:a"), vf.createURI("u:b"), vf.createURI("u:c"));
assertFalse(conn.hasStatement(s, false));
conn.add(s);
Assert.assertTrue(conn.hasStatement(s, false));
} finally {
if (conn != null) {
conn.close();
}
if (repo != null) {
repo.shutDown();
}
if (sail != null) {
sail.shutDown();
}
}
}
Aggregations