@Test public void getNextAvailablePort_never_returns_the_same_port_in_current_jvm() { Set<Integer> ports = new HashSet<>(); for (int i = 0; i < 100; i++) { int port = getNextAvailablePort(getLoopbackAddress()); assertThat(port).isGreaterThan(1023); ports.add(port); } assertThat(ports).hasSize(100); }
public static int getNextAvailablePort(InetAddress address) { return getNextAvailablePort(address, PortAllocator.INSTANCE); }
NetworkUtils { public static int getNextAvailablePort(InetAddress address) { return getNextAvailablePort(address, PortAllocator.INSTANCE); } }
NetworkUtils { public static int getNextAvailablePort(InetAddress address) { return getNextAvailablePort(address, PortAllocator.INSTANCE); } private  NetworkUtils(); }
NetworkUtils { public static int getNextAvailablePort(InetAddress address) { return getNextAvailablePort(address, PortAllocator.INSTANCE); } private  NetworkUtils(); static InetAddress getLocalhost(); static InetAddress getInetAddressByName(String name); static int getNextAvailablePort(InetAddress address); }
NetworkUtils { public static int getNextAvailablePort(InetAddress address) { return getNextAvailablePort(address, PortAllocator.INSTANCE); } private  NetworkUtils(); static InetAddress getLocalhost(); static InetAddress getInetAddressByName(String name); static int getNextAvailablePort(InetAddress address);  }