### Question:
Urls { public static UrlBuilder http(String host) { return new UrlBuilder(Scheme.HTTP, host); } private  Urls(); @Nonnull static URI createURI(@Nonnull String fullUrl); @Nonnull static String escape(@Nonnull String url); static UrlBuilder http(String host); static UrlBuilder https(String host); @Nonnull static Url parse(String url);  }### Answer:
@Test public void uriInteropHash() { Url url = Urls.http("host.com") .path("/c#") .query("q", "#!") .fragment("#fragment#") .create(); URI uri = url.uri(); assertEquals("/c#", uri.getPath()); assertEquals("q=#!", uri.getQuery()); assertEquals("#fragment#", uri.getFragment()); }
@Test public void uriInteropIpv6() { Url url = Urls.http("[ff::00]") .create(); URI uri = url.uri(); assertEquals("[ff::]", uri.getHost()); }
@Test public void emptyPathIsAlwaysForwardSlash() { Url expected = Urls.http("host").path("/").create(); assertEquals(expected, Urls.http("host").create()); assertEquals(expected, Urls.http("host").path("").create()); assertEquals(expected, Urls.http("host").path("\\").create()); }
@Test public void host() throws Exception { Url url = Urls.http("host").create(); assertEquals("host", url.host().display()); url = Urls.http("10.10.0.1:9000").create(); assertEquals("10.10.0.1", url.host().display()); url = Urls.http("2001:0db8:0000:0000:0000:8a2e:0370:7334").create(); assertEquals("2001:db8::8a2e:370:7334", url.host().display()); url = Urls.http("[2001:db8::8a2e:370:7334]").create(); assertEquals("2001:db8::8a2e:370:7334", url.host().display()); url = Urls.http("[::A]:9000").create(); assertEquals("::a", url.host().display()); assertEquals(9000, url.port()); }
@Test public void host_removesUserInfo() { Url url = Urls.http("user:password@host.com").create(); assertEquals("host.com", url.host().display()); url = Urls.http("user@domain.com:password@host.com").create(); assertEquals("host.com", url.host().display()); }
@Test public void host_convertCharactersToLowerCase() { assertEquals("abcd", Urls.http("ABCD").create().host().display()); assertEquals("σ", Urls.http("Σ").create().host().display()); }
@Test public void host_idnEncodedAsPunycode() { Url url = Urls.http("bücher").create(); assertEquals("xn--bcher-kva", url.host().name()); assertEquals("bücher", url.host().display()); }
@Test public void host_builderTakesPunycodeOrUnicode() { Url unicode = Urls.http("bücher").create(); Url punycode = Urls.http("xn--bcher-kva").create(); assertEquals(unicode, punycode); assertEquals(unicode.hashCode(), punycode.hashCode()); }
@Test public void fragment() { Url url = Urls.http("host") .fragment("\uD83D\uDC36") .create(); assertEquals("\uD83D\uDC36", url.fragment()); }
@Test public void uriInteropAllCodepoints() { for (char point = 0; point < 0x100; point++) { String input = "" + point; Url url = Urls.http("host.com") .path("/" + input) .query(input, input) .fragment(input) .create(); assertEquals(url.toString(), url.uri().toString()); } }