From 17bd9beaf7f358a44e5bf36a5855fe6727d506dc Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Tue, 10 May 2022 18:17:06 +0100 Subject: [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. --- .../ox/cs/pagoda/util/SimpleProgressBarTester.java | 16 ++++ .../java/uk/ac/ox/cs/pagoda/util/TestUtil.java | 97 ++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 src/test/java/uk/ac/ox/cs/pagoda/util/SimpleProgressBarTester.java create mode 100644 src/test/java/uk/ac/ox/cs/pagoda/util/TestUtil.java (limited to 'src/test/java/uk/ac/ox/cs/pagoda/util') 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 @@ +package uk.ac.ox.cs.pagoda.util; + +import org.testng.annotations.Test; + +public class SimpleProgressBarTester { + + @Test + public void test() throws InterruptedException { + SimpleProgressBar simpleProgressBar = new SimpleProgressBar("TestBar", 1000); + for(int i = 0; i < 1000; i++) { + simpleProgressBar.update(i); + Thread.sleep(10); + } + simpleProgressBar.dispose(); + } +} 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 @@ +package uk.ac.ox.cs.pagoda.util; + +import org.apache.log4j.Appender; +import org.apache.log4j.FileAppender; +import org.apache.log4j.Logger; +import org.semanticweb.owlapi.model.IRI; + +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; + +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; + +/** + * A collection of utility methods for testing. + */ +public class TestUtil { + + public static final String CONFIG_FILE = "test.properties"; + private static final Logger LOGGER = Logger.getLogger("Tester"); + private static boolean isConfigLoaded = false; + private static Properties config; + + public static Properties getConfig() { + if(!isConfigLoaded) { + try(InputStream in = TestUtil.class.getClassLoader().getResourceAsStream(CONFIG_FILE)) { + config = new java.util.Properties(); + config.load(in); + in.close(); + isConfigLoaded = true; + } catch (IOException e) { + e.printStackTrace(); + } + } + return config; + } + + public static String combinePaths(String path1, String path2) { + File file1 = new File(path1); + File file2 = new File(file1, path2); + return file2.getPath(); + } + + public static void copyFile(String src, String dst) throws IOException { + Files.copy(Paths.get(src), Paths.get(dst), REPLACE_EXISTING); + } + + /** + * Get the log file, which is assumed unique. + * */ + public static String getLogFileName() { + Enumeration e = Logger.getRootLogger().getAllAppenders(); + while (e.hasMoreElements()){ + Appender app = (Appender)e.nextElement(); + if (app instanceof FileAppender){ + return ((FileAppender)app).getFile(); + } + } + 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()); + } + + public static void logInfo(Object msg) { + LOGGER.info(msg); + } + + public static void logDebug(Object msg) { + LOGGER.debug(msg); + } + + public static void logError(Object msg) { + LOGGER.error(msg); + } + + public static void logError(Object msg, Throwable t) { + LOGGER.error(msg, t); + } + + public static final String NS = "http://example.org/test#%s"; + + public static IRI getEntityIRI(String name) { + return IRI.create(String.format(NS, name)); + } + +} -- cgit v1.2.3