Class WireMockTestResourceLifecycleManager
- java.lang.Object
-
- org.apache.camel.quarkus.test.wiremock.WireMockTestResourceLifecycleManager
-
- All Implemented Interfaces:
io.quarkus.test.common.QuarkusTestResourceLifecycleManager
public abstract class WireMockTestResourceLifecycleManager extends Object implements io.quarkus.test.common.QuarkusTestResourceLifecycleManager
-
-
Constructor Summary
Constructors Constructor Description WireMockTestResourceLifecycleManager()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcustomizeWiremockConfiguration(com.github.tomakehurst.wiremock.core.WireMockConfiguration config)Customizes theWireMockConfigurationthat will be used to create the next .protected StringenvOrDefault(String envVarName, String defaultValue)Get the value of a given environment variable or a default value if it does not existprotected booleanenvVarsPresent(String... envVarNames)Determines whether each of the given environment variable names is setprotected abstract StringgetRecordTargetBaseUrl()The target base URL that WireMock should watch for when recording requests.voidinject(Object testInstance)If mocking is enabled, inject an instance ofWireMockServerinto any fields annotated withMockServer.protected booleanisDeleteRecordedMappingsOnError()Whether recorded stub mapping files should be deleted if the HTTP response was an error code (>= 400).protected abstract booleanisMockingEnabled()Conditions under which theWireMockServershould be started.Map<String,String>start()Starts theWireMockServerand configures request / response recording if it has been enabledvoidstop()Stops theWireMockServerinstance if it was started and stops recording if record mode was enabled
-
-
-
Method Detail
-
start
public Map<String,String> start()
Starts theWireMockServerand configures request / response recording if it has been enabled- Specified by:
startin interfaceio.quarkus.test.common.QuarkusTestResourceLifecycleManager
-
stop
public void stop()
Stops theWireMockServerinstance if it was started and stops recording if record mode was enabled- Specified by:
stopin interfaceio.quarkus.test.common.QuarkusTestResourceLifecycleManager
-
inject
public void inject(Object testInstance)
If mocking is enabled, inject an instance ofWireMockServerinto any fields annotated withMockServer. This gives full control over creating recording rules and some aspects of the server lifecycle. The server instance is not injected if mocking is explicitly disabled, and therefore the resultingMockServerannotated field value will be null.- Specified by:
injectin interfaceio.quarkus.test.common.QuarkusTestResourceLifecycleManager
-
envVarsPresent
protected boolean envVarsPresent(String... envVarNames)
Determines whether each of the given environment variable names is set
-
envOrDefault
protected String envOrDefault(String envVarName, String defaultValue)
Get the value of a given environment variable or a default value if it does not exist
-
isDeleteRecordedMappingsOnError
protected boolean isDeleteRecordedMappingsOnError()
Whether recorded stub mapping files should be deleted if the HTTP response was an error code (>= 400). By default this returns true. Can be overridden if an error response is desired / expected from the HTTP request.
-
getRecordTargetBaseUrl
protected abstract String getRecordTargetBaseUrl()
The target base URL that WireMock should watch for when recording requests. For example, if a test triggers an HTTP call on an external endpoint like https://api.foo.com/some/resource. Then the base URL would be https://api.foo.com
-
isMockingEnabled
protected abstract boolean isMockingEnabled()
Conditions under which theWireMockServershould be started.
-
customizeWiremockConfiguration
protected void customizeWiremockConfiguration(com.github.tomakehurst.wiremock.core.WireMockConfiguration config)
Customizes theWireMockConfigurationthat will be used to create the next .
-
-