Class WireMockHelper

java.lang.Object
com.adaptris.tester.runtime.helpers.Helper
com.adaptris.tester.runtime.helpers.wiremock.WireMockHelper
All Implemented Interfaces:
Closeable, AutoCloseable

public class WireMockHelper extends com.adaptris.tester.runtime.helpers.Helper
Helper which starts a WireMock server.

WireMock (http://wiremock.org/):

WireMock is a simulator for HTTP-based APIs. Some might consider it a service virtualization tool or a mock server.

It enables you to stay productive when an API you depend on doesn't exist or isn't complete. It supports testing of edge cases and failure modes that the real API won't reliably produce. And because it's fast it can reduce your build time from hours down to minutes.

In the service test configuration this class is aliased as wire-mock-helper which is the preferred alternative to the fully qualified classname when building your configuration.

  • Field Details

    • WIRE_MOCK_HELPER_PORT_PROPERTY_NAME

      public static final String WIRE_MOCK_HELPER_PORT_PROPERTY_NAME
      Key for helper property ("wire.mock.helper.port").
      See Also:
  • Constructor Details

    • WireMockHelper

      public WireMockHelper()
  • Method Details

    • init

      public void init(com.adaptris.tester.runtime.ServiceTestConfig config) throws com.adaptris.tester.runtime.ServiceTestException
      Initialises Mock server with port set as value from getPortProvider() which also added as a helper property to "wire.mock.helper.port".
      Specified by:
      init in class com.adaptris.tester.runtime.helpers.Helper
      Parameters:
      config - The service tester config
      Throws:
      com.adaptris.tester.runtime.ServiceTestException - wrapping any thrown exception
    • close

      public void close() throws IOException
      Closes WireMock server and release port from getPortProvider().
      Throws:
      IOException
    • getFileSource

      public String getFileSource()
      Sets the path of the mock configuration.
    • setFileSource

      public void setFileSource(String fileSource)
      Sets the path of the mock configuration.
      Parameters:
      fileSource - Path of the mock configuration.
    • getPortProvider

      public com.adaptris.tester.runtime.helpers.PortProvider getPortProvider()
      The PortProvider for the mock server
    • setPortProvider

      public void setPortProvider(com.adaptris.tester.runtime.helpers.PortProvider portProvider)
      The PortProvider for the mock server