### Question:
InetSocketAddressFactory { public InetSocketAddress newInstance(String host) { int index = host.indexOf(':'); if (index == -1) { throw new IllegalArgumentException("No port found in host:" + host); } String hostname = host.substring(0, index); int port = Integer.parseInt(host.substring(index + 1)); return new InetSocketAddress(hostname, port); }  InetSocketAddress newInstance(String host);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void noPort() { factory.newInstance("localhost"); }
@Test public void typical() { InetSocketAddress address = factory.newInstance("localhost:1234"); assertThat(address.getHostName(), is("localhost")); assertThat(address.getPort(), is(1234)); }