Class WireMockExtension

  • All Implemented Interfaces:
    Admin, Stubbing, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.Extension, org.junit.jupiter.api.extension.ParameterResolver

    public class WireMockExtension
    extends DslWrapper
    implements org.junit.jupiter.api.extension.ParameterResolver, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.AfterAllCallback
    JUnit Jupiter extension that manages a WireMock server instance's lifecycle and configuration. See http://wiremock.org/docs/junit-jupiter/ for full documentation.
    • Constructor Detail

      • WireMockExtension

        public WireMockExtension()
      • WireMockExtension

        protected WireMockExtension​(WireMockExtension.Builder builder)
        Constructor intended for subclasses. The parameter is a builder so that we can avoid a constructor explosion or backwards-incompatible changes when new options are added.
        Parameters:
        builder - a WireMockExtension.Builder instance holding the initialisation parameters for the extension.
    • Method Detail

      • onBeforeAll

        protected void onBeforeAll​(WireMockRuntimeInfo wireMockRuntimeInfo)
        To be overridden in subclasses in order to run code immediately after per-class WireMock setup.
        Parameters:
        wireMockRuntimeInfo - port numbers, base URLs and HTTPS info for the running WireMock instance/
      • onBeforeEach

        protected void onBeforeEach​(WireMockRuntimeInfo wireMockRuntimeInfo)
        To be overridden in subclasses in order to run code immediately after per-test WireMock setup.
        Parameters:
        wireMockRuntimeInfo - port numbers, base URLs and HTTPS info for the running WireMock instance/
      • onAfterEach

        protected void onAfterEach​(WireMockRuntimeInfo wireMockRuntimeInfo)
        To be overridden in subclasses in order to run code immediately after per-test cleanup of WireMock and its associated resources.
        Parameters:
        wireMockRuntimeInfo - port numbers, base URLs and HTTPS info for the running WireMock instance/
      • onAfterAll

        protected void onAfterAll​(WireMockRuntimeInfo wireMockRuntimeInfo)
        To be overridden in subclasses in order to run code immediately after per-class cleanup of WireMock.
        Parameters:
        wireMockRuntimeInfo - port numbers, base URLs and HTTPS info for the running WireMock instance/
      • supportsParameter

        public boolean supportsParameter​(org.junit.jupiter.api.extension.ParameterContext parameterContext,
                                         org.junit.jupiter.api.extension.ExtensionContext extensionContext)
                                  throws org.junit.jupiter.api.extension.ParameterResolutionException
        Specified by:
        supportsParameter in interface org.junit.jupiter.api.extension.ParameterResolver
        Throws:
        org.junit.jupiter.api.extension.ParameterResolutionException
      • resolveParameter

        public java.lang.Object resolveParameter​(org.junit.jupiter.api.extension.ParameterContext parameterContext,
                                                 org.junit.jupiter.api.extension.ExtensionContext extensionContext)
                                          throws org.junit.jupiter.api.extension.ParameterResolutionException
        Specified by:
        resolveParameter in interface org.junit.jupiter.api.extension.ParameterResolver
        Throws:
        org.junit.jupiter.api.extension.ParameterResolutionException
      • beforeAll

        public final void beforeAll​(org.junit.jupiter.api.extension.ExtensionContext context)
                             throws java.lang.Exception
        Specified by:
        beforeAll in interface org.junit.jupiter.api.extension.BeforeAllCallback
        Throws:
        java.lang.Exception
      • beforeEach

        public final void beforeEach​(org.junit.jupiter.api.extension.ExtensionContext context)
                              throws java.lang.Exception
        Specified by:
        beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback
        Throws:
        java.lang.Exception
      • afterAll

        public final void afterAll​(org.junit.jupiter.api.extension.ExtensionContext context)
                            throws java.lang.Exception
        Specified by:
        afterAll in interface org.junit.jupiter.api.extension.AfterAllCallback
        Throws:
        java.lang.Exception
      • afterEach

        public final void afterEach​(org.junit.jupiter.api.extension.ExtensionContext context)
                             throws java.lang.Exception
        Specified by:
        afterEach in interface org.junit.jupiter.api.extension.AfterEachCallback
        Throws:
        java.lang.Exception
      • baseUrl

        public java.lang.String baseUrl()
      • url

        public java.lang.String url​(java.lang.String path)
      • getHttpsPort

        public int getHttpsPort()
      • getPort

        public int getPort()