hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1353363 - /httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java
Date Sun, 24 Jun 2012 23:48:50 GMT
Author: sebb
Date: Sun Jun 24 23:48:49 2012
New Revision: 1353363

URL: http://svn.apache.org/viewvc?rev=1353363&view=rev
Log:
Add tests for port and scheme copy

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java?rev=1353363&r1=1353362&r2=1353363&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java
Sun Jun 24 23:48:49 2012
@@ -26,6 +26,7 @@
 package org.apache.http.client.utils;
 
 import java.net.URI;
+import java.net.URISyntaxException;
 
 import org.apache.http.HttpHost;
 import org.junit.Assert;
@@ -40,7 +41,7 @@ public class TestURIUtils {
     private URI baseURI = URI.create("http://a/b/c/d;p?q");
 
     @Test
-    public void testRewite() throws Exception {
+    public void testRewrite() throws Exception {
         HttpHost target = new HttpHost("thathost", -1);
         Assert.assertEquals("http://thathost/stuff", URIUtils.rewriteURI(
                 URI.create("http://thishost/stuff"), target).toString());
@@ -65,6 +66,27 @@ public class TestURIUtils {
     }
 
     @Test
+    public void testRewritePort() throws Exception {
+        HttpHost target = new HttpHost("thathost", 8080); // port should be copied
+        Assert.assertEquals("http://thathost:8080/stuff", URIUtils.rewriteURI(
+                URI.create("http://thishost:80/stuff#crap"), target, true).toString());
+        Assert.assertEquals("http://thathost:8080/stuff#crap", URIUtils.rewriteURI(
+                URI.create("http://thishost:80/stuff#crap"), target, false).toString());
+        target = new HttpHost("thathost", -1); // input port should be dropped
+        Assert.assertEquals("http://thathost/stuff", URIUtils.rewriteURI(
+                URI.create("http://thishost:80/stuff#crap"), target, true).toString());
+        Assert.assertEquals("http://thathost/stuff#crap", URIUtils.rewriteURI(
+                URI.create("http://thishost:80/stuff#crap"), target, false).toString());
+    }
+
+    @Test
+    public void testRewriteScheme() throws Exception {
+        HttpHost target = new HttpHost("thathost", -1, "file"); // scheme should be copied
+        Assert.assertEquals("file://thathost/stuff", URIUtils.rewriteURI(
+                URI.create("http://thishost:80/stuff#crap"), target, true).toString());
+    }
+
+    @Test
     public void testResolve() {
         Assert.assertEquals("g:h", URIUtils.resolve(this.baseURI, "g:h").toString());
         Assert.assertEquals("http://a/b/c/g", URIUtils.resolve(this.baseURI, "g").toString());



Mime
View raw message