use of org.apache.jena.ontology.OntModel in project jena by apache.
the class TestReasoners method testTransitiveSpecReuse.
/**
* The reasoner contract for bind(data) is not quite precise. It allows for
* reasoners which have state so that reusing the same reasoner on a second data
* model might lead to interference. This in fact used to happen with the transitive
* reasoner. This is a test to check the top level symptoms of this which can be
* solved just be not reusing reasoners.
* @todo this test might be better moved to OntModel tests somewhere
*/
public void testTransitiveSpecReuse() {
OntModel om1 = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_TRANS_INF);
Resource c1 = om1.createResource(PrintUtil.egNS + "Class1");
Resource c2 = om1.createResource(PrintUtil.egNS + "Class2");
Resource c3 = om1.createResource(PrintUtil.egNS + "Class3");
om1.add(c1, RDFS.subClassOf, c2);
om1.add(c2, RDFS.subClassOf, c3);
om1.prepare();
assertFalse(om1.isEmpty());
OntModel om2 = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_TRANS_INF);
StmtIterator si = om2.listStatements();
boolean ok = !si.hasNext();
si.close();
assertTrue("Transitive reasoner state leak", ok);
}
use of org.apache.jena.ontology.OntModel in project jena by apache.
the class TestInfModel method testListWithPosits.
/**
* Check interface extensions which had an earlier bug with null handling
*/
public void testListWithPosits() {
String NS = PrintUtil.egNS;
Model data = ModelFactory.createDefaultModel();
Resource c1 = data.createResource(NS + "C1");
Resource c2 = data.createResource(NS + "C2");
Resource c3 = data.createResource(NS + "C3");
data.add(c2, RDFS.subClassOf, c3);
Model premise = ModelFactory.createDefaultModel();
premise.add(c1, RDFS.subClassOf, c2);
InfModel im = ModelFactory.createInfModel(ReasonerRegistry.getRDFSReasoner(), data);
TestUtil.assertIteratorValues(this, im.listStatements(c1, RDFS.subClassOf, null, premise), new Object[] { data.createStatement(c1, RDFS.subClassOf, c2), data.createStatement(c1, RDFS.subClassOf, c3), data.createStatement(c1, RDFS.subClassOf, c1) });
OntModel om = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM_RDFS_INF, data);
TestUtil.assertIteratorValues(this, om.listStatements(c1, RDFS.subClassOf, null, premise), new Object[] { data.createStatement(c1, RDFS.subClassOf, c2), data.createStatement(c1, RDFS.subClassOf, c3), data.createStatement(c1, RDFS.subClassOf, c1) });
}
Aggregations