aboutsummaryrefslogtreecommitdiff
path: root/test/uk/ac/ox/cs/pagoda
diff options
context:
space:
mode:
Diffstat (limited to 'test/uk/ac/ox/cs/pagoda')
-rw-r--r--test/uk/ac/ox/cs/pagoda/global_tests/JAIR_Scalability.java4
-rw-r--r--test/uk/ac/ox/cs/pagoda/global_tests/LightEvaluation.java4
-rw-r--r--test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java41
-rw-r--r--test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaLUBM.java39
-rw-r--r--test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java31
-rw-r--r--test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java4
-rw-r--r--test/uk/ac/ox/cs/pagoda/util/TestUtil.java9
7 files changed, 64 insertions, 68 deletions
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;
2 2
3import org.testng.annotations.Test; 3import org.testng.annotations.Test;
4import uk.ac.ox.cs.pagoda.tester.PagodaTester; 4import uk.ac.ox.cs.pagoda.tester.PagodaTester;
5import uk.ac.ox.cs.pagoda.util.Properties; 5import uk.ac.ox.cs.pagoda.util.PagodaProperties;
6import uk.ac.ox.cs.pagoda.util.TestUtil; 6import uk.ac.ox.cs.pagoda.util.TestUtil;
7 7
8import java.io.IOException; 8import java.io.IOException;
@@ -12,7 +12,7 @@ public class JAIR_Scalability {
12 private static final String date = "_0123"; 12 private static final String date = "_0123";
13 13
14 public static void main(String... args) throws IOException { 14 public static void main(String... args) throws IOException {
15 Properties.shellModeDefault = true; 15 PagodaProperties.shellModeDefault = true;
16 new JAIR_Scalability().testUniProt(50, false); 16 new JAIR_Scalability().testUniProt(50, false);
17 } 17 }
18 18
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 {
10 @Test 10 @Test
11 public void evaluation() throws IOException { 11 public void evaluation() throws IOException {
12 new TestPagodaUOBM().answersCorrectness(1); 12 new TestPagodaUOBM().answersCorrectness(1);
13 new TestPagodaLUBM().answersCorrecntess(100); 13 new TestPagodaLUBM().answersCorrectness(100);
14 new TestPagodaFLY().answersCorrectness(); 14// new TestPagodaFLY().answersCorrectness();
15 new TestPagodaDBPedia().answersCorrectness(); 15 new TestPagodaDBPedia().answersCorrectness();
16 new TestPagodaNPD().testNPDwithoutDataType(); 16 new TestPagodaNPD().testNPDwithoutDataType();
17 } 17 }
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;
4import uk.ac.ox.cs.pagoda.Pagoda; 4import uk.ac.ox.cs.pagoda.Pagoda;
5import uk.ac.ox.cs.pagoda.util.TestUtil; 5import uk.ac.ox.cs.pagoda.util.TestUtil;
6 6
7public class TestPagodaFLY { 7import java.io.File;
8import java.io.IOException;
9import java.nio.file.Path;
10import java.nio.file.Paths;
8 11
9 public static final String ANSWER_PATH = "~/TestPagodaFLY.json"; 12public class TestPagodaFLY {
10 13
11 @Test(groups = {"light"}) 14 @Test(groups = {"light"})
12 public void just_execute() { 15 public void answersCorrectness_withGJFC() throws IOException {
13 String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); 16 String ontoDir = TestUtil.getConfig().getProperty("ontoDir");
17 Path answers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath());
18 new File(answers.toString()).deleteOnExit();
19 Path givenAnswers = TestUtil.getAnswersFilePath("answers/pagoda-fly-with-GJ-FC-individuals.json");
20
14 Pagoda pagoda = Pagoda.builder() 21 Pagoda pagoda = Pagoda.builder()
15 .ontology(TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl")) 22 .ontology(TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"))
16 .query(TestUtil.combinePaths(ontoDir, "fly/queries/fly.sparql")) 23 .query(TestUtil.combinePaths(ontoDir, "fly/queries/fly.sparql"))
17// .answer(ANSWER_PATH) 24 .answer(answers)
18 .classify(true) 25 .classify(false)
19 .hermit(true) 26 .hermit(true)
20 .build(); 27 .build();
28
21 pagoda.run(); 29 pagoda.run();
30 CheckAnswers.assertSameAnswers(answers, givenAnswers);
22 } 31 }
23 32
24 @Test 33 @Test(groups = {"light"})
25 public void answersCorrectness() { 34 public void answersCorrectness_rolledUp() throws IOException {
26 // TODO implement 35 String ontoDir = TestUtil.getConfig().getProperty("ontoDir");
36 Path answers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath());
37 new File(answers.toString()).deleteOnExit();
38 Path givenAnswers = TestUtil.getAnswersFilePath("answers/pagoda-fly-rolledup.json");
39
40 Pagoda pagoda = Pagoda.builder()
41 .ontology(TestUtil.combinePaths(ontoDir, "fly/fly_rolledUp.owl"))
42 .query(TestUtil.combinePaths(ontoDir, "fly/queries/fly_rolledUp.sparql"))
43 .answer(answers)
44 .classify(false)
45 .hermit(true)
46 .build();
47
48 pagoda.run();
49 CheckAnswers.assertSameAnswers(answers, givenAnswers);
27 } 50 }
28} 51}
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;
11 11
12public class TestPagodaLUBM { 12public class TestPagodaLUBM {
13 13
14 /** 14 public void answersCorrectness(int number) throws IOException {
15 * Just execute on LUBM 100
16 */
17 public static void main(String... args) {
18 new TestPagodaLUBM().justExecute_100();
19 }
20
21 public void answersCorrecntess(int number) throws IOException {
22 String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); 15 String ontoDir = TestUtil.getConfig().getProperty("ontoDir");
23 Path computedAnswers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); 16 Path answers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath());
24 new File(computedAnswers.toString()).deleteOnExit(); 17 new File(answers.toString()).deleteOnExit();
18 Path givenAnswers = TestUtil.getAnswersFilePath("answers/pagoda-lubm" + number + ".json");
25 19
26 Pagoda pagoda = Pagoda.builder() 20 Pagoda pagoda = Pagoda.builder()
27 .ontology(Paths.get(ontoDir, "lubm/univ-bench.owl")) 21 .ontology(Paths.get(ontoDir, "lubm/univ-bench.owl"))
28 .data(Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl")) 22 .data(Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl"))
29 .query(Paths.get(ontoDir, "lubm/queries/test.sparql")) 23 .query(Paths.get(ontoDir, "lubm/queries/test.sparql"))
30 .answer(computedAnswers) 24 .answer(answers)
31 .classify(true) 25 .classify(true)
32 .hermit(true) 26 .hermit(true)
33 .build(); 27 .build();
34 pagoda.run();
35 28
36 Path givenAnswers = Paths.get(ontoDir, "lubm/lubm" + number + ".json"); 29 pagoda.run();
37 CheckAnswers.assertSameAnswers(computedAnswers, givenAnswers); 30 CheckAnswers.assertSameAnswers(answers, givenAnswers);
38 } 31 }
39 32
40 @Test(groups = {"light"}) 33 @Test(groups = {"light"})
41 public void answersCorrectness_1() throws IOException { 34 public void answersCorrectness_1() throws IOException {
42 answersCorrecntess(1); 35 answersCorrectness(1);
43 }
44
45 /**
46 * Just execute on LUBM 100
47 * */
48 public void justExecute_100() {
49 int number = 100;
50 String ontoDir = TestUtil.getConfig().getProperty("ontoDir");
51 Pagoda pagoda = Pagoda.builder()
52 .ontology(Paths.get(ontoDir, "lubm/univ-bench.owl"))
53 .data(Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl"))
54 .query(Paths.get(ontoDir, "lubm/queries/answersCorrectness.sparql"))
55 .classify(true)
56 .hermit(true)
57 .build();
58 pagoda.run();
59 } 36 }
60} 37}
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;
13public class TestPagodaUOBM { 13public class TestPagodaUOBM {
14 14
15 private static final int N_1 = 1; 15 private static final int N_1 = 1;
16 private static final int N_2 = 10; 16 private static final int N_2 = 4;
17 17
18 @DataProvider(name = "UOBMNumbers") 18 @DataProvider(name = "UOBMNumbers")
19 private static Object[][] UOBMNumbers() { 19 private static Object[][] UOBMNumbers() {
@@ -23,42 +23,29 @@ public class TestPagodaUOBM {
23 return integers; 23 return integers;
24 } 24 }
25 25
26 public void answersCorrectness(int number) throws IOException {
27 String ontoDir = TestUtil.getConfig().getProperty("ontoDir");
28 Path computedAnswers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath());
29 new File(computedAnswers.toString()).deleteOnExit();
30
31 Pagoda pagoda = Pagoda.builder()
32 .ontology(Paths.get(ontoDir, "uobm/univ-bench-dl.owl"))
33 .data(Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl"))
34 .query(Paths.get(ontoDir, "uobm/queries/test.sparql"))
35 .answer(computedAnswers)
36 .classify(true)
37 .hermit(true)
38 .build();
39 pagoda.run();
40
41 // TODO use HermitReasoner for computing correct answers if they are missing
42 String given_answers = "uobm/uobm" + number + ".json";
43 CheckAnswers.assertSameAnswers(computedAnswers, Paths.get(ontoDir, given_answers));
44 }
45
46 @Test(groups = {"light"}) 26 @Test(groups = {"light"})
47 public void answersCorrectness_1() throws IOException { 27 public void answersCorrectness_1() throws IOException {
48 answersCorrectness(1); 28 answersCorrectness(1);
49 } 29 }
50 30
51 @Test(groups = {"heavy"}, dataProvider = "UOBMNumbers") 31 @Test(groups = {"heavy"}, dataProvider = "UOBMNumbers")
52 public void justExecute(int number) { 32 public void answersCorrectness(int number) throws IOException {
53 String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); 33 String ontoDir = TestUtil.getConfig().getProperty("ontoDir");
34 Path answers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath());
35 new File(answers.toString()).deleteOnExit();
36 Path givenAnswers = TestUtil.getAnswersFilePath("answers/pagoda-uobm" + number + ".json");
37
54 Pagoda pagoda = Pagoda.builder() 38 Pagoda pagoda = Pagoda.builder()
55 .ontology(Paths.get(ontoDir, "uobm/univ-bench-dl.owl")) 39 .ontology(Paths.get(ontoDir, "uobm/univ-bench-dl.owl"))
56 .data(Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl")) 40 .data(Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl"))
57 .query(Paths.get(ontoDir, "uobm/queries/test.sparql")) 41 .query(Paths.get(ontoDir, "uobm/queries/test.sparql"))
42 .answer(answers)
58 .classify(true) 43 .classify(true)
59 .hermit(true) 44 .hermit(true)
60 .build(); 45 .build();
46
61 pagoda.run(); 47 pagoda.run();
48 CheckAnswers.assertSameAnswers(answers, givenAnswers);
62 } 49 }
63 50
64} 51}
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;
3import uk.ac.ox.cs.pagoda.query.AnswerTuple; 3import uk.ac.ox.cs.pagoda.query.AnswerTuple;
4import uk.ac.ox.cs.pagoda.query.AnswerTuples; 4import uk.ac.ox.cs.pagoda.query.AnswerTuples;
5import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; 5import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner;
6import uk.ac.ox.cs.pagoda.util.Properties; 6import uk.ac.ox.cs.pagoda.util.PagodaProperties;
7import uk.ac.ox.cs.pagoda.util.Timer; 7import uk.ac.ox.cs.pagoda.util.Timer;
8import uk.ac.ox.cs.pagoda.util.Utility; 8import uk.ac.ox.cs.pagoda.util.Utility;
9 9
@@ -136,7 +136,7 @@ public class PagodaTester {
136// args[2] = args[2].replace(".sparql", "_pellet.sparql"); 136// args[2] = args[2].replace(".sparql", "_pellet.sparql");
137 } 137 }
138 138
139 Properties properties = new Properties("config/uobm.properties"); 139 PagodaProperties properties = new PagodaProperties("config/uobm.properties");
140 140
141 int index = 0; 141 int index = 0;
142 if(args.length > index) properties.setOntologyPath(args[index++]); 142 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;
7import java.io.File; 7import java.io.File;
8import java.io.IOException; 8import java.io.IOException;
9import java.io.InputStream; 9import java.io.InputStream;
10import java.net.URL;
10import java.nio.file.Files; 11import java.nio.file.Files;
12import java.nio.file.Path;
11import java.nio.file.Paths; 13import java.nio.file.Paths;
12import java.util.Enumeration; 14import java.util.Enumeration;
13import java.util.Properties; 15import java.util.Properties;
@@ -62,4 +64,11 @@ public class TestUtil {
62 return null; 64 return null;
63 } 65 }
64 66
67 public static Path getAnswersFilePath(String name) {
68 URL givenAnswersURL = TestUtil.class.getClassLoader()
69 .getResource(name);
70 if(givenAnswersURL == null) throw new RuntimeException("Missing answers file:" + name);
71 return Paths.get(givenAnswersURL.getPath());
72 }
73
65} 74}