Package org.openhab.core.test
Class TestPortUtil
java.lang.Object
org.openhab.core.test.TestPortUtil
TestPortUtil
provides helper methods for working with ports in tests.- Author:
- Henning Treu - Initial contribution, Wouter Born - Increase reusability
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
Returns a free TCP/IP port number on localhost.
-
Method Details
-
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.- Returns:
- a free TCP/IP port number on localhost
- Throws:
IllegalStateException
- if unable to find a free port
-