diff --git a/webapp/test/edu/cornell/mannlib/vitro/webapp/reasoner/SimpleReasonerInversePropertyTest.java b/webapp/test/edu/cornell/mannlib/vitro/webapp/reasoner/SimpleReasonerInversePropertyTest.java index de3b0ff0b..e0f81bb74 100644 --- a/webapp/test/edu/cornell/mannlib/vitro/webapp/reasoner/SimpleReasonerInversePropertyTest.java +++ b/webapp/test/edu/cornell/mannlib/vitro/webapp/reasoner/SimpleReasonerInversePropertyTest.java @@ -31,6 +31,16 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { setLoggerLevel(ABoxRecomputer.class, Level.OFF); } + @Test + public void addABoxAssertion1Test(){ + addABoxAssertion1(true); + } + + @Test + public void addABoxAssertion1NoSameAsTest(){ + addABoxAssertion1(false); + } + /* * basic scenarios around adding abox data * @@ -40,8 +50,7 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { * Add a statement c Q d and verify that d Q c * is inferred. */ - @Test - public void addABoxAssertion1() { + public void addABoxAssertion1(boolean sameAs ) { // set up the tbox OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); @@ -57,7 +66,11 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { // create an abox and register the SimpleReasoner listener with it OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); - aBox.register(new SimpleReasoner(tBox, aBox, inf)); + + SimpleReasoner sr = new SimpleReasoner(tBox,aBox,inf); + sr.setSameAsEnabled( sameAs ); + + aBox.register( sr ); // add assertions to the abox and verify inferences Resource a = aBox.createResource("http://test.vivo/a"); @@ -68,15 +81,24 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { aBox.add(a,P,b); Assert.assertTrue(inf.contains(b,Q,a)); aBox.add(c,Q,d); - Assert.assertTrue(inf.contains(d,P,c)); + Assert.assertTrue(inf.contains(d,P,c)); } - + + @Test + public void addABoxAssertion2Test() { + addABoxAssertion2(true); + } + + @Test + public void addABoxAssertion2NoSameAsTest() { + addABoxAssertion2(false); + } + /* * don't infer statements already in the abox * (never infer because it's in the abox already) */ - @Test - public void addABoxAssertion2() { + public void addABoxAssertion2(boolean sameAs ) { // set up the tbox OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); @@ -107,12 +129,20 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { Assert.assertFalse(inf.contains(b,Q,a)); } + @Test + public void addABoxAssertion3Test() { + addABoxAssertion3(true); + } + @Test + public void addABoxAssertion3NoSameAsTest(){ + addABoxAssertion3(false); + } + /* * don't infer statements already in the abox * (remove the inference when it is asserted) */ - @Test - public void addABoxAssertion3() { + public void addABoxAssertion3(boolean sameAs) { // set up the tbox OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); @@ -127,7 +157,11 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { // create abox and register SimpleReasoner OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); - aBox.register(new SimpleReasoner(tBox, aBox, inf)); + + SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf); + sr.setSameAsEnabled( sameAs ); + + aBox.register( sr ); // add statements to the abox and verify inferences Resource a = aBox.createResource("http://test.vivo/a"); @@ -138,13 +172,21 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { aBox.add(b,Q,a); // this should cause the inference to be removed Assert.assertFalse(inf.contains(b,Q,a)); } - + + @Test + public void addABoxAssertion4Test() { + addABoxAssertion4(true); + } + @Test + public void addABoxAssertion4NoSameAsTest() { + addABoxAssertion4(false); + } + /* * adding abox data where the property has an inverse and * and equivalent property. */ - @Test - public void addABoxAssertion4() { + public void addABoxAssertion4( boolean sameAs ) { // set up the tbox OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); @@ -163,7 +205,10 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { // create an ABox and register the SimpleReasoner with it OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); - aBox.register(new SimpleReasoner(tBox, aBox, inf)); + + SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf); + sr.setSameAsEnabled( sameAs ); + aBox.register( sr ); // add abox statements and verify inferences Resource a = aBox.createResource("http://test.vivo/a"); @@ -179,13 +224,22 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { Assert.assertTrue(inf.contains(d,R,c)); } + @Test + public void removedABoxAssertion1Test(){ + removedABoxAssertion1(true); + } + + @Test + public void removedABoxAssertion1NoSameAsTest(){ + removedABoxAssertion1(false); + } + /* * basic scenarios around removing abox data * don't remove an inference if it's still * entailed by something else in the abox. */ - @Test - public void removedABoxAssertion1() { + public void removedABoxAssertion1(boolean sameAs) { // set up the tbox OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); @@ -203,7 +257,9 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { // create an ABox and register the SimpleReasoner with it OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); - aBox.register(new SimpleReasoner(tBox, aBox, inf)); + SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf); + sr.setSameAsEnabled( sameAs ); + aBox.register( sr ); // add statements to the abox and verify inferences Resource a = aBox.createResource("http://test.vivo/a"); @@ -226,12 +282,21 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { Assert.assertTrue(inf.contains(d,P,c)); // still inferred from c T d } + @Test + public void removedABoxAssertion2Test(){ + removedABoxAssertion2(true); + } + + @Test + public void removedABoxAssertion2NoSameAsTest(){ + removedABoxAssertion2(false); + } + /* * removing abox data with equivalent and inverse properties * don't remove inference if it's still inferred. */ - @Test - public void removedABoxAssertion2() { + public void removedABoxAssertion2(boolean sameAs) { // set up the tbox OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); @@ -253,7 +318,9 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { // create an abox and register the SimpleReasoner listener with it OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); - aBox.register(new SimpleReasoner(tBox, aBox, inf)); + SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf); + sr.setSameAsEnabled( sameAs ); + aBox.register( sr ); // add abox data and verify inferences Resource a = aBox.createResource("http://test.vivo/a"); @@ -270,11 +337,20 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { Assert.assertTrue(inf.contains(b,Q,a)); } + @Test + public void removedABoxAssertion3Test(){ + removedABoxAssertion3(true); + } + + @Test + public void removedABoxAssertion3NoSameAsTest(){ + removedABoxAssertion3(false); + } + /* * removing abox data with equivalent and inverse properties */ - @Test - public void removedABoxAssertion3() { + public void removedABoxAssertion3(boolean sameAs) { //set up the tbox OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); @@ -297,7 +373,9 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { aBox.add(a,P,b); // register the SimpleReasoner - aBox.register(new SimpleReasoner(tBox, aBox, inf)); + SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf); + sr.setSameAsEnabled( sameAs ); + aBox.register( sr ); // add abox statements and verify inferences aBox.add(b,Q,a); @@ -309,11 +387,20 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { // when it's removed from the abox } + @Test + public void addTBoxInverseAssertion1Test() throws InterruptedException { + addTBoxInverseAssertion1(true); + } + + @Test + public void addTBoxInverseAssertion1NoSameAsTest() throws InterruptedException { + addTBoxInverseAssertion1(false); + } + /* * adding an inverseOf assertion to the tbox */ - @Test - public void addTBoxInverseAssertion1() throws InterruptedException { + public void addTBoxInverseAssertion1(boolean sameAs) throws InterruptedException { // Set up the TBox. OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); @@ -330,7 +417,8 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { // set up SimpleReasoner and register it with abox. register // SimpleReasonerTBoxListener with the tbox. - SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf); + SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf ); + simpleReasoner.setSameAsEnabled( sameAs ); aBox.register(simpleReasoner); SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner); tBox.register(simpleReasonerTBoxListener); @@ -361,12 +449,21 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { simpleReasonerTBoxListener.setStopRequested(); } - + + @Test + public void removeTBoxInverseAssertion1Test() throws InterruptedException { + removeTBoxInverseAssertion1(true); + } + + @Test + public void removeTBoxInverseAssertion1NoSameAsTest() throws InterruptedException { + removeTBoxInverseAssertion1(false); + } + /* * removing an inverseOf assertion from the tbox */ - @Test - public void removeTBoxInverseAssertion1() throws InterruptedException { + public void removeTBoxInverseAssertion1(boolean sameAs) throws InterruptedException { // set up the tbox. OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); @@ -385,7 +482,8 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { // set up SimpleReasoner and SimpleReasonerTBox listener, // register them with abox and tbox - SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf); + SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf); + simpleReasoner.setSameAsEnabled( sameAs ); aBox.register(simpleReasoner); SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner); tBox.register(simpleReasonerTBoxListener); @@ -411,11 +509,20 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { simpleReasonerTBoxListener.setStopRequested(); } + @Test + public void recomputeABox1Test() throws InterruptedException { + recomputeABox1(true); + } + + @Test + public void recomputeABox1NoSameAsTest() throws InterruptedException { + recomputeABox1(false); + } + /* * Basic scenario around recomputing the ABox inferences */ - @Test - public void recomputeABox1() throws InterruptedException { + public void recomputeABox1(boolean sameAs) throws InterruptedException { // set up tbox OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); @@ -437,6 +544,7 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); Model inf = ModelFactory.createDefaultModel(); SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf); + simpleReasoner.setSameAsEnabled( sameAs ); aBox.register(simpleReasoner); // abox statements @@ -487,4 +595,4 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass { ontModel.writeAll(System.out,"N3",null); } -} \ No newline at end of file +} diff --git a/webapp/test/edu/cornell/mannlib/vitro/webapp/reasoner/SimpleReasonerTest.java b/webapp/test/edu/cornell/mannlib/vitro/webapp/reasoner/SimpleReasonerTest.java index 0c6427377..7b17d1303 100644 --- a/webapp/test/edu/cornell/mannlib/vitro/webapp/reasoner/SimpleReasonerTest.java +++ b/webapp/test/edu/cornell/mannlib/vitro/webapp/reasoner/SimpleReasonerTest.java @@ -2,10 +2,10 @@ package edu.cornell.mannlib.vitro.webapp.reasoner; - import org.apache.log4j.Level; import org.junit.Assert; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.mindswap.pellet.jena.PelletReasonerFactory; @@ -38,12 +38,20 @@ public class SimpleReasonerTest extends AbstractTestClass { setLoggerLevel(SimpleReasonerTBoxListener.class, Level.OFF); } + @Test + public void addABoxTypeAssertion1Test(){ + addABoxTypeAssertion1(true); + } + + @Test + public void addABoxTypeAssertion1NoSameAsTest(){ + addABoxTypeAssertion1(false); + } /* * Test that when an individual is asserted to be of a type, * its asserted type is not added to the inference graph */ - @Test - public void addABoxTypeAssertion1(){ + public void addABoxTypeAssertion1( boolean sameAsEnabled ){ // Create a Tbox with a simple class hierarchy. B is a subclass of A. // Pellet will compute TBox inferences @@ -62,7 +70,9 @@ public class SimpleReasonerTest extends AbstractTestClass { // create an ABox and register the SimpleReasoner listener with it OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); - aBox.register(new SimpleReasoner(tBox, aBox, inf)); + SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf); + simpleReasoner.setSameAsEnabled( sameAsEnabled ); + aBox.register(simpleReasoner); // Individual x Resource ind_x = aBox.createResource("http://test.vivo/x"); @@ -75,13 +85,20 @@ public class SimpleReasonerTest extends AbstractTestClass { Assert.assertFalse(inf.contains(xisb)); } + @Test + public void addABoxTypeAssertion2Test(){ + addABoxTypeAssertion2(true); + } + @Test + public void addABoxTypeAssertion2NoSameAs(){ + addABoxTypeAssertion2(false); + } /* * Test that when an individual is asserted have a type, * that inferences are materialized that it has the types * of its superclasses */ - @Test - public void addABoxTypeAssertion2(){ + public void addABoxTypeAssertion2(boolean enableSameAs){ // Create a Tbox with a simple class hierarchy. D and E are subclasses // of C. B and C are subclasses of A. Pellet will compute TBox inferences. @@ -113,7 +130,9 @@ public class SimpleReasonerTest extends AbstractTestClass { // create an Abox and register the SimpleReasoner listener with it OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); - aBox.register(new SimpleReasoner(tBox, aBox, inf)); + SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf); + sr.setSameAsEnabled( enableSameAs ); + aBox.register( sr ); // add a statement to the ABox that individual x is of type E. Resource ind_x = aBox.createResource("http://test.vivo/x"); @@ -128,11 +147,18 @@ public class SimpleReasonerTest extends AbstractTestClass { Assert.assertTrue(inf.contains(xisa)); } + @Test + public void addABoxTypeAssertion3Test() throws InterruptedException{ + addABoxTypeAssertion3(true); + } + @Test + public void addABoxTypeAssertion3NoSameAs() throws InterruptedException{ + addABoxTypeAssertion3(false); + } /* * Test inference based on class equivalence */ - @Test - public void addABoxTypeAssertion3() throws InterruptedException { + public void addABoxTypeAssertion3(boolean enableSameAs) throws InterruptedException { // Create TBox, ABox and Inference models and register // the ABox reasoner listeners with the ABox and TBox @@ -142,7 +168,9 @@ public class SimpleReasonerTest extends AbstractTestClass { OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); Model inf = ModelFactory.createDefaultModel(); - SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf); + SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf); + sr.setSameAsEnabled( enableSameAs ); + SimpleReasoner simpleReasoner = sr ; aBox.register(simpleReasoner); SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner); tBox.register(simpleReasonerTBoxListener); @@ -182,11 +210,18 @@ public class SimpleReasonerTest extends AbstractTestClass { simpleReasonerTBoxListener.setStopRequested();; } + @Test + public void addABoxTypeAssertion4Test()throws InterruptedException{ + addABoxTypeAssertion4(true); + } + @Test + public void addABoxTypeAssertion4NoSameAs()throws InterruptedException{ + addABoxTypeAssertion4(false); + } /* * Test inference based on class equivalence */ - @Test - public void addABoxTypeAssertion4() throws InterruptedException { + public void addABoxTypeAssertion4(boolean enableSameAs) throws InterruptedException { // Create TBox, ABox and Inference models and register // the ABox reasoner listeners with the ABox and TBox @@ -196,7 +231,9 @@ public class SimpleReasonerTest extends AbstractTestClass { OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); Model inf = ModelFactory.createDefaultModel(); - SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf); + SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf); + sr.setSameAsEnabled( enableSameAs ); + SimpleReasoner simpleReasoner = sr ; aBox.register(simpleReasoner); SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner); tBox.register(simpleReasonerTBoxListener); @@ -228,11 +265,18 @@ public class SimpleReasonerTest extends AbstractTestClass { } + @Test + public void addABoxTypeAssertion5Test()throws InterruptedException{ + addABoxTypeAssertion5(true); + } + @Test + public void addABoxTypeAssertion5NoSameAs()throws InterruptedException{ + addABoxTypeAssertion5(false); + } /* * Test inference based on class equivalence */ - @Test - public void addABoxTypeAssertion5() throws InterruptedException { + public void addABoxTypeAssertion5(boolean enableSameAs) throws InterruptedException { // Create TBox, ABox and Inference models and register // the ABox reasoner listeners with the ABox and TBox @@ -242,7 +286,9 @@ public class SimpleReasonerTest extends AbstractTestClass { OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); Model inf = ModelFactory.createDefaultModel(); - SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf); + SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf); + sr.setSameAsEnabled( enableSameAs ); + SimpleReasoner simpleReasoner = sr ; aBox.register(simpleReasoner); SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner); tBox.register(simpleReasonerTBoxListener); @@ -279,6 +325,14 @@ public class SimpleReasonerTest extends AbstractTestClass { simpleReasonerTBoxListener.setStopRequested(); } + @Test + public void removeABoxTypeAssertion1Test()throws InterruptedException{ + removeABoxTypeAssertion1(true); + } + @Test + public void removeABoxTypeAssertion1NoSameAs()throws InterruptedException{ + removeABoxTypeAssertion1(false); + } /* * Test that when it is retracted that an individual is of a type, * that the inferences that it is of the type of all superclasses @@ -287,8 +341,7 @@ public class SimpleReasonerTest extends AbstractTestClass { * TBox, ABox and inference graph minus the retracted type statement) * should not be retracted. */ - @Test - public void removeABoxTypeAssertion1(){ + public void removeABoxTypeAssertion1(boolean enableSameAs){ // Create a Tbox with a simple class hierarchy. C is a subclass of B // and B is a subclass of A. Pellet will compute TBox inferences. @@ -312,7 +365,9 @@ public class SimpleReasonerTest extends AbstractTestClass { // create an Abox and register the SimpleReasoner listener with it OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); - aBox.register(new SimpleReasoner(tBox, aBox, inf)); + SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf); + sr.setSameAsEnabled( enableSameAs ); + aBox.register( sr ); // add a statement to the ABox that individual x is of type C. Resource ind_x = aBox.createResource("http://test.vivo/x"); @@ -335,6 +390,14 @@ public class SimpleReasonerTest extends AbstractTestClass { } + @Test + public void addTBoxSubClassAssertion1Test()throws InterruptedException{ + addTBoxSubClassAssertion1(true); + } + @Test + public void addTBoxSubClassAssertion1NoSameAs()throws InterruptedException{ + addTBoxSubClassAssertion1(false); + } /* * Test the addition of a subClassOf statement to * the TBox. The instance data that is the basis @@ -351,8 +414,7 @@ public class SimpleReasonerTest extends AbstractTestClass { * rdfs:subClassOf statement, this test serves * as a test of equivalentClass statements also. */ - @Test - public void addTBoxSubClassAssertion1() throws InterruptedException { + public void addTBoxSubClassAssertion1(boolean enableSameAs) throws InterruptedException { // Create TBox, ABox and Inference models and register // the ABox reasoner listeners with the ABox and TBox @@ -362,7 +424,9 @@ public class SimpleReasonerTest extends AbstractTestClass { OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); Model inf = ModelFactory.createDefaultModel(); - SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf); + SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf); + sr.setSameAsEnabled( enableSameAs ); + SimpleReasoner simpleReasoner = sr ; aBox.register(simpleReasoner); SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner); tBox.register(simpleReasonerTBoxListener); @@ -408,6 +472,14 @@ public class SimpleReasonerTest extends AbstractTestClass { simpleReasonerTBoxListener.setStopRequested(); } + @Test + public void addTBoxSubClassAssertion2Test()throws InterruptedException{ + addTBoxSubClassAssertion2(true); + } + @Test + public void addTBoxSubClassAssertion2NoSameAs()throws InterruptedException{ + addTBoxSubClassAssertion2(false); + } /* * Test the addition of a subClassOf statement to * the TBox. The instance data that is the basis @@ -424,8 +496,7 @@ public class SimpleReasonerTest extends AbstractTestClass { * as some test of equivalentClass statements also. * */ - @Test - public void addTBoxSubClassAssertion2() throws InterruptedException { + public void addTBoxSubClassAssertion2(boolean enableSameAs) throws InterruptedException { // Create TBox, ABox and Inference models and register // the ABox reasoner listeners with the ABox and TBox @@ -435,7 +506,9 @@ public class SimpleReasonerTest extends AbstractTestClass { OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); Model inf = ModelFactory.createDefaultModel(); - SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf); + SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf); + sr.setSameAsEnabled( enableSameAs ); + SimpleReasoner simpleReasoner = sr ; aBox.register(simpleReasoner); SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner); tBox.register(simpleReasonerTBoxListener); @@ -480,6 +553,14 @@ public class SimpleReasonerTest extends AbstractTestClass { } + @Test + public void removeTBoxSubClassAssertion1Test()throws InterruptedException{ + removeTBoxSubClassAssertion1(true); + } + @Test + public void removeTBoxSubClassAssertion1NoSameAs()throws InterruptedException{ + removeTBoxSubClassAssertion1(false); + } /* * Test the removal of a subClassOf statement from * the TBox. The instance data that is the basis @@ -487,8 +568,7 @@ public class SimpleReasonerTest extends AbstractTestClass { * inference graph. * */ - @Test - public void removeTBoxSubClassAssertion1() throws InterruptedException { + public void removeTBoxSubClassAssertion1(boolean enableSameAs) throws InterruptedException { // Create TBox, ABox and Inference models and register // the ABox reasoner listeners with the ABox and TBox // Pellet will compute TBox inferences @@ -497,7 +577,9 @@ public class SimpleReasonerTest extends AbstractTestClass { OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); Model inf = ModelFactory.createDefaultModel(); - SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf); + SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf); + sr.setSameAsEnabled( enableSameAs ); + SimpleReasoner simpleReasoner = sr ; aBox.register(simpleReasoner); SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner); tBox.register(simpleReasonerTBoxListener); @@ -582,6 +664,17 @@ public class SimpleReasonerTest extends AbstractTestClass { simpleReasonerTBoxListener.setStopRequested(); } + @Ignore(" needs PelletListener infrastructure which is not in this suite.") + @Test + public void bcdTest()throws InterruptedException{ + bcd(true); + } + + @Ignore(" needs PelletListener infrastructure which is not in this suite.") + @Test + public void bcdNoSameAsTest()throws InterruptedException{ + bcd(false); + } /* * Test the removal of a subClassOf statement from * the TBox. The instance data that is the basis @@ -589,12 +682,12 @@ public class SimpleReasonerTest extends AbstractTestClass { * inference graph. * */ - //@Test - this test would need PelletListener infrastructure, which we're not + // this test would need PelletListener infrastructure, which we're not // testing in this suite. The reason it doesn't work as it is because // the SimpleReasonerTBoxListener is not listening to the tBox inference // model as Pellet is updating it. I could simulate it by adding to the // tBox assertions what we can count on Pellet to infer. - public void bcdTest() throws InterruptedException { + public void bcd(boolean enableSameAs) throws InterruptedException { // Create TBox, ABox and Inference models and register // the ABox reasoner listeners with the ABox and TBox // Pellet will compute TBox inferences @@ -604,6 +697,7 @@ public class SimpleReasonerTest extends AbstractTestClass { Model inf = ModelFactory.createDefaultModel(); SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf); + simpleReasoner.setSameAsEnabled( enableSameAs ); aBox.register(simpleReasoner); SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner); tBox.register(simpleReasonerTBoxListener); @@ -654,12 +748,19 @@ public class SimpleReasonerTest extends AbstractTestClass { simpleReasonerTBoxListener.setStopRequested(); } + @Test + public void mstTest1Test()throws InterruptedException{ + mstTest1(true); + } + @Test + public void mstTest1NoSameAs()throws InterruptedException{ + mstTest1(false); + } /* * Test computation of mostSpecificType annotations in response * to an added/removed ABox type assertion. */ - @Test - public void mstTest1() throws InterruptedException { + public void mstTest1(boolean enableSameAs) throws InterruptedException { // Create TBox, ABox and Inference models and register // the ABox reasoner listeners with the ABox and TBox // Pellet will compute TBox inferences @@ -668,7 +769,9 @@ public class SimpleReasonerTest extends AbstractTestClass { OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); Model inf = ModelFactory.createDefaultModel(); - SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf); + SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf); + sr.setSameAsEnabled( enableSameAs ); + SimpleReasoner simpleReasoner = sr ; aBox.register(simpleReasoner); SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner); tBox.register(simpleReasonerTBoxListener); @@ -732,12 +835,19 @@ public class SimpleReasonerTest extends AbstractTestClass { } + @Test + public void mstTest2Test()throws InterruptedException{ + mstTest2(true); + } + @Test + public void mstTest2NoSameAs()throws InterruptedException{ + mstTest2(false); + } /* * Test computation of mostSpecificType annotations in response * to an added ABox type assertion. */ - @Test - public void mstTest2() throws InterruptedException { + public void mstTest2(boolean enableSameAs) throws InterruptedException { // Create TBox, ABox and Inference models and register // the ABox reasoner listeners with the ABox and TBox // Pellet will compute TBox inferences @@ -746,7 +856,9 @@ public class SimpleReasonerTest extends AbstractTestClass { OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); Model inf = ModelFactory.createDefaultModel(); - SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf); + SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf); + sr.setSameAsEnabled( enableSameAs ); + SimpleReasoner simpleReasoner = sr ; aBox.register(simpleReasoner); SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner); tBox.register(simpleReasonerTBoxListener); @@ -785,13 +897,20 @@ public class SimpleReasonerTest extends AbstractTestClass { simpleReasonerTBoxListener.setStopRequested(); } - + + @Test + public void mstTest3Test()throws InterruptedException{ + mstTest3(true); + } + @Test + public void mstTest3NoSameAs()throws InterruptedException{ + mstTest3(false); + } /* * Test computation of mostSpecificType annotations in response * to an added/removed TBox assertions. */ - @Test - public void mstTest3() throws InterruptedException { + public void mstTest3(boolean enableSameAs) throws InterruptedException { // Create TBox, ABox and Inference models and register // the ABox reasoner listeners with the ABox and TBox // Pellet will compute TBox inferences @@ -800,7 +919,9 @@ public class SimpleReasonerTest extends AbstractTestClass { OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); Model inf = ModelFactory.createDefaultModel(); - SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf); + SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf); + sr.setSameAsEnabled( enableSameAs ); + SimpleReasoner simpleReasoner = sr ; aBox.register(simpleReasoner); SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner); tBox.register(simpleReasonerTBoxListener); @@ -906,4 +1027,4 @@ public class SimpleReasonerTest extends AbstractTestClass { ontModel.writeAll(System.out,"N3",null); } -} \ No newline at end of file +}