Skip to content
This repository has been archived by the owner on Jul 3, 2018. It is now read-only.

Commit

Permalink
#2 adding testing framework for publisher sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-conway committed May 31, 2016
1 parent 471a056 commit e57c3e0
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 12 deletions.
9 changes: 7 additions & 2 deletions publisher-sandbox/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@
<artifactId>publisher-sandbox</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>publisher framework for DE - API</name>
<name>Testing/validation sandbox emulating publishing</name>
<dependencies>
<dependency>
<groupId>org.iplantc.de</groupId>
<artifactId>publisher-api</artifactId>
<version>${project.version}</version>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.xeustechnologies</groupId>
<artifactId>jcl-core</artifactId>
<version>2.7</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,6 +21,7 @@
public class PublisherEmulator {

private SandboxConfiguration sandboxConfiguration;
private JarClassLoader jcl;

public static final Logger log = LoggerFactory
.getLogger(PublisherEmulator.class);
Expand Down Expand Up @@ -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<URL> urls = new ArrayList<URL>();
ArrayList<URI> uris = new ArrayList<URI>();
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();
}

}
Original file line number Diff line number Diff line change
@@ -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");
}

}
Original file line number Diff line number Diff line change
@@ -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 <code>Properties</code> 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;
}

}

0 comments on commit e57c3e0

Please sign in to comment.