hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1354115 - /httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java
Date Tue, 26 Jun 2012 17:17:06 GMT
Author: sebb
Date: Tue Jun 26 17:17:05 2012
New Revision: 1354115

URL: http://svn.apache.org/viewvc?rev=1354115&view=rev
Log:
Add test to check that builder behaves the same as URI

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

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java?rev=1354115&r1=1354114&r2=1354115&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java
Tue Jun 26 17:17:05 2012
@@ -164,4 +164,33 @@ public class TestURIBuilder {
         Assert.assertEquals(uri1, uri2);
     }
 
+    @Test
+    public void testAgainstURI() throws Exception {
+        // Check that the URI generated by URI builder agrees with that generated by using
URI directly
+        final String scheme="https";
+        final String host="localhost";
+        final String specials="/abcd!$&*()_-+.,=:;'~@[]?<>|#^%\"{}\\£`¬¦xyz";
// N.B. excludes space
+        URI uri = new URI(scheme, specials, host, 80, specials, specials, specials);
+
+        URI bld = new URIBuilder()
+                .setScheme(scheme)
+                .setHost(host)
+                .setUserInfo(specials)
+                .setPath(specials)
+                .addParameter(specials, null) // hack to bypass parsing of query data
+                .setFragment(specials)
+                .build();
+
+        Assert.assertEquals(uri.getHost(), bld.getHost());
+        
+        Assert.assertEquals(uri.getUserInfo(), bld.getUserInfo());
+        
+        Assert.assertEquals(uri.getPath(), bld.getPath());
+
+        Assert.assertEquals(uri.getQuery(), bld.getQuery());
+
+        Assert.assertEquals(uri.getFragment(), bld.getFragment());
+
+    }
+
 }



Mime
View raw message