// create a Sail stack
Sail sail = new MemoryStore();
sail = new ForwardChainingRDFSPlusInverseInferencer(sail);
// create a Repository
Repository repository = new SailRepository(sail);
try {
repository.initialize();
} catch (RepositoryException e) {
throw new RuntimeException(e);
}
org.openrdf.model.URI a = new org.openrdf.model.impl.URIImpl(
"urn:test:a");
org.openrdf.model.URI b = new org.openrdf.model.impl.URIImpl(
"urn:test:b");
org.openrdf.model.URI c = new org.openrdf.model.impl.URIImpl(
"urn:test:c");
org.openrdf.model.URI d = new org.openrdf.model.impl.URIImpl(
"urn:test:d");
org.openrdf.model.URI nrlInverse = new org.openrdf.model.impl.URIImpl(
"http://www.semanticdesktop.org/ontologies/2007/08/15/nrl#inverseProperty");
repository.getConnection().add(a, b, c, new Resource[0]);
Assert.assertTrue("added [a] [b] [c]", repository.getConnection()
.hasStatement(a, b, c, true, new Resource[0]));
Assert.assertFalse("expect not [c] [d] [a]", repository.getConnection()
.hasStatement(c, d, a, true, new Resource[0]));
// add [b] hasInverse [d]
repository.getConnection().add(b, nrlInverse, d, new Resource[0]);
Assert.assertTrue("added [b] nrlInverse [d]", repository
.getConnection().hasStatement(b, nrlInverse, d, true,
new Resource[0]));
Assert.assertTrue("expect [c] [d] [a]", repository.getConnection()
.hasStatement(c, d, a, true, new Resource[0]));
}