org.mule.tck.junit4.rule
Class DynamicPort
java.lang.Object
org.junit.rules.ExternalResource
org.mule.tck.junit4.rule.DynamicPort
- All Implemented Interfaces:
- org.junit.rules.TestRule
public class DynamicPort
- extends org.junit.rules.ExternalResource
Defines a socket port number that will be dynamically assigned as an
external resource. The instance will check that the port has been released
on test shutdown.
To use an instance dynamic socket port:
Constructor Summary |
DynamicPort(String name)
Creates a dynamic port resource for a given port name. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
freePortFinder
protected static FreePortFinder freePortFinder
logger
protected Log logger
DynamicPort
public DynamicPort(String name)
- Creates a dynamic port resource for a given port name.
- Parameters:
name
- the name assigned to the port number. On resource creation
a new system property will be created with that name and the
value will be the port number.
before
public void before()
throws Throwable
- Initializes the dynamic port.
NOTE: this method was made public in order to support the usage of
static dynamic ports because current JUnit version does not support
class rules.
- Overrides:
before
in class org.junit.rules.ExternalResource
- Throws:
Throwable
after
public void after()
- Checks that the port has been released. For now if it was not released it
just logs a message so we can track the problem.
NOTE: this method was made public in order to support the usage of
static dynamic ports because current JUnit version does not support
class rules.
- Overrides:
after
in class org.junit.rules.ExternalResource
- Throws:
Throwable
getNumber
public int getNumber()
getName
public String getName()
Copyright © 2003-2011 MuleSoft, Inc.. All Rights Reserved.