aboutsummaryrefslogtreecommitdiff
path: root/test/uk/ac/ox/cs/pagoda/util/TestUtil.java
diff options
context:
space:
mode:
authorFederico Igne <federico.igne@cs.ox.ac.uk>2022-05-10 18:17:06 +0100
committerFederico Igne <federico.igne@cs.ox.ac.uk>2022-05-11 12:34:47 +0100
commit17bd9beaf7f358a44e5bf36a5855fe6727d506dc (patch)
tree47e9310a0cff869d9ec017dcb2c81876407782c8 /test/uk/ac/ox/cs/pagoda/util/TestUtil.java
parent8651164cd632a5db310b457ce32d4fbc97bdc41c (diff)
downloadACQuA-17bd9beaf7f358a44e5bf36a5855fe6727d506dc.tar.gz
ACQuA-17bd9beaf7f358a44e5bf36a5855fe6727d506dc.zip
[pagoda] Move project to Scala
This commit includes a few changes: - The repository still uses Maven to manage dependency but it is now a Scala project. - The code has been ported from OWLAPI 3.4.10 to 5.1.20 - A proof of concept program using both RSAComb and PAGOdA has been added.
Diffstat (limited to 'test/uk/ac/ox/cs/pagoda/util/TestUtil.java')
-rw-r--r--test/uk/ac/ox/cs/pagoda/util/TestUtil.java97
1 files changed, 0 insertions, 97 deletions
diff --git a/test/uk/ac/ox/cs/pagoda/util/TestUtil.java b/test/uk/ac/ox/cs/pagoda/util/TestUtil.java
deleted file mode 100644
index c7f024a..0000000
--- a/test/uk/ac/ox/cs/pagoda/util/TestUtil.java
+++ /dev/null
@@ -1,97 +0,0 @@
1package uk.ac.ox.cs.pagoda.util;
2
3import org.apache.log4j.Appender;
4import org.apache.log4j.FileAppender;
5import org.apache.log4j.Logger;
6import org.semanticweb.owlapi.model.IRI;
7
8import java.io.File;
9import java.io.IOException;
10import java.io.InputStream;
11import java.net.URL;
12import java.nio.file.Files;
13import java.nio.file.Path;
14import java.nio.file.Paths;
15import java.util.Enumeration;
16import java.util.Properties;
17
18import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
19
20/**
21 * A collection of utility methods for testing.
22 */
23public class TestUtil {
24
25 public static final String CONFIG_FILE = "test.properties";
26 private static final Logger LOGGER = Logger.getLogger("Tester");
27 private static boolean isConfigLoaded = false;
28 private static Properties config;
29
30 public static Properties getConfig() {
31 if(!isConfigLoaded) {
32 try(InputStream in = TestUtil.class.getClassLoader().getResourceAsStream(CONFIG_FILE)) {
33 config = new java.util.Properties();
34 config.load(in);
35 in.close();
36 isConfigLoaded = true;
37 } catch (IOException e) {
38 e.printStackTrace();
39 }
40 }
41 return config;
42 }
43
44 public static String combinePaths(String path1, String path2) {
45 File file1 = new File(path1);
46 File file2 = new File(file1, path2);
47 return file2.getPath();
48 }
49
50 public static void copyFile(String src, String dst) throws IOException {
51 Files.copy(Paths.get(src), Paths.get(dst), REPLACE_EXISTING);
52 }
53
54 /**
55 * Get the log file, which is assumed unique.
56 * */
57 public static String getLogFileName() {
58 Enumeration e = Logger.getRootLogger().getAllAppenders();
59 while (e.hasMoreElements()){
60 Appender app = (Appender)e.nextElement();
61 if (app instanceof FileAppender){
62 return ((FileAppender)app).getFile();
63 }
64 }
65 return null;
66 }
67
68 public static Path getAnswersFilePath(String name) {
69 URL givenAnswersURL = TestUtil.class.getClassLoader()
70 .getResource(name);
71 if(givenAnswersURL == null) throw new RuntimeException("Missing answers file:" + name);
72 return Paths.get(givenAnswersURL.getPath());
73 }
74
75 public static void logInfo(Object msg) {
76 LOGGER.info(msg);
77 }
78
79 public static void logDebug(Object msg) {
80 LOGGER.debug(msg);
81 }
82
83 public static void logError(Object msg) {
84 LOGGER.error(msg);
85 }
86
87 public static void logError(Object msg, Throwable t) {
88 LOGGER.error(msg, t);
89 }
90
91 public static final String NS = "http://example.org/test#%s";
92
93 public static IRI getEntityIRI(String name) {
94 return IRI.create(String.format(NS, name));
95 }
96
97}