diff --git a/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java b/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java index 9e1975d21..fc2630156 100644 --- a/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java +++ b/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java @@ -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()); + + } + }