### Question:
NetUtil { public static boolean isValidIpV6Address(String ip) { return isValidIpV6Address((CharSequence) ip); } private  NetUtil(); static boolean isIpV4StackPreferred(); static boolean isIpV6AddressesPreferred(); static byte[] createByteArrayFromIpAddressString(String ipAddressString); static String intToIpAddress(int i); static String bytesToIpAddress(byte[] bytes); static String bytesToIpAddress(byte[] bytes, int offset, int length); static boolean isValidIpV6Address(String ip); static boolean isValidIpV6Address(CharSequence ip); static boolean isValidIpV4Address(CharSequence ip); static boolean isValidIpV4Address(String ip); static Inet6Address getByName(CharSequence ip); static Inet6Address getByName(CharSequence ip, boolean ipv4Mapped); static String toSocketAddressString(InetSocketAddress addr); static String toSocketAddressString(String host, int port); static String toAddressString(InetAddress ip); static String toAddressString(InetAddress ip, boolean ipv4Mapped); static String getHostname(InetSocketAddress addr); static final Inet4Address LOCALHOST4; static final Inet6Address LOCALHOST6; static final InetAddress LOCALHOST; static final NetworkInterface LOOPBACK_IF; static final int SOMAXCONN; }### Answer:
@Test public void testIsValidIpV6Address() { for (String host : validIpV6Hosts.keySet()) { assertTrue(host, isValidIpV6Address(host)); if (host.charAt(0) != '[' && !host.contains("%")) { assertNotNull(host, getByName(host, true)); String hostMod = '[' + host + ']'; assertTrue(hostMod, isValidIpV6Address(hostMod)); hostMod = host + '%'; assertTrue(hostMod, isValidIpV6Address(hostMod)); hostMod = host + "%eth1"; assertTrue(hostMod, isValidIpV6Address(hostMod)); hostMod = '[' + host + "%]"; assertTrue(hostMod, isValidIpV6Address(hostMod)); hostMod = '[' + host + "%1]"; assertTrue(hostMod, isValidIpV6Address(hostMod)); hostMod = '[' + host + "]%"; assertFalse(hostMod, isValidIpV6Address(hostMod)); hostMod = '[' + host + "]%1"; assertFalse(hostMod, isValidIpV6Address(hostMod)); } } for (String host : invalidIpV6Hosts.keySet()) { assertFalse(host, isValidIpV6Address(host)); assertNull(host, getByName(host)); String hostMod = '[' + host + ']'; assertFalse(hostMod, isValidIpV6Address(hostMod)); hostMod = host + '%'; assertFalse(hostMod, isValidIpV6Address(hostMod)); hostMod = host + "%eth1"; assertFalse(hostMod, isValidIpV6Address(hostMod)); hostMod = '[' + host + "%]"; assertFalse(hostMod, isValidIpV6Address(hostMod)); hostMod = '[' + host + "%1]"; assertFalse(hostMod, isValidIpV6Address(hostMod)); hostMod = '[' + host + "]%"; assertFalse(hostMod, isValidIpV6Address(hostMod)); hostMod = '[' + host + "]%1"; assertFalse(hostMod, isValidIpV6Address(hostMod)); hostMod = host + ']'; assertFalse(hostMod, isValidIpV6Address(hostMod)); hostMod = '[' + host; assertFalse(hostMod, isValidIpV6Address(hostMod)); } }