You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2014/03/07 16:53:41 UTC

svn commit: r1575298 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java test/src/org/apache/jmeter/protocol/http/util/TestHTTPUtils.java

Author: sebb
Date: Fri Mar  7 15:53:41 2014
New Revision: 1575298

URL: http://svn.apache.org/r1575298
Log:
Fix documentation; add related tests

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java
    jmeter/trunk/test/src/org/apache/jmeter/protocol/http/util/TestHTTPUtils.java

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java?rev=1575298&r1=1575297&r2=1575298&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java Fri Mar  7 15:53:41 2014
@@ -91,11 +91,12 @@ public class ConversionUtils {
     }
 
     /**
-     * Generate a relative URL, allowing for extraneous leading "../" segments.
+     * Generate an absolute URL from a possibly relative location,
+     * allowing for extraneous leading "../" segments.
      * The Java {@link URL#URL(URL, String)} constructor does not remove these.
      *
-     * @param baseURL
-     * @param location relative location, possibly with extraneous leading "../"
+     * @param baseURL the base URL which is used to resolve missing protocol/host in the location
+     * @param location the location, possibly with extraneous leading "../"
      * @return URL with extraneous ../ removed
      * @throws MalformedURLException
      */

Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/util/TestHTTPUtils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/util/TestHTTPUtils.java?rev=1575298&r1=1575297&r2=1575298&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/util/TestHTTPUtils.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/util/TestHTTPUtils.java Fri Mar  7 15:53:41 2014
@@ -61,6 +61,15 @@ public class TestHTTPUtils extends TestC
         assertEquals(new URL("http://192.168.0.1/a/b/c/d"),ConversionUtils.makeRelativeURL(base,"./d"));
     }
 
+    // Test that location urls with a protocol are passed unchanged
+    public void testMakeRelativeURL3() throws Exception {
+        URL base = new URL("http://ahost.invalid/a/b/c");
+        assertEquals(new URL("http://host.invalid/e"),ConversionUtils.makeRelativeURL(base ,"http://host.invalid/e"));
+        assertEquals(new URL("https://host.invalid/e"),ConversionUtils.makeRelativeURL(base ,"https://host.invalid/e"));
+        assertEquals(new URL("http://host.invalid:8081/e"),ConversionUtils.makeRelativeURL(base ,"http://host.invalid:8081/e"));
+        assertEquals(new URL("https://host.invalid:8081/e"),ConversionUtils.makeRelativeURL(base ,"https://host.invalid:8081/e"));
+    }
+
     public void testRemoveSlashDotDot()
     {
         assertEquals("/path/", ConversionUtils.removeSlashDotDot("/path/"));