### Question:
HostPort { public static HostPort valueOf(String hostPort) throws NumberFormatException, IllegalArgumentException { final int sepIndex = hostPort.lastIndexOf(':'); if ((hostPort.charAt(0) == '[' && hostPort.charAt(hostPort.length() - 1) == ']') || sepIndex == -1) { throw new IllegalArgumentException( "Invalid host/port string: no network port was provided in '" + hostPort + "'"); } else if (sepIndex == 0) { throw new IllegalArgumentException( "Invalid host/port string: no host name was provided in '" + hostPort + "'"); } else if (hostPort.lastIndexOf(':', sepIndex - 1) != -1 && (hostPort.charAt(0) != '[' || hostPort.charAt(sepIndex - 1) != ']')) { throw new IllegalArgumentException( "Invalid host/port string: Suspected IPv6 address provided in '" + hostPort + "'. The only allowed format for providing IPv6 " + "addresses is '[IPv6 address]:port'"); } String host = hostPort.substring(0, sepIndex); int port = Integer.parseInt(hostPort.substring(sepIndex + 1)); return new HostPort(host, port); } private  HostPort(int port);  HostPort(String host, int port); static boolean isLocalAddress(InetAddress address); static HostPort allAddresses(int port); static HostPort localAddress(int port); static HostPort valueOf(String hostPort); String getHost(); int getPort(); boolean isLocalAddress(); InetSocketAddress toInetSocketAddress(); @Override String toString(); boolean isEquivalentTo(final HostPort other); @Override boolean equals(Object obj); @Override int hashCode(); static final String WILDCARD_ADDRESS; }### Answer:
@Test(expectedExceptions = IllegalArgumentException.class) public void valueOfNoPort() { HostPort.valueOf("host"); }
@Test(expectedExceptions = IllegalArgumentException.class) public void valueOfNoHost() { HostPort.valueOf(":389"); }
@Test(expectedExceptions = NumberFormatException.class) public void valueOfPortNotANumber() { HostPort.valueOf("host:port"); }
@Test(expectedExceptions = IllegalArgumentException.class) public void valueOfPortNumberTooSmall() { HostPort.valueOf("host:-1"); }
@Test(expectedExceptions = IllegalArgumentException.class) public void valueOfPortNumberTooBig() { HostPort.valueOf("host:99999999"); }