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

public class SoapEndpointRule extends SoapServiceRule
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 Details

    • SoapEndpointRule

      public SoapEndpointRule()
    • SoapEndpointRule

      public SoapEndpointRule(String... portNames)
    • SoapEndpointRule

      public SoapEndpointRule(int portRangeStart, int portRangeEnd, String... portNames)
  • Method Details

    • newInstance

      public static SoapEndpointRule newInstance()
    • newInstance

      public static SoapEndpointRule newInstance(String... portNames)
    • newInstance

      public static SoapEndpointRule newInstance(int portRangeStart, int portRangeEnd, String... portNames)
    • getPort

      public int getPort(String portName)
      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

      public Map<String,Integer> 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: SoapServiceRule
      Create (and start) an endpoint with the given properties.
      Specified by:
      proxy in class SoapServiceRule
      Type Parameters:
      T - the type of the mocked class
      Parameters:
      target - instance calls are forwarded to
      port - service class
      address - address, i.e. http://localhost:1234
      wsdlLocation - wsdl location, or null
      schemaLocations - schema locations, or null
      properties - additional properties, like mtom-enabled etc.
    • before

      protected void before()
      Overrides:
      before in class org.junit.rules.ExternalResource
    • after

      protected void after()
      Overrides:
      after in class org.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: SoapServiceRule
      Stop services.
      Specified by:
      stop in class SoapServiceRule
    • start

      public void start()
      Description copied from class: SoapServiceRule
      (Re)start services.
      Specified by:
      start in class SoapServiceRule