Class WireMockTestResourceLifecycleManager

  • All Implemented Interfaces:
    io.quarkus.test.common.QuarkusTestResourceLifecycleManager

    public abstract class WireMockTestResourceLifecycleManager
    extends Object
    implements io.quarkus.test.common.QuarkusTestResourceLifecycleManager
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static org.jboss.logging.Logger LOG  
      protected com.github.tomakehurst.wiremock.WireMockServer server  
    • Field Detail

      • LOG

        protected static final org.jboss.logging.Logger LOG
      • server

        protected com.github.tomakehurst.wiremock.WireMockServer server
    • Constructor Detail

      • WireMockTestResourceLifecycleManager

        public WireMockTestResourceLifecycleManager()
    • Method Detail

      • start

        public Map<String,​String> start()
        Starts the WireMockServer and configures request / response recording if it has been enabled
        Specified by:
        start in interface io.quarkus.test.common.QuarkusTestResourceLifecycleManager
      • stop

        public void stop()
        Stops the WireMockServer instance if it was started and stops recording if record mode was enabled
        Specified by:
        stop in interface io.quarkus.test.common.QuarkusTestResourceLifecycleManager
      • inject

        public void inject​(Object testInstance)
        If mocking is enabled, inject an instance of WireMockServer into any fields annotated with MockServer. 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 resulting MockServer annotated field value will be null.
        Specified by:
        inject in interface io.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 the WireMockServer should be started.
      • customizeWiremockConfiguration

        protected void customizeWiremockConfiguration​(com.github.tomakehurst.wiremock.core.WireMockConfiguration config)
        Customizes the WiremockConfiguration that will be used to create the next .