This commit is contained in:
stellamit 2012-06-05 20:37:35 +00:00
parent 2f9cf7d54d
commit f8137db5c8

View file

@ -308,6 +308,13 @@ public class SimpleReasonerPropertyTest extends AbstractTestClass {
// Pellet will compute TBox inferences // Pellet will compute TBox inferences
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
OntProperty P = tBox.createOntProperty("http://test.vivo/P");
P.setLabel("property P", "en-US");
OntProperty Q = tBox.createOntProperty("http://test.vivo/Q");
Q.setLabel("property Q", "en-US");
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
Model inf = ModelFactory.createDefaultModel(); Model inf = ModelFactory.createDefaultModel();
@ -316,14 +323,6 @@ public class SimpleReasonerPropertyTest extends AbstractTestClass {
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner); SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
tBox.register(simpleReasonerTBoxListener); tBox.register(simpleReasonerTBoxListener);
// set up TBox and Abox
OntProperty P = tBox.createOntProperty("http://test.vivo/P");
P.setLabel("property P", "en-US");
OntProperty Q = tBox.createOntProperty("http://test.vivo/Q");
Q.setLabel("property Q", "en-US");
// Individuals a, b, c and d // Individuals a, b, c and d
Resource a = aBox.createResource("http://test.vivo/a"); Resource a = aBox.createResource("http://test.vivo/a");
Resource b = aBox.createResource("http://test.vivo/b"); Resource b = aBox.createResource("http://test.vivo/b");
@ -340,6 +339,9 @@ public class SimpleReasonerPropertyTest extends AbstractTestClass {
Q.addInverseOf(P); Q.addInverseOf(P);
tBox.rebind();
tBox.prepare();
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) { while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
Thread.sleep(delay); Thread.sleep(delay);
} }
@ -355,7 +357,7 @@ public class SimpleReasonerPropertyTest extends AbstractTestClass {
* Basic scenario around removing an inverseOf assertion to the * Basic scenario around removing an inverseOf assertion to the
* TBox * TBox
*/ */
//@Test @Test
public void removeTBoxInverseAssertion1() throws InterruptedException { public void removeTBoxInverseAssertion1() throws InterruptedException {
// Create TBox, ABox and Inference models and register // Create TBox, ABox and Inference models and register
@ -363,13 +365,6 @@ public class SimpleReasonerPropertyTest extends AbstractTestClass {
// Pellet will compute TBox inferences // Pellet will compute TBox inferences
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
Model inf = ModelFactory.createDefaultModel();
SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf);
aBox.register(simpleReasoner);
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
tBox.register(simpleReasonerTBoxListener);
// set up TBox and Abox // set up TBox and Abox
@ -381,6 +376,13 @@ public class SimpleReasonerPropertyTest extends AbstractTestClass {
Q.addInverseOf(P); Q.addInverseOf(P);
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
Model inf = ModelFactory.createDefaultModel();
SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf);
aBox.register(simpleReasoner);
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
tBox.register(simpleReasonerTBoxListener);
// Individuals a, b, c and d // Individuals a, b, c and d
Resource c = aBox.createResource("http://test.vivo/c"); Resource c = aBox.createResource("http://test.vivo/c");
Resource d = aBox.createResource("http://test.vivo/d"); Resource d = aBox.createResource("http://test.vivo/d");
@ -395,7 +397,9 @@ public class SimpleReasonerPropertyTest extends AbstractTestClass {
Q.removeInverseProperty(P); Q.removeInverseProperty(P);
Thread.sleep(delay); tBox.rebind();
tBox.prepare();
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) { while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
Thread.sleep(delay); Thread.sleep(delay);
} }
@ -409,20 +413,13 @@ public class SimpleReasonerPropertyTest extends AbstractTestClass {
/* /*
* Basic scenario around recomputing the ABox inferences * Basic scenario around recomputing the ABox inferences
*/ */
//@Test @Test
public void recomputeABox1() throws InterruptedException { public void recomputeABox1() throws InterruptedException {
// Create TBox, ABox and Inference models and register // Create TBox, ABox and Inference models and register
// the ABox reasoner listeners with the ABox and TBox // the ABox reasoner listeners with the ABox and TBox
// Pellet will compute TBox inferences // Pellet will compute TBox inferences
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
Model inf = ModelFactory.createDefaultModel();
SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf);
aBox.register(simpleReasoner);
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
tBox.register(simpleReasonerTBoxListener);
// set up TBox and Abox // set up TBox and Abox
OntProperty P = tBox.createOntProperty("http://test.vivo/propP"); OntProperty P = tBox.createOntProperty("http://test.vivo/propP");
@ -437,8 +434,13 @@ public class SimpleReasonerPropertyTest extends AbstractTestClass {
Q.setLabel("property Y", "en-US"); Q.setLabel("property Y", "en-US");
X.addInverseOf(Y); X.addInverseOf(Y);
Thread.sleep(delay*3); OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
Model inf = ModelFactory.createDefaultModel();
SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf);
aBox.register(simpleReasoner);
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
tBox.register(simpleReasonerTBoxListener);
// Individuals a, b, c and d // Individuals a, b, c and d
Resource a = aBox.createResource("http://test.vivo/a"); Resource a = aBox.createResource("http://test.vivo/a");
Resource b = aBox.createResource("http://test.vivo/b"); Resource b = aBox.createResource("http://test.vivo/b");
@ -451,8 +453,7 @@ public class SimpleReasonerPropertyTest extends AbstractTestClass {
simpleReasoner.recompute(); simpleReasoner.recompute();
Thread.sleep(delay); while (simpleReasoner.isRecomputing()) {
while (!VitroBackgroundThread.getLivingThreads().isEmpty() || simpleReasoner.isRecomputing()) {
Thread.sleep(delay); Thread.sleep(delay);
} }