@Test public void testGetNextAvailable_0args() { int result = AvailablePortFinder.getNextAvailable(); assertTrue( result > 0 ); }
public static int getNextAvailable() { ServerSocket serverSocket = null; try { serverSocket = new ServerSocket( 0 ); int port = serverSocket.getLocalPort(); serverSocket.close(); return port; } catch ( IOException ioe ) { throw new NoSuchElementException( ioe.getMessage() ); } }
AvailablePortFinder { public static int getNextAvailable() { ServerSocket serverSocket = null; try { serverSocket = new ServerSocket( 0 ); int port = serverSocket.getLocalPort(); serverSocket.close(); return port; } catch ( IOException ioe ) { throw new NoSuchElementException( ioe.getMessage() ); } } }
AvailablePortFinder { public static int getNextAvailable() { ServerSocket serverSocket = null; try { serverSocket = new ServerSocket( 0 ); int port = serverSocket.getLocalPort(); serverSocket.close(); return port; } catch ( IOException ioe ) { throw new NoSuchElementException( ioe.getMessage() ); } } private  AvailablePortFinder(); }
AvailablePortFinder { public static int getNextAvailable() { ServerSocket serverSocket = null; try { serverSocket = new ServerSocket( 0 ); int port = serverSocket.getLocalPort(); serverSocket.close(); return port; } catch ( IOException ioe ) { throw new NoSuchElementException( ioe.getMessage() ); } } private  AvailablePortFinder(); static Set<Integer> getAvailablePorts(); static int getNextAvailable(); static int getNextAvailable( int fromPort ); static boolean available( int port ); static Set<Integer> getAvailablePorts( int fromPort, int toPort ); }
AvailablePortFinder { public static int getNextAvailable() { ServerSocket serverSocket = null; try { serverSocket = new ServerSocket( 0 ); int port = serverSocket.getLocalPort(); serverSocket.close(); return port; } catch ( IOException ioe ) { throw new NoSuchElementException( ioe.getMessage() ); } } private  AvailablePortFinder(); static Set<Integer> getAvailablePorts(); static int getNextAvailable(); static int getNextAvailable( int fromPort ); static boolean available( int port ); static Set<Integer> getAvailablePorts( int fromPort, int toPort ); static final int MIN_PORT_NUMBER; static final int MAX_PORT_NUMBER; }