|
Spring Integration | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.integration.test.util.SocketUtils
public final class SocketUtils
Contains several socket-specific utility methods. For example, you may have test cases that require an open port. Rather than hard-coding the relevant port, it will be better to use methods from this utility class to automatically select an open port, therefore improving the portability of your test-cases across systems.
Field Summary | |
---|---|
static int |
DEFAULT_PORT_RANGE_MAX
|
static int |
DEFAULT_PORT_RANGE_MIN
|
Constructor Summary | |
---|---|
SocketUtils()
The constructor is intentionally public. |
Method Summary | |
---|---|
static int |
findAvailableServerSocket()
Determines a free available server socket (port) using an automatically chosen start seed port. |
static int |
findAvailableServerSocket(int seed)
Determines a free available server socket (port) using the 'seed' value as the starting port. |
static java.util.List<java.lang.Integer> |
findAvailableServerSockets(int seed,
int numberOfRequestedPorts)
Determines a free available server socket (port) using the 'seed' value as the starting port. |
static int |
findAvailableUdpSocket()
Determines a free available Udp socket using an automatically chosen start seed port. |
static int |
findAvailableUdpSocket(int seed)
Determines a free available Udp socket (port) using the 'seed' value as the starting port. |
static java.util.List<java.lang.Integer> |
findAvailableUdpSockets(int seed,
int numberOfRequestedPorts)
Determines free available udp socket(s) (port) using the 'seed' value as the starting port. |
static int |
getRandomSeedPort()
Determines a random seed port number within the port range 10000 and 60000. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_PORT_RANGE_MIN
public static final int DEFAULT_PORT_RANGE_MAX
Constructor Detail |
---|
public SocketUtils()
...port="#{T(org.springframework.integration.test.util.SocketUtils).findAvailableServerSocket(12000)}"
But unfortunately, you would need to repeat the package for each usage.
This will be acceptable for single use, but if you need to invoke the
methods numerous time, you may instead want to do this:
<bean id="tcpIpUtils" class="org.springframework.integration.test.util.SocketUtils" />
...port="#{tcpIpUtils.findAvailableServerSocket(12000)}"
Method Detail |
---|
public static int findAvailableServerSocket(int seed)
seed
- The starting port, which must not be negative.
java.lang.IllegalStateException
- when no open port was found.public static java.util.List<java.lang.Integer> findAvailableServerSockets(int seed, int numberOfRequestedPorts)
seed
- The starting port, which must not be negative.numberOfRequestedPorts
- How many open ports shall be retrieved?
java.lang.IllegalStateException
- when no open port was found.public static int findAvailableServerSocket()
java.lang.IllegalStateException
- when no open port was found.public static int findAvailableUdpSocket(int seed)
seed
- The starting port, which must not be negative.
java.lang.IllegalStateException
- when no open port was found.public static java.util.List<java.lang.Integer> findAvailableUdpSockets(int seed, int numberOfRequestedPorts)
seed
- The starting port, which must not be negative.numberOfRequestedPorts
- How many open ports shall be retrieved?
java.lang.IllegalStateException
- when no open port was found.public static int findAvailableUdpSocket()
java.lang.IllegalStateException
- when no open port was found.public static int getRandomSeedPort()
|
Spring Integration | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |