HostAndIpValidator { public static boolean isValidHost(String host) { return host.matches(VALID_HOSTNAME); }  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 testIsValidHost() throws Exception { assertThat(isValidHost("hostname"), is(true)); assertThat(isValidHost("host-name"), is(true)); assertThat(isValidHost("host-name123"), is(true)); assertThat(isValidHost("host_name"), is(false)); assertThat(isValidHost("host%%name"), is(false)); assertThat(isValidHost("host:name"), is(false)); }