Package com.github.skjolber.mockito.soap
Class SoapEndpointRule
java.lang.Object
org.junit.rules.ExternalResource
com.github.skjolber.mockito.soap.SoapServiceRule
com.github.skjolber.mockito.soap.SoapEndpointRule
- All Implemented Interfaces:
org.junit.rules.TestRule
Rule for mocking SOAP services using Endpoints. Multiple services can run on the same port.
If used as a ClassRule, the rule can be used to reserve random free ports.
Resulting reserved ports are set as system properties to port names provided by the caller.
- Author:
- thomas.skjolberg@gmail.com
-
Constructor Summary
ConstructorsConstructorDescriptionSoapEndpointRule(int portRangeStart, int portRangeEnd, String... portNames) SoapEndpointRule(String... portNames) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafter()protected voidbefore()voidclear()Stop and remove endpoints, keeping port reservations.voiddestroy()intReturns the port number that was reserved for the given name.getPorts()Returns all port names and respective port numbers.static SoapEndpointRulestatic SoapEndpointRulenewInstance(int portRangeStart, int portRangeEnd, String... portNames) static SoapEndpointRulenewInstance(String... portNames) <T> voidproxy(T target, Class<T> port, String address, String wsdlLocation, List<String> schemaLocations, Map<String, Object> properties) Create (and start) an endpoint with the given properties.voidstart()(Re)start services.voidstop()Stop services.Methods inherited from class com.github.skjolber.mockito.soap.SoapServiceRule
assertValidAddress, assertValidParams, mock, mock, mock, mock, mock, mock, parsePort, processProperties, properties, proxy, verifyPropertiesMethods inherited from class org.junit.rules.ExternalResource
apply
-
Constructor Details
-
SoapEndpointRule
public SoapEndpointRule() -
SoapEndpointRule
-
SoapEndpointRule
-
-
Method Details
-
newInstance
-
newInstance
-
newInstance
public static SoapEndpointRule newInstance(int portRangeStart, int portRangeEnd, String... portNames) -
getPort
Returns the port number that was reserved for the given name.- Parameters:
portName- port name- Returns:
- a valid port number if the port has been reserved, -1 otherwise
-
getPorts
Returns all port names and respective port numbers.- Returns:
- a map of port name and port value (a valid port number if the port has been reserved, or -1 otherwise)
-
proxy
public <T> void proxy(T target, Class<T> port, String address, String wsdlLocation, List<String> schemaLocations, Map<String, Object> properties) Description copied from class:SoapServiceRuleCreate (and start) an endpoint with the given properties.- Specified by:
proxyin classSoapServiceRule- Type Parameters:
T- the type of the mocked class- Parameters:
target- instance calls are forwarded toport- service classaddress- address, i.e. http://localhost:1234wsdlLocation- wsdl location, or nullschemaLocations- schema locations, or nullproperties- additional properties, like mtom-enabled etc.
-
before
protected void before()- Overrides:
beforein classorg.junit.rules.ExternalResource
-
after
protected void after()- Overrides:
afterin classorg.junit.rules.ExternalResource
-
clear
public void clear()Stop and remove endpoints, keeping port reservations. -
destroy
public void destroy() -
stop
public void stop()Description copied from class:SoapServiceRuleStop services.- Specified by:
stopin classSoapServiceRule
-
start
public void start()Description copied from class:SoapServiceRule(Re)start services.- Specified by:
startin classSoapServiceRule
-