@Test
public void testIsValidHostname() throws Exception {

  // Valid host names
  Assert.assertTrue(HostUtils.isValidHostname("localhost"));
  Assert.assertTrue(HostUtils.isValidHostname("localhost.localdomain"));
  Assert.assertTrue(HostUtils.isValidHostname("host1.example.com"));
  Assert.assertTrue(HostUtils.isValidHostname("Host1.eXample.coM"));
  Assert.assertTrue(HostUtils.isValidHostname("host-name.example.com"));
  Assert.assertTrue(HostUtils.isValidHostname("123.456.789"));
  Assert.assertTrue(HostUtils.isValidHostname("host-123-name.ex4mpl3.c0m"));
  // Invalid host names
  Assert.assertFalse(HostUtils.isValidHostname("host_name.example.com"));
  Assert.assertFalse(HostUtils.isValidHostname("host;name.example.com"));
  Assert.assertFalse(HostUtils.isValidHostname("host?name.example.com"));
  Assert.assertFalse(HostUtils.isValidHostname("host@name.example.com"));
  Assert.assertFalse(HostUtils.isValidHostname("host=name.example.com"));
  Assert.assertFalse(HostUtils.isValidHostname("host+name.example.com"));
  Assert.assertFalse(HostUtils.isValidHostname("host)name).example.com"));
}