summaryrefslogtreecommitdiff
path: root/qpid/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
commit8777033b46c4686d0f1190a51c5d0633690b6fa6 (patch)
tree4dcb98bd777b3fadb64bfd002a4424e1608a8090 /qpid/java
parent7ce22edc39db3aca3ef5344a30344fdcbfc8bb90 (diff)
downloadqpid-python-8777033b46c4686d0f1190a51c5d0633690b6fa6.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@1525746 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
-rwxr-xr-xqpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
index 38a7b90ebd..c3b3090f1f 100755
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
+++ b/qpid/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)