You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by bd...@apache.org on 2011/02/11 16:37:42 UTC
svn commit: r1069843 - in /incubator/stanbol/trunk:
commons/testing/jarexec/src/main/java/org/apache/stanbol/commons/testing/jarexec/JarExecutor.java
enhancer/integration-tests/pom.xml
Author: bdelacretaz
Date: Fri Feb 11 15:37:42 2011
New Revision: 1069843
URL: http://svn.apache.org/viewvc?rev=1069843&view=rev
Log:
STANBOL-77 - remove hardcoded values in JarExecutor
Modified:
incubator/stanbol/trunk/commons/testing/jarexec/src/main/java/org/apache/stanbol/commons/testing/jarexec/JarExecutor.java
incubator/stanbol/trunk/enhancer/integration-tests/pom.xml
Modified: incubator/stanbol/trunk/commons/testing/jarexec/src/main/java/org/apache/stanbol/commons/testing/jarexec/JarExecutor.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/testing/jarexec/src/main/java/org/apache/stanbol/commons/testing/jarexec/JarExecutor.java?rev=1069843&r1=1069842&r2=1069843&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/testing/jarexec/src/main/java/org/apache/stanbol/commons/testing/jarexec/JarExecutor.java (original)
+++ incubator/stanbol/trunk/commons/testing/jarexec/src/main/java/org/apache/stanbol/commons/testing/jarexec/JarExecutor.java Fri Feb 11 15:37:42 2011
@@ -40,7 +40,9 @@ public class JarExecutor {
public static final int DEFAULT_PORT = 8765;
public static final String PROP_PREFIX = "jar.executor.";
public static final String PROP_SERVER_PORT = PROP_PREFIX + "server.port";
-
+ public static final String PROP_JAR_FOLDER = PROP_PREFIX + "jar.folder";
+ public static final String PROP_JAR_NAME_REGEXP = PROP_PREFIX + "jar.name.regexp";
+
@SuppressWarnings("serial")
public static class ExecutorException extends Exception {
ExecutorException(String reason) {
@@ -65,6 +67,14 @@ public class JarExecutor {
}
return instance;
}
+
+ private String requireSystemProperty(String name) throws ExecutorException {
+ final String result = System.getProperty(name);
+ if(result == null || result.trim().length() == 0) {
+ throw new ExecutorException("Missing system property: " + name);
+ }
+ return result.trim();
+ }
/** Build a JarExecutor, locate the jar to run, etc */
private JarExecutor(Properties config) throws ExecutorException {
@@ -73,13 +83,17 @@ public class JarExecutor {
String str = config.getProperty(PROP_SERVER_PORT);
serverPort = str == null ? DEFAULT_PORT : Integer.valueOf(str);
- // TODO make those configurable
javaExecutable = isWindows ? "java.exe" : "java";
- final File jarFolder = new File("./target/dependency");
- final Pattern jarPattern = Pattern.compile("org.apache.stanbol.*full.*jar$");
+ final File jarFolder = new File(requireSystemProperty(PROP_JAR_FOLDER));
+ final Pattern jarPattern = Pattern.compile(requireSystemProperty(PROP_JAR_NAME_REGEXP));
// Find executable jar
final String [] candidates = jarFolder.list();
+ if(candidates == null) {
+ throw new ExecutorException(
+ "No files found in jar folder specified by "
+ + PROP_JAR_FOLDER + " property: " + jarFolder.getAbsolutePath());
+ }
File f = null;
if(candidates != null) {
for(String filename : candidates) {
Modified: incubator/stanbol/trunk/enhancer/integration-tests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/integration-tests/pom.xml?rev=1069843&r1=1069842&r2=1069843&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/integration-tests/pom.xml (original)
+++ incubator/stanbol/trunk/enhancer/integration-tests/pom.xml Fri Feb 11 15:37:42 2011
@@ -124,6 +124,8 @@
<test.server.url>${test.server.url}</test.server.url>
<jar.executor.server.port>${server.port}</jar.executor.server.port>
<jar.executor.vm.options>${jar.executor.vm.options}</jar.executor.vm.options>
+ <jar.executor.jar.folder>${project.basedir}/target/dependency</jar.executor.jar.folder>
+ <jar.executor.jar.name.regexp>org.apache.stanbol.*full.*jar$</jar.executor.jar.name.regexp>
<keepJarRunning>${keepJarRunning}</keepJarRunning>
<server.ready.timeout.seconds>60</server.ready.timeout.seconds>
<server.ready.path.1>/:stanbol.css</server.ready.path.1>