log.warn("Testing logging at WARN level");
}
@Test
public void testDirectRepositoryAccess() throws Exception {
Model model = getModelFactory().createModel();
model.open();
// fetch the Repository, a Connection and a ValueFactory
Repository repository = (Repository) model
.getUnderlyingModelImplementation();
RepositoryConnection connection = repository.getConnection();
ValueFactory factory = repository.getValueFactory();
// add a statement
model.addStatement(subject, predicate, object);
// convert the statement parts to OpenRDF data types
Resource openRdfSubject = ConversionUtil.toOpenRDF(subject, factory);
org.openrdf.model.URI openRdfPredicate = ConversionUtil.toOpenRDF(
predicate, factory);
Value openRdfObject = ConversionUtil.toOpenRDF(object, factory);
org.openrdf.model.URI context = RepositoryModel.DEFAULT_OPENRDF_CONTEXT;
// make sure this statement is contained in this model
assertTrue(connection.hasStatement(openRdfSubject, openRdfPredicate,
openRdfObject, false, context));
// make sure this statement can also be found through the Model API
ClosableIterator<? extends Statement> sit = model.findStatements(
subject, predicate, object);
assertNotNull(sit);
assertTrue(sit.hasNext());
Statement s2 = sit.next();
URI s2s = (URI) s2.getSubject();
URI s2p = s2.getPredicate();
URI s2o = (URI) s2.getObject();
assertEquals(subject, s2s);
assertEquals(predicate, s2p);
assertEquals(object, s2o);
// make sure that this statement is only returned once
assertFalse(sit.hasNext());
// clean-up
sit.close();
connection.close();
model.close();
}