Package org.wiremock.spring
Annotation Interface ConfigureWireMock
@Target(TYPE)
@Retention(RUNTIME)
@Repeatable(ConfigureWireMocks.class)
@ExtendWith(WireMockSpringJunitExtension.class) @ExtendWith(org.springframework.test.context.junit.jupiter.SpringExtension.class)
public @interface ConfigureWireMock
Configures WireMock instance.
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionString[]Names of Spring properties to inject theWireMockServer.baseUrl().Class<? extends WireMockConfigurationCustomizer>[]CustomizesWireMockConfigurationused byWireMockServerinstance.Class<? extends com.github.tomakehurst.wiremock.extension.ExtensionFactory>[]WireMock extensions to register inWireMockServer.Class<? extends com.github.tomakehurst.wiremock.extension.Extension>[]WireMock extensions to register inWireMockServer.Classpaths to pass toWireMockConfiguration.usingFilesUnderClasspath(String).String[]Directory paths to pass toWireMockConfiguration.usingFilesUnderDirectory(String).booleanString[]Names of Spring properties to inject theWireMockServer.baseUrl().intSame asport()but for HTTPS.String[]Names of Spring properties to inject theWireMockServer.httpsPort()Key manager password to use with the keystore configured withkeystorePath().Password of the keystore configured withkeystorePath().Path to the keystore used to serve HTTPS.Type of the keystore configured withkeystorePath(), e.g.The name of WireMock server.booleanIftrue, requires clients to present a certificate trusted by the trust store configured withtrustStorePath().intPort on which WireMock server is going to listen.String[]Names of Spring properties to inject theWireMockServer.port()booleanIftrue, it will registerWireMockServeras a Spring Bean so that it can beAutowiredby name.booleanWhen tests are running concurrently they will break each other if servers are being reset between tests.booleanIf you are having performance problems, you may want to set this to false.Password of the trust store configured withtrustStorePath().Path to the trust store used to verify client certificates.Type of the trust store configured withtrustStorePath(), e.g.booleanIf the port property is found in SpringApplicationContextit will be used. -
Field Summary
Fields
-
Field Details
-
DEFAULT_FILES_UNDER_DIRECTORY
-
-
Element Details
-
port
int portPort on which WireMock server is going to listen.-1means disabled.0means WireMock will pick random available port.>0means that static port will be used. A static port will, by default, make Spring context dirty to avoid port collisions. Automatic dirty context can be turned off withstaticPortDirtySpringContext().- Returns:
- WireMock server port
- Default:
- 0
-
httpsPort
int httpsPortSame asport()but for HTTPS.- Returns:
- HTTPS port to use.
- Default:
- -1
-
staticPortDirtySpringContext
boolean staticPortDirtySpringContextIf you are having performance problems, you may want to set this to false. Making context dirty is intended as a fix to avoid port collisions when using static port.- Returns:
- true if a static port should make Spring context dirty.
- Default:
- true
-
name
String nameThe name of WireMock server.- Returns:
- the name of WireMock server.
- Default:
- "wiremock"
-
usePortFromPredefinedPropertyIfFound
boolean usePortFromPredefinedPropertyIfFoundIf the port property is found in SpringApplicationContextit will be used. Enables a user to predefine a static port with a property.- Returns:
- true if enabled, else false.
- Default:
- false
-
portProperties
String[] portPropertiesNames of Spring properties to inject theWireMockServer.port()- Returns:
- names of Spring properties to inject the
WireMockServer.port()
- Default:
- {"wiremock.server.port"}
-
httpsPortProperties
String[] httpsPortPropertiesNames of Spring properties to inject theWireMockServer.httpsPort()- Returns:
- names of Spring properties to inject the
WireMockServer.httpsPort()
- Default:
- {"wiremock.server.httpsPort"}
-
baseUrlProperties
String[] baseUrlPropertiesNames of Spring properties to inject theWireMockServer.baseUrl().- Returns:
- names of Spring properties to inject the
WireMockServer.baseUrl().
- Default:
- {"wiremock.server.baseUrl"}
-
httpsBaseUrlProperties
String[] httpsBaseUrlPropertiesNames of Spring properties to inject theWireMockServer.baseUrl().- Returns:
- names of Spring properties to inject the
WireMockServer.baseUrl().
- Default:
- {"wiremock.server.httpsBaseUrl"}
-
filesUnderClasspath
String filesUnderClasspathClasspaths to pass toWireMockConfiguration.usingFilesUnderClasspath(String). See alsofilesUnderDirectory().- Default:
- ""
-
filesUnderDirectory
String[] filesUnderDirectoryDirectory paths to pass toWireMockConfiguration.usingFilesUnderDirectory(String). First existing directory will be used if list is given.It will search for mocks in this order:
- In filesystem
filesUnderDirectory()- In classpath
filesUnderClasspath()- In filesystem
DEFAULT_FILES_UNDER_DIRECTORY- Default:
- {}
- In filesystem
-
extensions
Class<? extends com.github.tomakehurst.wiremock.extension.Extension>[] extensionsWireMock extensions to register inWireMockServer.- Returns:
- the extensions
- Default:
- {}
-
extensionFactories
Class<? extends com.github.tomakehurst.wiremock.extension.ExtensionFactory>[] extensionFactoriesWireMock extensions to register inWireMockServer.- Returns:
- the extensions
- Default:
- {}
-
configurationCustomizers
Class<? extends WireMockConfigurationCustomizer>[] configurationCustomizersCustomizesWireMockConfigurationused byWireMockServerinstance. Customizers are ordered by their natural order in this array. Each customizer must have no-arg constructor.- Returns:
- the configuration customizers classes
- Default:
- {}
-
resetWireMockServer
boolean resetWireMockServerWhen tests are running concurrently they will break each other if servers are being reset between tests. Automatic reset is turned on by default, this option allows a user to turn it off.- Returns:
- true if
WireMockServershould be invoked withWireMockServer.resetAll()between test runs.
- Default:
- true
-
registerSpringBean
boolean registerSpringBeanIftrue, it will registerWireMockServeras a Spring Bean so that it can beAutowiredby name.- Default:
- false
-
globalTemplating
boolean globalTemplating- See Also:
-
WireMockConfiguration.globalTemplating(boolean)
- Default:
- false
-
keystorePath
String keystorePathPath to the keystore used to serve HTTPS. Only used whenhttpsPort()is enabled. Can point to a file on the filesystem or, if no such file exists, a resource on the classpath.- See Also:
-
WireMockConfiguration.keystorePath(String)
- Default:
- ""
-
keystorePassword
String keystorePasswordPassword of the keystore configured withkeystorePath().- See Also:
-
WireMockConfiguration.keystorePassword(String)
- Default:
- ""
-
keystoreType
String keystoreType- See Also:
-
WireMockConfiguration.keystoreType(String)
- Default:
- ""
-
keyManagerPassword
String keyManagerPasswordKey manager password to use with the keystore configured withkeystorePath().- See Also:
-
WireMockConfiguration.keyManagerPassword(String)
- Default:
- ""
-
trustStorePath
String trustStorePathPath to the trust store used to verify client certificates. Only used whenhttpsPort()is enabled. Can point to a file on the filesystem or, if no such file exists, a resource on the classpath.- See Also:
-
WireMockConfiguration.trustStorePath(String)
- Default:
- ""
-
trustStorePassword
String trustStorePasswordPassword of the trust store configured withtrustStorePath().- See Also:
-
WireMockConfiguration.trustStorePassword(String)
- Default:
- ""
-
trustStoreType
String trustStoreType- See Also:
-
WireMockConfiguration.trustStoreType(String)
- Default:
- ""
-
needClientAuth
boolean needClientAuthIftrue, requires clients to present a certificate trusted by the trust store configured withtrustStorePath().- See Also:
-
WireMockConfiguration.needClientAuth(boolean)
- Default:
- false
-