summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2013-09-23 23:48:02 +0000
committerRobert Gemmell <robbie@apache.org>2013-09-23 23:48:02 +0000
commit2d19a6f1bf9796645d17a2f60313e99328643d63 (patch)
treea9d135360cd5f739da35537499a2a8bc45df5c6f /java
parent84b256fa852086ae84cba9c595bf8794d2413e40 (diff)
downloadqpid-python-2d19a6f1bf9796645d17a2f60313e99328643d63.tar.gz
QPID-5161: make QBTC use the canonical working dir, and throw an exception if the relative path handling cant generate an appropriate path
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1525746 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rwxr-xr-xjava/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java b/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
index 38a7b90ebd..c3b3090f1f 100755
--- a/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
@@ -19,6 +19,7 @@ package org.apache.qpid.test.utils;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.PrintStream;
import java.net.URI;
import java.net.URISyntaxException;
@@ -643,7 +644,25 @@ public class QpidBrokerTestCase extends QpidTestCase
{
File configLocation = new File(file);
File workingDirectory = new File(System.getProperty("user.dir"));
- return configLocation.getAbsolutePath().replace(workingDirectory.getAbsolutePath(), "").substring(1);
+
+ _logger.debug("Converting path to be relative to working directory: " + file);
+
+ try
+ {
+ if(!configLocation.getAbsolutePath().startsWith(workingDirectory.getCanonicalPath()))
+ {
+ throw new RuntimeException("Provided path is not a child of the working directory: " + workingDirectory.getCanonicalPath());
+ }
+
+ String substring = configLocation.getAbsolutePath().replace(workingDirectory.getCanonicalPath(), "").substring(1);
+ _logger.debug("Converted relative path: " + substring);
+
+ return substring;
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Problem while converting to relative path", e);
+ }
}
protected String saveTestConfiguration(int port, TestBrokerConfiguration testConfiguration)