try {
if (rootDir != null)
- System.setProperty(AntConstants.ROOT_DIR_PROPERTY, rootDir
- .getURL().toString());
+ setSystemPropertyForRes(AntConstants.ROOT_DIR_PROPERTY, rootDir);
if (confDir != null)
- System.setProperty(AntConstants.CONF_DIR_PROPERTY, confDir
- .getURL().toString());
+ setSystemPropertyForRes(AntConstants.CONF_DIR_PROPERTY, confDir);
if (workDir != null)
System.setProperty(AntConstants.WORK_DIR_PROPERTY, workDir
.getCanonicalPath());
}
}
+ /**
+ * Set property as an absolute file path if the resource can be located on
+ * the file system, or as an url.
+ */
+ private void setSystemPropertyForRes(String key, Resource res)
+ throws IOException {
+ String value = null;
+ try {
+ value = res.getFile().getCanonicalPath();
+ } catch (IOException e) {
+ value = res.getURL().toString();
+ }
+ System.setProperty(key, value);
+ }
+
protected ConfigurableApplicationContext createExecutionContext(
SlcExecution slcExecution) {
try {
--- /dev/null
+package org.argeo.slc.ant.unit;
+
+import junit.framework.TestCase;
+
+import org.argeo.slc.ant.AntExecutionContext;
+import org.argeo.slc.cli.DefaultSlcRuntime;
+import org.argeo.slc.runtime.SlcExecutionOutput;
+
+public abstract class AntSlcApplicationTestCase extends TestCase implements
+ SlcExecutionOutput<AntExecutionContext> {
+
+ /** To be overriden */
+ public void postExecution(AntExecutionContext executionContext) {
+
+ }
+
+ protected String getRootDir() {
+ return System.getProperty("slc.rootDir", "src/main/slc/root");
+ }
+
+ protected String getAbsoluteScript(String relative) {
+ return getRootDir() + '/' + relative;
+ }
+
+ protected void execute(String relativeScript) {
+ execute(relativeScript, null);
+ }
+
+ protected void execute(String relativeScript, String targets) {
+ new DefaultSlcRuntime().executeScript(
+ getAbsoluteScript(relativeScript), targets, this);
+ }
+
+}
+++ /dev/null
-package org.argeo.slc.ant.unit;
-
-import junit.framework.TestCase;
-
-import org.argeo.slc.ant.AntExecutionContext;
-import org.argeo.slc.cli.DefaultSlcRuntime;
-import org.argeo.slc.runtime.SlcExecutionOutput;
-
-public abstract class SlcAntAppliTestCase extends TestCase implements
- SlcExecutionOutput<AntExecutionContext> {
-
- /** To be overriden */
- public void postExecution(AntExecutionContext executionContext) {
-
- }
-
- protected String getRootDir() {
- return System.getProperty("slc.rootDir", "src/main/slc/root");
- }
-
- protected String getAbsoluteScript(String relative) {
- return getRootDir() + '/' + relative;
- }
-
- protected void execute(String relativeScript) {
- execute(relativeScript, null);
- }
-
- protected void execute(String relativeScript, String targets) {
- new DefaultSlcRuntime().executeScript(
- getAbsoluteScript(relativeScript), targets, this);
- }
-
-}
try {
Resource slcRootFile = currDir.createRelative(SLC_ROOT_FILE_NAME);
if (slcRootFile.exists()) {
+ if (log.isDebugEnabled())
+ log.debug("Found SLC root file: " + slcRootFile);
return slcRootFile;
} else {
String currPath = currDir.getURL().getPath();