From d81b086fe329fa69891eba0a4b1f73e44183620d Mon Sep 17 00:00:00 2001 From: RncLsn Date: Wed, 20 May 2015 18:52:47 +0100 Subject: Added more tests. Querying of the upper bound is currently unstable. --- .../cs/pagoda/global_tests/JAIR_Scalability.java | 4 +-- .../ox/cs/pagoda/global_tests/LightEvaluation.java | 4 +-- .../ox/cs/pagoda/global_tests/TestPagodaFLY.java | 41 +++++++++++++++++----- .../ox/cs/pagoda/global_tests/TestPagodaLUBM.java | 39 +++++--------------- .../ox/cs/pagoda/global_tests/TestPagodaUOBM.java | 31 +++++----------- test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java | 4 +-- test/uk/ac/ox/cs/pagoda/util/TestUtil.java | 9 +++++ 7 files changed, 64 insertions(+), 68 deletions(-) (limited to 'test/uk/ac') diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_Scalability.java b/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_Scalability.java index 5feda35..01f3568 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_Scalability.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_Scalability.java @@ -2,7 +2,7 @@ package uk.ac.ox.cs.pagoda.global_tests; import org.testng.annotations.Test; import uk.ac.ox.cs.pagoda.tester.PagodaTester; -import uk.ac.ox.cs.pagoda.util.Properties; +import uk.ac.ox.cs.pagoda.util.PagodaProperties; import uk.ac.ox.cs.pagoda.util.TestUtil; import java.io.IOException; @@ -12,7 +12,7 @@ public class JAIR_Scalability { private static final String date = "_0123"; public static void main(String... args) throws IOException { - Properties.shellModeDefault = true; + PagodaProperties.shellModeDefault = true; new JAIR_Scalability().testUniProt(50, false); } diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/LightEvaluation.java b/test/uk/ac/ox/cs/pagoda/global_tests/LightEvaluation.java index eb1f42c..3551b9b 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/LightEvaluation.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/LightEvaluation.java @@ -10,8 +10,8 @@ public class LightEvaluation { @Test public void evaluation() throws IOException { new TestPagodaUOBM().answersCorrectness(1); - new TestPagodaLUBM().answersCorrecntess(100); - new TestPagodaFLY().answersCorrectness(); + new TestPagodaLUBM().answersCorrectness(100); +// new TestPagodaFLY().answersCorrectness(); new TestPagodaDBPedia().answersCorrectness(); new TestPagodaNPD().testNPDwithoutDataType(); } 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 5c8dbf6..d8d2b76 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java @@ -4,25 +4,48 @@ import org.testng.annotations.Test; import uk.ac.ox.cs.pagoda.Pagoda; import uk.ac.ox.cs.pagoda.util.TestUtil; -public class TestPagodaFLY { +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; - public static final String ANSWER_PATH = "~/TestPagodaFLY.json"; +public class TestPagodaFLY { @Test(groups = {"light"}) - public void just_execute() { + public void answersCorrectness_withGJFC() throws IOException { String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + Path answers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); + new File(answers.toString()).deleteOnExit(); + Path givenAnswers = TestUtil.getAnswersFilePath("answers/pagoda-fly-with-GJ-FC-individuals.json"); + Pagoda pagoda = Pagoda.builder() .ontology(TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl")) .query(TestUtil.combinePaths(ontoDir, "fly/queries/fly.sparql")) -// .answer(ANSWER_PATH) - .classify(true) + .answer(answers) + .classify(false) .hermit(true) - .build(); + .build(); + pagoda.run(); + CheckAnswers.assertSameAnswers(answers, givenAnswers); } - @Test - public void answersCorrectness() { - // TODO implement + @Test(groups = {"light"}) + public void answersCorrectness_rolledUp() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + Path answers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); + new File(answers.toString()).deleteOnExit(); + Path givenAnswers = TestUtil.getAnswersFilePath("answers/pagoda-fly-rolledup.json"); + + Pagoda pagoda = Pagoda.builder() + .ontology(TestUtil.combinePaths(ontoDir, "fly/fly_rolledUp.owl")) + .query(TestUtil.combinePaths(ontoDir, "fly/queries/fly_rolledUp.sparql")) + .answer(answers) + .classify(false) + .hermit(true) + .build(); + + pagoda.run(); + CheckAnswers.assertSameAnswers(answers, givenAnswers); } } 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 8cbe022..d261d84 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaLUBM.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaLUBM.java @@ -11,50 +11,27 @@ import java.nio.file.Paths; public class TestPagodaLUBM { - /** - * Just execute on LUBM 100 - */ - public static void main(String... args) { - new TestPagodaLUBM().justExecute_100(); - } - - public void answersCorrecntess(int number) throws IOException { + public void answersCorrectness(int number) throws IOException { String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - Path computedAnswers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); - new File(computedAnswers.toString()).deleteOnExit(); + Path answers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); + new File(answers.toString()).deleteOnExit(); + Path givenAnswers = TestUtil.getAnswersFilePath("answers/pagoda-lubm" + number + ".json"); Pagoda pagoda = Pagoda.builder() .ontology(Paths.get(ontoDir, "lubm/univ-bench.owl")) .data(Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl")) .query(Paths.get(ontoDir, "lubm/queries/test.sparql")) - .answer(computedAnswers) + .answer(answers) .classify(true) .hermit(true) .build(); - pagoda.run(); - Path givenAnswers = Paths.get(ontoDir, "lubm/lubm" + number + ".json"); - CheckAnswers.assertSameAnswers(computedAnswers, givenAnswers); + pagoda.run(); + CheckAnswers.assertSameAnswers(answers, givenAnswers); } @Test(groups = {"light"}) public void answersCorrectness_1() throws IOException { - answersCorrecntess(1); - } - - /** - * Just execute on LUBM 100 - * */ - public void justExecute_100() { - int number = 100; - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - Pagoda pagoda = Pagoda.builder() - .ontology(Paths.get(ontoDir, "lubm/univ-bench.owl")) - .data(Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl")) - .query(Paths.get(ontoDir, "lubm/queries/answersCorrectness.sparql")) - .classify(true) - .hermit(true) - .build(); - pagoda.run(); + answersCorrectness(1); } } 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 0956ee8..558ac1f 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java @@ -13,7 +13,7 @@ import java.nio.file.Paths; public class TestPagodaUOBM { private static final int N_1 = 1; - private static final int N_2 = 10; + private static final int N_2 = 4; @DataProvider(name = "UOBMNumbers") private static Object[][] UOBMNumbers() { @@ -23,42 +23,29 @@ public class TestPagodaUOBM { return integers; } - public void answersCorrectness(int number) throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - Path computedAnswers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); - new File(computedAnswers.toString()).deleteOnExit(); - - Pagoda pagoda = Pagoda.builder() - .ontology(Paths.get(ontoDir, "uobm/univ-bench-dl.owl")) - .data(Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl")) - .query(Paths.get(ontoDir, "uobm/queries/test.sparql")) - .answer(computedAnswers) - .classify(true) - .hermit(true) - .build(); - pagoda.run(); - - // TODO use HermitReasoner for computing correct answers if they are missing - String given_answers = "uobm/uobm" + number + ".json"; - CheckAnswers.assertSameAnswers(computedAnswers, Paths.get(ontoDir, given_answers)); - } - @Test(groups = {"light"}) public void answersCorrectness_1() throws IOException { answersCorrectness(1); } @Test(groups = {"heavy"}, dataProvider = "UOBMNumbers") - public void justExecute(int number) { + public void answersCorrectness(int number) throws IOException { String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + Path answers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); + new File(answers.toString()).deleteOnExit(); + Path givenAnswers = TestUtil.getAnswersFilePath("answers/pagoda-uobm" + number + ".json"); + Pagoda pagoda = Pagoda.builder() .ontology(Paths.get(ontoDir, "uobm/univ-bench-dl.owl")) .data(Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl")) .query(Paths.get(ontoDir, "uobm/queries/test.sparql")) + .answer(answers) .classify(true) .hermit(true) .build(); + pagoda.run(); + CheckAnswers.assertSameAnswers(answers, givenAnswers); } } diff --git a/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java b/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java index 274946d..d741d3b 100644 --- a/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java +++ b/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java @@ -3,7 +3,7 @@ package uk.ac.ox.cs.pagoda.tester; import uk.ac.ox.cs.pagoda.query.AnswerTuple; import uk.ac.ox.cs.pagoda.query.AnswerTuples; import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; -import uk.ac.ox.cs.pagoda.util.Properties; +import uk.ac.ox.cs.pagoda.util.PagodaProperties; import uk.ac.ox.cs.pagoda.util.Timer; import uk.ac.ox.cs.pagoda.util.Utility; @@ -136,7 +136,7 @@ public class PagodaTester { // args[2] = args[2].replace(".sparql", "_pellet.sparql"); } - Properties properties = new Properties("config/uobm.properties"); + PagodaProperties properties = new PagodaProperties("config/uobm.properties"); int index = 0; if(args.length > index) properties.setOntologyPath(args[index++]); diff --git a/test/uk/ac/ox/cs/pagoda/util/TestUtil.java b/test/uk/ac/ox/cs/pagoda/util/TestUtil.java index ad0d494..c3909d5 100644 --- a/test/uk/ac/ox/cs/pagoda/util/TestUtil.java +++ b/test/uk/ac/ox/cs/pagoda/util/TestUtil.java @@ -7,7 +7,9 @@ import org.apache.log4j.Logger; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.net.URL; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.Enumeration; import java.util.Properties; @@ -62,4 +64,11 @@ public class TestUtil { return null; } + public static Path getAnswersFilePath(String name) { + URL givenAnswersURL = TestUtil.class.getClassLoader() + .getResource(name); + if(givenAnswersURL == null) throw new RuntimeException("Missing answers file:" + name); + return Paths.get(givenAnswersURL.getPath()); + } + } -- cgit v1.2.3