diff options
Diffstat (limited to 'test/uk/ac/ox/cs/pagoda/global_tests')
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/global_tests/BugTests.java (renamed from test/uk/ac/ox/cs/pagoda/global_tests/MinimumCardinalityTest.java) | 89 | ||||
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java | 6 | ||||
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaLUBM.java | 10 | ||||
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java | 26 |
4 files changed, 105 insertions, 26 deletions
diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/MinimumCardinalityTest.java b/test/uk/ac/ox/cs/pagoda/global_tests/BugTests.java index 71c20c1..19e0b2a 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/MinimumCardinalityTest.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/BugTests.java | |||
| @@ -6,6 +6,7 @@ import org.testng.Assert; | |||
| 6 | import org.testng.annotations.Test; | 6 | import org.testng.annotations.Test; |
| 7 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; | 7 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; |
| 8 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; | 8 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; |
| 9 | import uk.ac.ox.cs.pagoda.query.QueryRecord; | ||
| 9 | import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; | 10 | import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; |
| 10 | import uk.ac.ox.cs.pagoda.util.TestUtil; | 11 | import uk.ac.ox.cs.pagoda.util.TestUtil; |
| 11 | 12 | ||
| @@ -13,7 +14,7 @@ import java.io.IOException; | |||
| 13 | import java.nio.file.Files; | 14 | import java.nio.file.Files; |
| 14 | import java.nio.file.Paths; | 15 | import java.nio.file.Paths; |
| 15 | 16 | ||
| 16 | public class MinimumCardinalityTest { | 17 | public class BugTests { |
| 17 | 18 | ||
| 18 | public static final String NS = "http://example.org/test#%s"; | 19 | public static final String NS = "http://example.org/test#%s"; |
| 19 | 20 | ||
| @@ -21,8 +22,8 @@ public class MinimumCardinalityTest { | |||
| 21 | return IRI.create(String.format(NS, name)); | 22 | return IRI.create(String.format(NS, name)); |
| 22 | } | 23 | } |
| 23 | 24 | ||
| 24 | @Test(groups = {"BugTesters"}) | 25 | @Test |
| 25 | public void test() throws OWLOntologyCreationException, IOException, OWLOntologyStorageException { | 26 | public void minimumCardinalityAxiom() throws OWLOntologyCreationException, IOException, OWLOntologyStorageException { |
| 26 | 27 | ||
| 27 | /* | 28 | /* |
| 28 | * Build test ontology | 29 | * Build test ontology |
| @@ -98,4 +99,86 @@ public class MinimumCardinalityTest { | |||
| 98 | } | 99 | } |
| 99 | pagoda.dispose(); | 100 | pagoda.dispose(); |
| 100 | } | 101 | } |
| 102 | |||
| 103 | /** | ||
| 104 | * Bug: the relevant ontology is not a subset of the original one. | ||
| 105 | * | ||
| 106 | * @throws OWLOntologyCreationException | ||
| 107 | * @throws IOException | ||
| 108 | * @throws OWLOntologyStorageException | ||
| 109 | */ | ||
| 110 | @Test | ||
| 111 | public void rTest() throws OWLOntologyCreationException, IOException, OWLOntologyStorageException { | ||
| 112 | |||
| 113 | /* | ||
| 114 | * Build test ontology | ||
| 115 | * */ | ||
| 116 | |||
| 117 | OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); | ||
| 118 | OWLDataFactory factory = manager.getOWLDataFactory(); | ||
| 119 | OWLOntology ontology = manager.createOntology(); | ||
| 120 | |||
| 121 | OWLClass classA = factory.getOWLClass(getEntityIRI("A")); | ||
| 122 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(classA)); | ||
| 123 | OWLClass classB = factory.getOWLClass(getEntityIRI("B")); | ||
| 124 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(classB)); | ||
| 125 | OWLNamedIndividual a = factory.getOWLNamedIndividual(getEntityIRI("a")); | ||
| 126 | OWLNamedIndividual b = factory.getOWLNamedIndividual(getEntityIRI("b")); | ||
| 127 | OWLNamedIndividual c = factory.getOWLNamedIndividual(getEntityIRI("c")); | ||
| 128 | OWLObjectProperty roleR = factory.getOWLObjectProperty(IRI.create(String.format(NS, "R"))); | ||
| 129 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(roleR)); | ||
| 130 | OWLObjectProperty roleP = factory.getOWLObjectProperty(IRI.create(String.format(NS, "P"))); | ||
| 131 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(roleP)); | ||
| 132 | |||
| 133 | // Class assertions | ||
| 134 | manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(classA, a)); // A(a) | ||
| 135 | manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(classA, b)); // A(b) | ||
| 136 | manager.addAxiom(ontology, factory.getOWLObjectPropertyAssertionAxiom(roleP, c, a)); // P(c,a) | ||
| 137 | |||
| 138 | // Axioms | ||
| 139 | // subsetOf(A someValuesFrom(R owl:Thing)) | ||
| 140 | manager.addAxiom(ontology, | ||
| 141 | factory.getOWLSubClassOfAxiom(classA, | ||
| 142 | factory.getOWLObjectSomeValuesFrom(roleR, | ||
| 143 | factory.getOWLThing()))); | ||
| 144 | |||
| 145 | // inverseFunctional(R) | ||
| 146 | manager.addAxiom(ontology, | ||
| 147 | factory.getOWLInverseFunctionalObjectPropertyAxiom(roleR)); | ||
| 148 | |||
| 149 | // subsetOf(someValuesFrom(inverseOf(P) owl:thing) B) | ||
| 150 | manager.addAxiom(ontology, | ||
| 151 | factory.getOWLSubClassOfAxiom(factory.getOWLObjectSomeValuesFrom(roleP.getInverseProperty(), | ||
| 152 | factory.getOWLThing()), | ||
| 153 | classB)); | ||
| 154 | /* | ||
| 155 | * Save the ontology | ||
| 156 | * */ | ||
| 157 | |||
| 158 | // manager.saveOntology(ontology, Files.newOutputStream(Paths.get("/home/alessandro/Desktop/test-ontology.owl"))); | ||
| 159 | |||
| 160 | /* | ||
| 161 | * Test one query | ||
| 162 | * */ | ||
| 163 | |||
| 164 | QueryReasoner pagoda = QueryReasoner.getInstance(ontology); | ||
| 165 | pagoda.loadOntology(ontology); | ||
| 166 | if(pagoda.preprocess()) { | ||
| 167 | String queryStr = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " + | ||
| 168 | "select distinct ?x" + | ||
| 169 | " where { " | ||
| 170 | + " ?x rdf:type " + classB + | ||
| 171 | " }"; | ||
| 172 | QueryRecord queryRecord = pagoda.getQueryManager().create(queryStr); | ||
| 173 | System.out.println(queryRecord); | ||
| 174 | pagoda.evaluate(queryRecord); | ||
| 175 | AnswerTuples answers = queryRecord.getAnswers(); | ||
| 176 | System.out.println("Difficulty: " + queryRecord.getDifficulty()); | ||
| 177 | for(AnswerTuple ans; answers.isValid(); answers.moveNext()) { | ||
| 178 | ans = answers.getTuple(); | ||
| 179 | TestUtil.logInfo(ans); | ||
| 180 | } | ||
| 181 | } | ||
| 182 | pagoda.dispose(); | ||
| 183 | } | ||
| 101 | } | 184 | } |
diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java index 31d2eac..0ce3d69 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java | |||
| @@ -25,7 +25,6 @@ public class TestPagodaFLY { | |||
| 25 | .query(Paths.get(ontoDir, "fly/queries/fly.sparql")) | 25 | .query(Paths.get(ontoDir, "fly/queries/fly.sparql")) |
| 26 | .answer(answers) | 26 | .answer(answers) |
| 27 | .classify(false) | 27 | .classify(false) |
| 28 | .hermit(true) | ||
| 29 | .build(); | 28 | .build(); |
| 30 | 29 | ||
| 31 | pagoda.run(); | 30 | pagoda.run(); |
| @@ -45,7 +44,6 @@ public class TestPagodaFLY { | |||
| 45 | .answer(answers) | 44 | .answer(answers) |
| 46 | // .answer(Paths.get("/home/alessandro/Desktop/answers.json")) | 45 | // .answer(Paths.get("/home/alessandro/Desktop/answers.json")) |
| 47 | .classify(false) | 46 | .classify(false) |
| 48 | .hermit(true) | ||
| 49 | .build(); | 47 | .build(); |
| 50 | 48 | ||
| 51 | pagoda.run(); | 49 | pagoda.run(); |
| @@ -57,8 +55,8 @@ public class TestPagodaFLY { | |||
| 57 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | 55 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); |
| 58 | 56 | ||
| 59 | Pagoda.builder() | 57 | Pagoda.builder() |
| 60 | .ontology(Paths.get(ontoDir, "fly/fly_rolledUp.owl")) | 58 | // .ontology(Paths.get(ontoDir, "fly/fly_rolledUp.owl")) |
| 61 | // .ontology(Paths.get(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl")) | 59 | .ontology(Paths.get(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl")) |
| 62 | .query(Paths.get(ontoDir, "fly/queries/new_queries.sparql")) | 60 | .query(Paths.get(ontoDir, "fly/queries/new_queries.sparql")) |
| 63 | // .answer(Paths.get("/home/alessandro/Desktop/answers.json")) | 61 | // .answer(Paths.get("/home/alessandro/Desktop/answers.json")) |
| 64 | .classify(false) | 62 | .classify(false) |
diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaLUBM.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaLUBM.java index fdbfc42..c893f96 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaLUBM.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaLUBM.java | |||
| @@ -23,8 +23,6 @@ public class TestPagodaLUBM { | |||
| 23 | .data(Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl")) | 23 | .data(Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl")) |
| 24 | .query(Paths.get(ontoDir, "lubm/queries/test.sparql")) | 24 | .query(Paths.get(ontoDir, "lubm/queries/test.sparql")) |
| 25 | .answer(answers) | 25 | .answer(answers) |
| 26 | .classify(true) | ||
| 27 | .hermit(true) | ||
| 28 | .build(); | 26 | .build(); |
| 29 | 27 | ||
| 30 | pagoda.run(); | 28 | pagoda.run(); |
| @@ -45,11 +43,9 @@ public class TestPagodaLUBM { | |||
| 45 | Pagoda pagoda = Pagoda.builder() | 43 | Pagoda pagoda = Pagoda.builder() |
| 46 | .ontology(Paths.get(ontoDir, "lubm/univ-bench.owl")) | 44 | .ontology(Paths.get(ontoDir, "lubm/univ-bench.owl")) |
| 47 | .data(Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl")) | 45 | .data(Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl")) |
| 48 | .query(Paths.get(ontoDir, "lubm/queries/lubm_sygenia.sparql")) | 46 | .query(Paths.get(ontoDir, "lubm/queries/lubm_sygenia.sparql")) |
| 49 | // .answer(answers) | 47 | // .answer(answers) |
| 50 | .classify(true) | 48 | .build(); |
| 51 | .hermit(true) | ||
| 52 | .build(); | ||
| 53 | 49 | ||
| 54 | pagoda.run(); | 50 | pagoda.run(); |
| 55 | // CheckAnswers.assertSameAnswers(answers, givenAnswers); | 51 | // CheckAnswers.assertSameAnswers(answers, givenAnswers); |
| @@ -71,8 +67,6 @@ public class TestPagodaLUBM { | |||
| 71 | .data(Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl")) | 67 | .data(Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl")) |
| 72 | .query(Paths.get(ontoDir, "lubm/queries/lubm_sygenia_all-blanks.sparql")) | 68 | .query(Paths.get(ontoDir, "lubm/queries/lubm_sygenia_all-blanks.sparql")) |
| 73 | // .answer(answers) | 69 | // .answer(answers) |
| 74 | .classify(true) | ||
| 75 | .hermit(true) | ||
| 76 | .build(); | 70 | .build(); |
| 77 | 71 | ||
| 78 | pagoda.run(); | 72 | pagoda.run(); |
diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java index 9fb6cbe..c5b272c 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java | |||
| @@ -41,8 +41,6 @@ public class TestPagodaUOBM { | |||
| 41 | .data(Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl")) | 41 | .data(Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl")) |
| 42 | .query(Paths.get(ontoDir, "uobm/queries/test.sparql")) | 42 | .query(Paths.get(ontoDir, "uobm/queries/test.sparql")) |
| 43 | .answer(answers) | 43 | .answer(answers) |
| 44 | .classify(true) | ||
| 45 | .hermit(true) | ||
| 46 | .build(); | 44 | .build(); |
| 47 | 45 | ||
| 48 | pagoda.run(); | 46 | pagoda.run(); |
| @@ -65,8 +63,6 @@ public class TestPagodaUOBM { | |||
| 65 | .ontology(Paths.get(ontoDir, "uobm/univ-bench-dl.owl")) | 63 | .ontology(Paths.get(ontoDir, "uobm/univ-bench-dl.owl")) |
| 66 | .data(Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl")) | 64 | .data(Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl")) |
| 67 | .query(Paths.get(ontoDir, "uobm/queries/uobm_sygenia.sparql")) | 65 | .query(Paths.get(ontoDir, "uobm/queries/uobm_sygenia.sparql")) |
| 68 | .classify(true) | ||
| 69 | .hermit(true) | ||
| 70 | .build(); | 66 | .build(); |
| 71 | 67 | ||
| 72 | pagoda.run(); | 68 | pagoda.run(); |
| @@ -85,22 +81,30 @@ public class TestPagodaUOBM { | |||
| 85 | .ontology(Paths.get(ontoDir, "uobm/univ-bench-dl.owl")) | 81 | .ontology(Paths.get(ontoDir, "uobm/univ-bench-dl.owl")) |
| 86 | .data(Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl")) | 82 | .data(Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl")) |
| 87 | .query(Paths.get(ontoDir, "uobm/queries/uobm_sygenia_all-blanks.sparql")) | 83 | .query(Paths.get(ontoDir, "uobm/queries/uobm_sygenia_all-blanks.sparql")) |
| 88 | .classify(true) | 84 | .build() |
| 89 | .hermit(true) | 85 | .run(); |
| 86 | } | ||
| 87 | |||
| 88 | @Test(groups = {"justExecute", "heavy", "nonOriginal"}) | ||
| 89 | public void justExecute_modifiedUOBM() throws IOException { | ||
| 90 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 91 | |||
| 92 | Pagoda.builder() | ||
| 93 | .ontology(Paths.get(ontoDir, "uobm_modified/univ-bench-dl-modified.owl")) | ||
| 94 | .data(Paths.get(ontoDir, "uobm_modified/data/uobm1.ttl")) | ||
| 95 | .query(Paths.get(ontoDir, "uobm_modified/queries/additional_queries.sparql")) | ||
| 90 | .build() | 96 | .build() |
| 91 | .run(); | 97 | .run(); |
| 92 | } | 98 | } |
| 93 | 99 | ||
| 94 | @Test(groups = {"justExecute"}) | 100 | @Test(groups = {"justExecute"}) |
| 95 | public void justExecute_existentialQueries() throws IOException { | 101 | public void justExecute_additionalQueries() throws IOException { |
| 96 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | 102 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); |
| 97 | 103 | ||
| 98 | Pagoda.builder() | 104 | Pagoda.builder() |
| 99 | .ontology(Paths.get(ontoDir, "uobm/univ-bench-dl-modified.owl")) | 105 | .ontology(Paths.get(ontoDir, "uobm/univ-bench-dl.owl")) |
| 100 | .data(Paths.get(ontoDir, "uobm/data/uobm1.ttl")) | 106 | .data(Paths.get(ontoDir, "uobm/data/uobm1.ttl")) |
| 101 | .query(Paths.get(ontoDir, "uobm/queries/existential_queries.sparql")) | 107 | .query(Paths.get(ontoDir, "uobm/queries/additional_queries.sparql")) |
| 102 | .classify(true) | ||
| 103 | .hermit(true) | ||
| 104 | .build() | 108 | .build() |
| 105 | .run(); | 109 | .run(); |
| 106 | } | 110 | } |
