public class AvailablePortFinderPropertiesFunction extends Object implements org.apache.camel.component.properties.PropertiesFunction
PropertiesFunction that reserves network ports and place them in a cache for reuse.
The first time the function is invoked for a given name, an unused network port is determined and cached
in an hash map with the given name as key so each time this function is invoked for the same name, the
previously discovered port will be returned.
This is useful for testing purpose where you can write a route like:
from("undertow:http://0.0.0.0:{{available-port:server-port}}")
.to("mock:result");
And then you can invoke with ProducerTemplate like:
template.sendBody("undertow:http://0.0.0.0:{{available-port:server-port}}", "the body");
Doing so avoid the need to compute the port and pass it to the various method or store it as a global
variable in the test class.AvailablePortFinder| Constructor and Description |
|---|
AvailablePortFinderPropertiesFunction() |
Apache Camel