org.mule.tck.junit4.rule
Class DynamicPort

java.lang.Object
  extended by org.junit.rules.ExternalResource
      extended by 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:


Field Summary
protected static FreePortFinder freePortFinder
           
protected  Log logger
           
 
Constructor Summary
DynamicPort(String name)
          Creates a dynamic port resource for a given port name.
 
Method Summary
 void after()
          Checks that the port has been released.
 void before()
          Initializes the dynamic port.
 String getName()
           
 int getNumber()
           
 
Methods inherited from class org.junit.rules.ExternalResource
apply
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

freePortFinder

protected static FreePortFinder freePortFinder

logger

protected Log logger
Constructor Detail

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.
Method Detail

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-2014 MuleSoft, Inc.. All Rights Reserved.