Annotation Type AutoConfigureStubRunner
@Target(TYPE)
@Retention(RUNTIME)
@Documented
@ImportAutoConfiguration
@AutoConfigureMessageVerifier
@PropertyMapping(value="stubrunner",
skip=ON_DEFAULT_VALUE)
public @interface AutoConfigureStubRunner
- Author:
- Dave Syer
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionYou can override the defaultspring.application.name
of this field by setting a value to this parameter.boolean
boolean
boolean
Class<? extends HttpServerStubConfigurer>
Configuration for an HTTP server stub.String[]
For debugging purposes you can output the registered mappings to a given folder.int
int
String[]
Properties in form key=value.The way stubs should be found and registered.boolean
On the producer side the consumers can have a folder that contains contracts related only to them.
-
Element Details
-
minPort
int minPort- Returns:
- Min value of a port for the automatically started WireMock server.
- Default:
- 10000
-
maxPort
int maxPort- Returns:
- Max value of a port for the automatically started WireMock server.
- Default:
- 15000
-
repositoryRoot
String repositoryRoot- Returns:
- The repository root to use (where the stubs should be downloaded from).
- Default:
- ""
-
ids
String[] ids- Returns:
- The ids of the stubs to run in "ivy" notation
([groupId]:artifactId[:version][:classifier][:port]).
groupId
,version
,classifier
andport
can be optional.
- Default:
- {}
-
classifier
String classifier- Returns:
- The classifier to use by default in ivy co-ordinates for a stub.
- Default:
- "stubs"
-
stubsPerConsumer
boolean stubsPerConsumerOn the producer side the consumers can have a folder that contains contracts related only to them. By setting the flag totrue
we no longer register all stubs but only those that correspond to the consumer application's name. In other words we'll scan the path of every stub and if it contains the name of the consumer in the path only then will it get registered. Let's look at this example. Let's assume that we have a producer calledfoo
and two consumersbaz
andbar
. On thefoo
producer side the contracts would look like thissrc/test/resources/contracts/baz-service/some/contracts/...
andsrc/test/resources/contracts/bar-service/some/contracts/...
. Then when the consumer withspring.application.name
or theconsumerName()
annotation parameter set tobaz-service
will define the test setup as follows@AutoConfigureStubRunner(ids = "com.example:foo:+:stubs:8095", stubsPerConsumer=true)
then only the stubs registered undersrc/test/resources/contracts/baz-service/some/contracts/...
will get registered and those undersrc/test/resources/contracts/bar-service/some/contracts/...
will get ignored.- Returns:
true
to turn on the feature- See Also:
- Default:
- false
-
consumerName
String consumerNameYou can override the defaultspring.application.name
of this field by setting a value to this parameter.- Returns:
- name of this application
- See Also:
- Default:
- ""
-
mappingsOutputFolder
String mappingsOutputFolderFor debugging purposes you can output the registered mappings to a given folder. Each HTTP server stub will have its own subfolder where all the mappings will get stored.- Returns:
- where the mappings output should be stored
- See Also:
- Default:
- ""
-
stubsMode
StubRunnerProperties.StubsMode stubsModeThe way stubs should be found and registered. Defaults toStubRunnerProperties.StubsMode.CLASSPATH
.- Returns:
- the type of stubs mode
- Default:
- CLASSPATH
-
properties
String[] propertiesProperties in form key=value.- Returns:
- the properties to add
- Default:
- {}
-
deleteStubsAfterTest
boolean deleteStubsAfterTest- Returns:
- If set to
false
will NOT delete stubs from a temporary folder after running tests
- Default:
- true
-
generateStubs
boolean generateStubs- Returns:
- When enabled, this flag will tell stub runner to not load the generated stubs, but convert the found contracts at runtime to a stub format and run those stubs.
- Default:
- false
-
failOnNoStubs
boolean failOnNoStubs- Returns:
- when enabled, this flag will tell stub runner to throw an exception when no stubs / contracts were found.
- Default:
- true
-
httpServerStubConfigurer
Class<? extends HttpServerStubConfigurer> httpServerStubConfigurerConfiguration for an HTTP server stub.- Returns:
- class that allows to perform additional HTTP server stub configuration
- Default:
- org.springframework.cloud.contract.stubrunner.HttpServerStubConfigurer.NoOpHttpServerStubConfigurer.class
-