/** * 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 that the transitive reasoner state reuse has been fixed at source. */ public void testTransitiveBindReuse() { Reasoner r = ReasonerRegistry.getTransitiveReasoner(); InfModel om1 = ModelFactory.createInfModel(r, ModelFactory.createDefaultModel()); 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()); InfModel om2 = ModelFactory.createInfModel(r, ModelFactory.createDefaultModel()); StmtIterator si = om2.listStatements(); boolean ok = ! si.hasNext(); si.close(); assertTrue("Transitive reasoner state leak", ok); }
/** * 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 that the transitive reasoner state reuse has been fixed at source. */ public void testTransitiveBindReuse() { Reasoner r = ReasonerRegistry.getTransitiveReasoner(); InfModel om1 = ModelFactory.createInfModel(r, ModelFactory.createDefaultModel()); 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()); InfModel om2 = ModelFactory.createInfModel(r, ModelFactory.createDefaultModel()); StmtIterator si = om2.listStatements(); boolean ok = ! si.hasNext(); si.close(); assertTrue("Transitive reasoner state leak", ok); }