HostAndIpValidator { public static boolean isValidIPv6(String ipAddress) { return isValidIPv6(ipAddress, false) || isValidIPv6(ipAddress, true); }  static boolean isValidHost(String host); static boolean isValidIPv4(String ipAddress); static boolean isValidIPv4Cidr(String cidr); static boolean isValidIPv6(String ipAddress); static boolean isValidIPv6(String ipAddress, boolean brackets); static boolean isValidIPv6Cidr(String cidr); static String getIPv4Suffix(); static String getIPv6Suffix();  }
@Test public void testIsValidIPv6() throws Exception { assertThat(isValidIPv6("2001:db8:a0b:12f0:0:0:0:1", false), is(true)); assertThat(isValidIPv6("2001:db8:a0b:12f0::1", false), is(true)); assertThat(isValidIPv6("::1", false), is(true)); assertThat(isValidIPv6("2001:db8::", false), is(true)); assertThat(isValidIPv6("[2001:db8::]", true), is(true)); assertThat(isValidIPv6("aaaa:aaaa:aaaa:aaaa", false), is(false)); assertThat(isValidIPv6("aaaa:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa", false), is(false)); assertThat(isValidIPv6("2001:db8:a0b::12f0::1", false), is(false)); assertThat(isValidIPv6("2001:db8:a0b:12f0:::1", false), is(false)); assertThat(isValidIPv6("[2001:db8:a0b:12f0:::1]", true), is(false)); }