TransportAddresses implements Iterable<InetSocketTransportAddress> { @Override public Iterator<InetSocketTransportAddress> iterator() { List<InetSocketTransportAddress> result = new LinkedList<>(); for (String node : nodes) { InetSocketTransportAddress transportAddress = transformToInetAddress(node); result.add(transportAddress); } return result.iterator(); } TransportAddresses(String[] nodes); @Override Iterator<InetSocketTransportAddress> iterator();  }
@Test(expected = IllegalArgumentException.class) public void throwsOnEmptyArray() throws Exception { new TransportAddresses(new String[] {}).iterator(); }
@Test(expected = IllegalArgumentException.class) public void throwsOnInvalidHostAndPortPair() throws Exception { new TransportAddresses(new String[] {"h1:1000", "h2"}).iterator(); }
@Test(expected = IllegalArgumentException.class) public void throwsOnInvalidPortValue() throws Exception { new TransportAddresses(new String[] {"h1:-1000"}).iterator(); }
@Test(expected = IllegalArgumentException.class) public void throwsOnPortNotANumber() throws Exception { new TransportAddresses(new String[] {"h1:dummy"}).iterator(); }
@Test(expected = IllegalArgumentException.class) public void throwsOnInvalidHostAndPortFormat() throws Exception { new TransportAddresses(new String[] {"h1:dummy:231"}).iterator(); }