Add test to check that builder behaves the same as URI
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1354115 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
518e6da29d
commit
caade0db95
|
@ -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());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue