@Test public void getNextAvailablePort_retries_to_get_available_port_when_port_has_already_been_allocated() { NetworkUtils.PortAllocator portAllocator = mock(NetworkUtils.PortAllocator.class); when(portAllocator.getAvailable(any(InetAddress.class))).thenReturn(9_000, 9_000, 9_000, 9_100); InetAddress address = getLoopbackAddress(); assertThat(getNextAvailablePort(address, portAllocator)).isEqualTo(9_000); assertThat(getNextAvailablePort(address, portAllocator)).isEqualTo(9_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);  }