@Test
public void testShouldCycleIpWhenPortsExhausted() {

  InetAddress expectedAddress = Inet4Resolver.inetAddress(AddressResolver.defaultStartingIp);
  int expectedPort = 65530;
  AddressResolver resolver = new NodePerPortResolver(expectedPort);
  for (int i = 0; i < 1000; i++) {
    InetSocketAddress address = (InetSocketAddress) resolver.get();
    assertThat(address.getAddress()).isEqualTo(expectedAddress);
    assertThat(address.getPort()).isEqualTo(expectedPort++);
    if (expectedPort == 65536) {
      expectedPort = 65530;
      expectedAddress =
          Inet4Resolver.inetAddress(Inet4Resolver.nextAddressBytes(expectedAddress.getAddress()));
    }
  }
}