Package org.apache.camel.quarkus.test
Class AvailablePortFinder
java.lang.Object
org.apache.camel.quarkus.test.AvailablePortFinder
Finds currently available server ports.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic intGets the next available TCP port.static intgetNextAvailable(AvailablePortFinder.Protocol protocol) Gets the next available port for the given protocol.static voidreserveNetworkPorts(String... names) Reserve a list of random and not in use TCP network ports and places them in Map.reserveNetworkPorts(Function<Integer, T> converter, String... names) Reserve a list of random and not in use TCP network ports and places them in Map.reserveNetworkPorts(AvailablePortFinder.Protocol protocol, String... names) Reserve a list of random and not in use network ports for the given protocol and places them in Map.reserveNetworkPorts(AvailablePortFinder.Protocol protocol, Function<Integer, T> converter, String... names) Reserve a list of random and not in use network ports for the given protocol and places them in Map.
-
Method Details
-
getNextAvailable
public static int getNextAvailable()Gets the next available TCP port.- Returns:
- the available port
- Throws:
IllegalStateException- if there are no ports available
-
getNextAvailable
Gets the next available port for the given protocol.- Parameters:
protocol- the network protocol to reserve the port for. Either TCP or UDP- Returns:
- the available port
- Throws:
IllegalStateException- if there are no ports available
-
reserveNetworkPorts
Reserve a list of random and not in use TCP network ports and places them in Map. -
reserveNetworkPorts
public static Map<String,Integer> reserveNetworkPorts(AvailablePortFinder.Protocol protocol, String... names) Reserve a list of random and not in use network ports for the given protocol and places them in Map. -
reserveNetworkPorts
Reserve a list of random and not in use TCP network ports and places them in Map. -
reserveNetworkPorts
public static <T> Map<String,T> reserveNetworkPorts(AvailablePortFinder.Protocol protocol, Function<Integer, T> converter, String... names) Reserve a list of random and not in use network ports for the given protocol and places them in Map. -
releaseReservedPorts
public static void releaseReservedPorts()
-