You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2013/09/24 01:48:03 UTC

svn commit: r1525746 - /qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java

Author: robbie
Date: Mon Sep 23 23:48:02 2013
New Revision: 1525746

URL: http://svn.apache.org/r1525746
Log:
QPID-5161: make QBTC use the canonical working dir, and throw an exception if the relative path handling cant generate an appropriate path

Modified:
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java?rev=1525746&r1=1525745&r2=1525746&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java Mon Sep 23 23:48:02 2013
@@ -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 
     {
         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)



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org