Merge branch '1.0.x'

fixes #179 #117
This commit is contained in:
Marcin Grzejszczak
2016-12-28 19:40:42 +01:00
14 changed files with 377 additions and 92 deletions

View File

@@ -289,6 +289,59 @@ org.springframework.cloud.contract.spec.Contract.make {
}
----
==== Working with Context Paths
Spring Cloud Contract supports context paths.
IMPORTANT: The only thing that changes in order to fully support context paths is the switch
on the *PRODUCER* side. The autogenerated tests need to be using the *EXPLICIT* mode.
The consumer side remains untouched, in order for the generated test to pass you have to switch the *EXPLICIT* mode.
[source,xml,indent=0,subs="verbatim,attributes",role="primary"]
.Maven
----
<plugin>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
<version>${spring-cloud-contract.version}</version>
<extensions>true</extensions>
<configuration>
<testMode>EXPLICIT</testMode>
</configuration>
</plugin>
----
[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"]
.Gradle
----
contracts {
testMode = 'EXPLICIT'
}
----
That way you'll generate a test that *DOES NOT* use MockMvc. It means that you're generating
real requests and you need to setup your generated test's base class to work on a real socket.
Let's imagine the following contract:
[source,groovy,indent=0]
----
include::{verifier_core_path}/src/test/groovy/org/springframework/cloud/contract/verifier/builder/SingleTestGeneratorSpec.groovy[tags=context_path_contract,indent=0]
----
Here is an example of how to set up a base class and Rest Assured for everything to work correctly.
[source,groovy,indent=0]
----
include::{verifier_core_path}/src/test/groovy/org/springframework/cloud/contract/verifier/builder/SingleTestGeneratorSpec.groovy[tags=context_path_baseclass,indent=0]
----
That way all:
- all your requests in the autogenerated tests will be sent to the real endpoint with your context path included (e.g. `/my-context-path/url`)
- your contracts reflect that you have a context path, thus your generated stubs will also
have that information (e.g. in the stubs you'll see that you have too call `/my-context-path/url`)
==== Messaging Top-Level Elements