diff --git a/publisher-sandbox/pom.xml b/publisher-sandbox/pom.xml index c284bf7..603d916 100644 --- a/publisher-sandbox/pom.xml +++ b/publisher-sandbox/pom.xml @@ -11,12 +11,17 @@ publisher-sandbox 1.0.0-SNAPSHOT jar - publisher framework for DE - API + Testing/validation sandbox emulating publishing org.iplantc.de publisher-api -${project.version} + ${project.version} + + + org.xeustechnologies + jcl-core + 2.7 diff --git a/publisher-sandbox/src/main/java/org/iplantc/de/publish/sandbox/PublisherEmulator.java b/publisher-sandbox/src/main/java/org/iplantc/de/publish/sandbox/PublisherEmulator.java index 0a8db52..f9dc783 100644 --- a/publisher-sandbox/src/main/java/org/iplantc/de/publish/sandbox/PublisherEmulator.java +++ b/publisher-sandbox/src/main/java/org/iplantc/de/publish/sandbox/PublisherEmulator.java @@ -4,12 +4,13 @@ package org.iplantc.de.publish.sandbox; import java.io.File; -import java.net.URL; +import java.net.URI; import java.util.ArrayList; import org.iplantc.de.publish.mechanism.api.exception.PublicationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.xeustechnologies.jcl.JarClassLoader; /** * Black box host of publishing mechanisms for testing and validation purposes @@ -20,6 +21,7 @@ public class PublisherEmulator { private SandboxConfiguration sandboxConfiguration; + private JarClassLoader jcl; public static final Logger log = LoggerFactory .getLogger(PublisherEmulator.class); @@ -71,20 +73,20 @@ public void init() throws PublicationException { } - public void initialize(String libDir) throws Exception { + public void loadPublisherClasses(String libDir) throws Exception { + File dependencyDirectory = new File(libDir); File[] files = dependencyDirectory.listFiles(); - ArrayList urls = new ArrayList(); + ArrayList uris = new ArrayList(); for (int i = 0; i < files.length; i++) { if (files[i].getName().endsWith(".jar")) { - urls.add(files[i].toURL()); - // urls.add(files[i].toURI().toURL()); + log.info("adding jar:{} to candidates", files[i]); + uris.add(files[i].toURI()); } - } /* - * classLoader = new JarFileClassLoader("Scheduler CL" + - * System.currentTimeMillis(), urls.toArray(new URL[urls.size()]), - * GFClassLoader.class.getClassLoader()); - */ + } + + log.info("creating jar class loader..."); + jcl = new JarClassLoader(); } } diff --git a/publisher-sandbox/src/test/java/org/iplantc/de/publish/sandbox/PublisherEmulatorTest.java b/publisher-sandbox/src/test/java/org/iplantc/de/publish/sandbox/PublisherEmulatorTest.java new file mode 100644 index 0000000..4c4c8a1 --- /dev/null +++ b/publisher-sandbox/src/test/java/org/iplantc/de/publish/sandbox/PublisherEmulatorTest.java @@ -0,0 +1,42 @@ +/** + * + */ +package org.iplantc.de.publish.sandbox; + +import static org.junit.Assert.fail; + +import java.util.Properties; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * @author Mike Conway - DICE + * + */ +public class PublisherEmulatorTest { + + private static Properties testingProperties; + + /** + * @throws java.lang.Exception + */ + @BeforeClass + public static void setUpBeforeClass() throws Exception { + // testingProperties = TestingProperties. + } + + /** + * @throws java.lang.Exception + */ + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Test + public void test() { + fail("Not yet implemented"); + } + +} diff --git a/publisher-sandbox/src/test/java/org/iplantc/de/publish/sandbox/PublisherTestingProperties.java b/publisher-sandbox/src/test/java/org/iplantc/de/publish/sandbox/PublisherTestingProperties.java new file mode 100644 index 0000000..c628d98 --- /dev/null +++ b/publisher-sandbox/src/test/java/org/iplantc/de/publish/sandbox/PublisherTestingProperties.java @@ -0,0 +1,55 @@ +/** + * + */ +package org.iplantc.de.publish.sandbox; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import org.irods.jargon.testutils.TestingUtilsException; + +/** + * Test properties and utils + * + * @author Mike Conway - DICE + * + */ +public class PublisherTestingProperties { + + public static final String TEST_PUBLISHER_DIR_PROPERTY = "driver.jar.dir"; + + /** + * + */ + public PublisherTestingProperties() { + } + + /** + * Load the properties that control various tests from the + * testing.properties file on the code path + * + * @return Properties class with the test values + * @throws TestingUtilsException + */ + public Properties getTestProperties() throws TestingUtilsException { + ClassLoader loader = this.getClass().getClassLoader(); + InputStream in = loader.getResourceAsStream("testing.properties"); + Properties properties = new Properties(); + + try { + properties.load(in); + } catch (IOException ioe) { + throw new TestingUtilsException("error loading test properties", + ioe); + } finally { + try { + in.close(); + } catch (Exception e) { + // ignore + } + } + return properties; + } + +}