@Test
public void testLocalhost() throws Exception {

    // Check that the URI generated by URI builder agrees with that generated by using URI directly
    final String scheme="https";
    final InetAddress host=InetAddress.getLocalHost();
    final String specials="/abcd!$&*()_-+.,=:;'~@[]?<>|#^%\"{}\\\u00a3`\u00ac\u00a6xyz"; // N.B. excludes space
    final URI uri = new URI(scheme, specials, host.getHostAddress(), 80, specials, specials, specials);
    final URI bld = URIBuilder.localhost()
            .setScheme(scheme)
            .setUserInfo(specials)
            .setPath(specials)
            .setCustomQuery(specials)
            .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());
}