### Question:
NetUtil { public static Host parseHost(String str) { return parseHost(str, 0); }  static Host parseHost(String str); static Host parseHost(String str, int defaultPort); static List<Host> parseHostList(String str); static boolean hostNameMatch(String hostname, List<Host> list); static boolean hostNameMatch(InetAddress host, List<Host> list); static byte[] getInetAddressAsHex(InetAddress addr); static InetAddress getInetAddressFromHex(String hex); static String inferDomain(); static String getBaseDomain(String host); static String getBaseDomain(String host, boolean tight); static String resolveDottedIP(String ip); static long ipToLong(String ip); static String longToIp(long i); static final byte hex; }### Answer:
@Test public void testParseHost() { NetUtil.Host host = NetUtil.parseHost("host:80"); assertEquals("host", host.name); assertEquals(80, host.port); host = NetUtil.parseHost("host"); assertEquals("host", host.name); assertEquals(0, host.port); host = NetUtil.parseHost("host", 80); assertEquals("host", host.name); assertEquals(80, host.port); host = NetUtil.parseHost("host:80", 8000); assertEquals("host", host.name); assertEquals(80, host.port); host = NetUtil.parseHost("host:"); assertEquals("host", host.name); assertEquals(0, host.port); host = NetUtil.parseHost(":80"); assertEquals("80", host.name); assertEquals(0, host.port); }
@Test(expected = NumberFormatException.class) public void testParseHostInvalidPort() { NetUtil.parseHost("host:port"); }