Class TestPortUtil

  • public final class TestPortUtil
    extends Object
    TestPortUtil provides helper methods for working with ports in tests.
    Henning Treu - Initial contribution, Wouter Born - Increase reusability
    • Method Detail

      • findFreePort

        public static int findFreePort()
        Returns a free TCP/IP port number on localhost. Heavily inspired from org.eclipse.jdt.launching.SocketUtil (to avoid a dependency to JDT just because of this). Slightly improved with close() missing in JDT. And throws exception instead of returning -1.
        a free TCP/IP port number on localhost
        IllegalStateException - if unable to find a free port