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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringKey for helper property ("wire.mock.helper.port"). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes WireMock server and release port fromgetPortProvider().Sets the path of the mock configuration.com.adaptris.tester.runtime.helpers.PortProviderThePortProviderfor the mock servervoidinit(com.adaptris.tester.runtime.ServiceTestConfig config) Initialises Mock server with port set as value fromgetPortProvider()which also added as a helper property to "wire.mock.helper.port".voidsetFileSource(String fileSource) Sets the path of the mock configuration.voidsetPortProvider(com.adaptris.tester.runtime.helpers.PortProvider portProvider) ThePortProviderfor the mock serverMethods inherited from class com.adaptris.tester.runtime.helpers.Helper
addHelperProperty, getHelperProperties
-
Field Details
-
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 fromgetPortProvider()which also added as a helper property to "wire.mock.helper.port".- Specified by:
initin classcom.adaptris.tester.runtime.helpers.Helper- Parameters:
config- The service tester config- Throws:
com.adaptris.tester.runtime.ServiceTestException- wrapping any thrown exception
-
close
Closes WireMock server and release port fromgetPortProvider().- Throws:
IOException
-
getFileSource
Sets the path of the mock configuration. -
setFileSource
Sets the path of the mock configuration.- Parameters:
fileSource- Path of the mock configuration.
-
getPortProvider
public com.adaptris.tester.runtime.helpers.PortProvider getPortProvider()ThePortProviderfor the mock server -
setPortProvider
public void setPortProvider(com.adaptris.tester.runtime.helpers.PortProvider portProvider) ThePortProviderfor the mock server
-