HostAndIpValidator { public static boolean isValidIPv4(String ipAddress) { return ipAddress.matches(IPv4_ADDRESS); }  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 testIsValidIPv4() throws Exception { assertThat(isValidIPv4("10.10.10.10"), is(true)); assertThat(isValidIPv4("0.0.0.0"), is(true)); assertThat(isValidIPv4("127.0.0.1"), is(true)); assertThat(isValidIPv4("10.10.10"), is(false)); assertThat(isValidIPv4("10.10.10.10.10"), is(false)); assertThat(isValidIPv4("400:400:400:400"), is(false)); assertThat(isValidIPv4("abc.10.10.%%^"), is(false)); assertThat(isValidIPv4("10-10-10-10"), is(false)); }