### Question:
NetworkUtility { public static String urlForSocketAddress(final String scheme, final InetSocketAddress address) { String hostName = address.getHostName(); if (isUnspecifiedAddress(hostName)) { hostName = InetAddress.getLoopbackAddress().getHostName(); } if (hostName.contains(":")) { hostName = "[" + hostName + "]"; } return scheme + ": } private  NetworkUtility(); static boolean isIPv6Available(); static boolean isValidPort(final int port); static String urlForSocketAddress(final String scheme, final InetSocketAddress address); static boolean isNetworkInterfaceAvailable(final String ipAddress); static boolean isUnspecifiedAddress(final String ipAddress); static void checkPort(final int port, final String portTypeName); static final String INADDR_ANY; static final String INADDR6_ANY; }### Answer:
@Test public void urlForSocketAddressHandlesIPv6() { final InetSocketAddress ipv6All = new InetSocketAddress("::", 80); assertThat(NetworkUtility.urlForSocketAddress("http", ipv6All)).doesNotContain("::"); assertThat(NetworkUtility.urlForSocketAddress("http", ipv6All)) .doesNotContain("0:0:0:0:0:0:0:0"); final InetSocketAddress ipv6 = new InetSocketAddress("1:2:3:4:5:6:7:8", 80); assertThat(NetworkUtility.urlForSocketAddress("http", ipv6)).contains("[1:2:3:4:5:6:7:8]"); }