diff options
| author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2022-05-10 18:17:06 +0100 |
|---|---|---|
| committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2022-05-11 12:34:47 +0100 |
| commit | 17bd9beaf7f358a44e5bf36a5855fe6727d506dc (patch) | |
| tree | 47e9310a0cff869d9ec017dcb2c81876407782c8 /src/test/java/uk/ac/ox/cs/pagoda/util | |
| parent | 8651164cd632a5db310b457ce32d4fbc97bdc41c (diff) | |
| download | ACQuA-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 'src/test/java/uk/ac/ox/cs/pagoda/util')
| -rw-r--r-- | src/test/java/uk/ac/ox/cs/pagoda/util/SimpleProgressBarTester.java | 16 | ||||
| -rw-r--r-- | src/test/java/uk/ac/ox/cs/pagoda/util/TestUtil.java | 97 |
2 files changed, 113 insertions, 0 deletions
diff --git a/src/test/java/uk/ac/ox/cs/pagoda/util/SimpleProgressBarTester.java b/src/test/java/uk/ac/ox/cs/pagoda/util/SimpleProgressBarTester.java new file mode 100644 index 0000000..3de30e4 --- /dev/null +++ b/src/test/java/uk/ac/ox/cs/pagoda/util/SimpleProgressBarTester.java | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.util; | ||
| 2 | |||
| 3 | import org.testng.annotations.Test; | ||
| 4 | |||
| 5 | public class SimpleProgressBarTester { | ||
| 6 | |||
| 7 | @Test | ||
| 8 | public void test() throws InterruptedException { | ||
| 9 | SimpleProgressBar simpleProgressBar = new SimpleProgressBar("TestBar", 1000); | ||
| 10 | for(int i = 0; i < 1000; i++) { | ||
| 11 | simpleProgressBar.update(i); | ||
| 12 | Thread.sleep(10); | ||
| 13 | } | ||
| 14 | simpleProgressBar.dispose(); | ||
| 15 | } | ||
| 16 | } | ||
diff --git a/src/test/java/uk/ac/ox/cs/pagoda/util/TestUtil.java b/src/test/java/uk/ac/ox/cs/pagoda/util/TestUtil.java new file mode 100644 index 0000000..c7f024a --- /dev/null +++ b/src/test/java/uk/ac/ox/cs/pagoda/util/TestUtil.java | |||
| @@ -0,0 +1,97 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.util; | ||
| 2 | |||
| 3 | import org.apache.log4j.Appender; | ||
| 4 | import org.apache.log4j.FileAppender; | ||
| 5 | import org.apache.log4j.Logger; | ||
| 6 | import org.semanticweb.owlapi.model.IRI; | ||
| 7 | |||
| 8 | import java.io.File; | ||
| 9 | import java.io.IOException; | ||
| 10 | import java.io.InputStream; | ||
| 11 | import java.net.URL; | ||
| 12 | import java.nio.file.Files; | ||
| 13 | import java.nio.file.Path; | ||
| 14 | import java.nio.file.Paths; | ||
| 15 | import java.util.Enumeration; | ||
| 16 | import java.util.Properties; | ||
| 17 | |||
| 18 | import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; | ||
| 19 | |||
| 20 | /** | ||
| 21 | * A collection of utility methods for testing. | ||
| 22 | */ | ||
| 23 | public 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 | } | ||
