diff options
| author | RncLsn <rnc.lsn@gmail.com> | 2015-05-09 14:26:28 +0100 |
|---|---|---|
| committer | RncLsn <rnc.lsn@gmail.com> | 2015-05-09 14:26:28 +0100 |
| commit | 870eb35e38f746ed73f233070dcf3bdaf4687e02 (patch) | |
| tree | 41ef0c1e18057aedc9f0f94d242cf6450d22025f /test | |
| parent | 5be5fd3daa0d50980fb3791e904e035cdbca254f (diff) | |
| download | ACQuA-870eb35e38f746ed73f233070dcf3bdaf4687e02.tar.gz ACQuA-870eb35e38f746ed73f233070dcf3bdaf4687e02.zip | |
Adding (not completed) log of partial answers in Json.
Diffstat (limited to 'test')
| -rw-r--r-- | test/AllTests.xml | 6 | ||||
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/test_units/PagodaLUBM.java | 2 | ||||
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/test_units/PagodaUOBM.java | 2 | ||||
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/test_units/TestGlobalCorrectness.java | 27 | ||||
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java | 6 | ||||
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/util/TestUtil.java | 3 |
6 files changed, 25 insertions, 21 deletions
diff --git a/test/AllTests.xml b/test/AllTests.xml index 8ce5fcf..cb8a0e3 100644 --- a/test/AllTests.xml +++ b/test/AllTests.xml | |||
| @@ -9,4 +9,10 @@ | |||
| 9 | </classes> | 9 | </classes> |
| 10 | </test> | 10 | </test> |
| 11 | 11 | ||
| 12 | <test name="PagodaLUBM"> | ||
| 13 | <classes> | ||
| 14 | <class name="uk.ac.ox.cs.pagoda.test_units.PagodaLUBM" /> | ||
| 15 | </classes> | ||
| 16 | </test> | ||
| 17 | |||
| 12 | </suite> \ No newline at end of file | 18 | </suite> \ No newline at end of file |
diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaLUBM.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaLUBM.java index 29abc87..1aded5b 100644 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaLUBM.java +++ b/test/uk/ac/ox/cs/pagoda/test_units/PagodaLUBM.java | |||
| @@ -13,7 +13,7 @@ public class PagodaLUBM { | |||
| 13 | TestGlobalCorrectness.test(Paths.get(ontoDir, "lubm/univ-bench.owl"), | 13 | TestGlobalCorrectness.test(Paths.get(ontoDir, "lubm/univ-bench.owl"), |
| 14 | Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl"), | 14 | Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl"), |
| 15 | Paths.get(ontoDir, "lubm/queries/test.sparql"), | 15 | Paths.get(ontoDir, "lubm/queries/test.sparql"), |
| 16 | Paths.get(ontoDir, "lubm/lubm" + number + ".ans")); | 16 | Paths.get(ontoDir, "lubm/lubm" + number + ".json")); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | @Test | 19 | @Test |
diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaUOBM.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaUOBM.java index f53ed7e..ee9cf13 100644 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaUOBM.java +++ b/test/uk/ac/ox/cs/pagoda/test_units/PagodaUOBM.java | |||
| @@ -13,7 +13,7 @@ public class PagodaUOBM { | |||
| 13 | TestGlobalCorrectness.test(Paths.get(ontoDir, "uobm/univ-bench-dl.owl"), | 13 | TestGlobalCorrectness.test(Paths.get(ontoDir, "uobm/univ-bench-dl.owl"), |
| 14 | Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl"), | 14 | Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl"), |
| 15 | Paths.get(ontoDir, "uobm/queries/test.sparql"), | 15 | Paths.get(ontoDir, "uobm/queries/test.sparql"), |
| 16 | Paths.get(ontoDir, "uobm/uobm" + number + ".ans")); | 16 | Paths.get(ontoDir, "uobm/uobm" + number + ".json")); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | @Test | 19 | @Test |
diff --git a/test/uk/ac/ox/cs/pagoda/test_units/TestGlobalCorrectness.java b/test/uk/ac/ox/cs/pagoda/test_units/TestGlobalCorrectness.java index 34ec8cd..ffaf8fc 100644 --- a/test/uk/ac/ox/cs/pagoda/test_units/TestGlobalCorrectness.java +++ b/test/uk/ac/ox/cs/pagoda/test_units/TestGlobalCorrectness.java | |||
| @@ -1,13 +1,12 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.test_units; | 1 | package uk.ac.ox.cs.pagoda.test_units; |
| 2 | 2 | ||
| 3 | import com.google.gson.Gson; | 3 | import com.google.gson.Gson; |
| 4 | import com.google.gson.GsonBuilder; | ||
| 5 | import com.google.gson.reflect.TypeToken; | 4 | import com.google.gson.reflect.TypeToken; |
| 6 | import org.apache.log4j.Logger; | 5 | import org.apache.log4j.Level; |
| 7 | import org.testng.Assert; | 6 | import org.testng.Assert; |
| 8 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; | ||
| 9 | import uk.ac.ox.cs.pagoda.query.QueryRecord; | 7 | import uk.ac.ox.cs.pagoda.query.QueryRecord; |
| 10 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; | 8 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; |
| 9 | import uk.ac.ox.cs.pagoda.util.Utility; | ||
| 11 | 10 | ||
| 12 | import java.io.BufferedReader; | 11 | import java.io.BufferedReader; |
| 13 | import java.io.File; | 12 | import java.io.File; |
| @@ -16,39 +15,37 @@ import java.lang.reflect.Type; | |||
| 16 | import java.nio.file.Files; | 15 | import java.nio.file.Files; |
| 17 | import java.nio.file.Path; | 16 | import java.nio.file.Path; |
| 18 | import java.nio.file.Paths; | 17 | import java.nio.file.Paths; |
| 19 | import java.util.Collection; | ||
| 20 | import java.util.Set; | 18 | import java.util.Set; |
| 21 | 19 | ||
| 22 | /* | 20 | /** |
| 23 | * This is a unit test for TestNG. | 21 | * This is a unit test for TestNG. |
| 24 | * <p> | 22 | * <p> |
| 25 | * It tests the correctness on the final output. | 23 | * It tests the correctness on the final output. |
| 26 | * */ | 24 | * */ |
| 27 | public class TestGlobalCorrectness { | 25 | public class TestGlobalCorrectness { |
| 28 | 26 | ||
| 29 | public static final Logger logger = Logger.getLogger(TestGlobalCorrectness.class); | ||
| 30 | |||
| 31 | public static void test(Path ontology, Path data, Path queries, Path givenAnswers) { | 27 | public static void test(Path ontology, Path data, Path queries, Path givenAnswers) { |
| 32 | try { | 28 | try { |
| 33 | Path computedAnswers = Paths.get(File.createTempFile("answers", ".tmp").getAbsolutePath()); | 29 | Utility.setLogLevel(Level.DEBUG); |
| 30 | Path computedAnswers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); | ||
| 34 | PagodaTester.main(ontology.toString(), data.toString(), queries.toString(), computedAnswers.toString()); | 31 | PagodaTester.main(ontology.toString(), data.toString(), queries.toString(), computedAnswers.toString()); |
| 35 | Assert.assertTrue(checkSameContent(computedAnswers, givenAnswers)); | 32 | assertSameContent(computedAnswers, givenAnswers); |
| 36 | } catch (IOException e) { | 33 | } catch (IOException e) { |
| 37 | e.printStackTrace(); | 34 | e.printStackTrace(); |
| 38 | } | 35 | } |
| 39 | } | 36 | } |
| 40 | 37 | ||
| 41 | private static boolean checkSameContent(Path computedAnswersFile, Path givenAnswersFile) throws IOException { | 38 | private static void assertSameContent(Path computedAnswersFile, Path givenAnswersFile) throws IOException { |
| 42 | BufferedReader computedReader = Files.newBufferedReader(computedAnswersFile); | 39 | BufferedReader computedReader = Files.newBufferedReader(computedAnswersFile); |
| 43 | BufferedReader givenReader = Files.newBufferedReader(givenAnswersFile); | 40 | BufferedReader givenReader = Files.newBufferedReader(givenAnswersFile); |
| 44 | 41 | ||
| 45 | Gson gson = new GsonBuilder().create(); | 42 | Gson gson = QueryRecord.GsonCreator.getInstance(); |
| 46 | 43 | ||
| 47 | Type cqType = new TypeToken<Set<AnswerTuple>>() {}.getType(); | 44 | Type cqType = new TypeToken<Set<QueryRecord>>() {}.getType(); |
| 48 | Collection<QueryRecord> computedAnswers = gson.fromJson(computedReader, cqType); | 45 | Set<QueryRecord> computedAnswers = gson.fromJson(computedReader, cqType); |
| 49 | Collection<QueryRecord> givenAnswers = gson.fromJson(givenReader, cqType); | 46 | Set<QueryRecord> givenAnswers = gson.fromJson(givenReader, cqType); |
| 50 | 47 | ||
| 51 | return computedAnswers.equals(givenAnswers); | 48 | Assert.assertEquals(computedAnswers, givenAnswers); |
| 52 | } | 49 | } |
| 53 | 50 | ||
| 54 | 51 | ||
diff --git a/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java b/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java index 7dacdac..5e49f79 100644 --- a/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java +++ b/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java | |||
| @@ -37,7 +37,7 @@ public class PagodaTester { | |||
| 37 | public static final int uobm_number = 1; | 37 | public static final int uobm_number = 1; |
| 38 | public static final String uobm_tbox = onto_dir + "uobm/univ-bench-dl.owl"; | 38 | public static final String uobm_tbox = onto_dir + "uobm/univ-bench-dl.owl"; |
| 39 | public static final String uobm_abox = onto_dir + "uobm/data/uobm" + uobm_number + ".ttl"; | 39 | public static final String uobm_abox = onto_dir + "uobm/data/uobm" + uobm_number + ".ttl"; |
| 40 | public static final String uobm_query = onto_dir + "uobm/queries/standard.sparql"; | 40 | public static final String uobm_query = onto_dir + "uobm/queries/test.sparql"; |
| 41 | public static final String uobm_query_temp = onto_dir + "uobm/queries/temp.sparql"; | 41 | public static final String uobm_query_temp = onto_dir + "uobm/queries/temp.sparql"; |
| 42 | public static final String uobm_query2 = onto_dir + "uobm/queries/standard_q2.sparql"; | 42 | public static final String uobm_query2 = onto_dir + "uobm/queries/standard_q2.sparql"; |
| 43 | public static final String uobm_query9 = onto_dir + "uobm/queries/standard_q9.sparql"; | 43 | public static final String uobm_query9 = onto_dir + "uobm/queries/standard_q9.sparql"; |
| @@ -93,8 +93,8 @@ public class PagodaTester { | |||
| 93 | public static void main(String... args) { | 93 | public static void main(String... args) { |
| 94 | if (args.length == 0) { | 94 | if (args.length == 0) { |
| 95 | // args = new String[] {test_tbox, test_abox, test_query}; | 95 | // args = new String[] {test_tbox, test_abox, test_query}; |
| 96 | args = new String[] {lubm_tbox, lubm_abox, lubm_query, "/home/alessandro/Desktop/lubm1.ans"}; | 96 | // args = new String[] {lubm_tbox, lubm_abox, lubm_query}; |
| 97 | // args = new String[] {uobm_tbox, uobm_abox, uobm_query.replace(".sparql", "_all_pagoda.sparql")}; | 97 | args = new String[] {uobm_tbox, uobm_abox, uobm_query, "/home/alessandro/Desktop/uobm1.ans"}; |
| 98 | // args = new String[] {fly, "null", fly_query.replace(".sparql", "_pellet.sparql") }; | 98 | // args = new String[] {fly, "null", fly_query.replace(".sparql", "_pellet.sparql") }; |
| 99 | // args = new String[] {dbpedia_tbox, dbpedia_abox, dbpedia_query}; | 99 | // args = new String[] {dbpedia_tbox, dbpedia_abox, dbpedia_query}; |
| 100 | // args = new String[] {travel_tbox, null, dbpedia_query274}; | 100 | // args = new String[] {travel_tbox, null, dbpedia_query274}; |
diff --git a/test/uk/ac/ox/cs/pagoda/util/TestUtil.java b/test/uk/ac/ox/cs/pagoda/util/TestUtil.java index 227398b..06d391a 100644 --- a/test/uk/ac/ox/cs/pagoda/util/TestUtil.java +++ b/test/uk/ac/ox/cs/pagoda/util/TestUtil.java | |||
| @@ -48,7 +48,7 @@ public class TestUtil { | |||
| 48 | Files.copy(Paths.get(src), Paths.get(dst), REPLACE_EXISTING); | 48 | Files.copy(Paths.get(src), Paths.get(dst), REPLACE_EXISTING); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | /* | 51 | /** |
| 52 | * Get the log file, which is assumed unique. | 52 | * Get the log file, which is assumed unique. |
| 53 | * */ | 53 | * */ |
| 54 | public static String getLogFileName() { | 54 | public static String getLogFileName() { |
| @@ -61,4 +61,5 @@ public class TestUtil { | |||
| 61 | } | 61 | } |
| 62 | return null; | 62 | return null; |
| 63 | } | 63 | } |
| 64 | |||
| 64 | } | 65 | } |
