From dc0ffd587eaf14110cc386ef0d907bfee46bdbfd Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Tue, 24 Oct 2017 18:33:19 +0200 Subject: [PATCH] Merged 1.1.x --- docs/src/main/asciidoc/verifier_contract.adoc | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/docs/src/main/asciidoc/verifier_contract.adoc b/docs/src/main/asciidoc/verifier_contract.adoc index 4b7f850397..3da6b52f67 100644 --- a/docs/src/main/asciidoc/verifier_contract.adoc +++ b/docs/src/main/asciidoc/verifier_contract.adoc @@ -89,6 +89,49 @@ plugin configuration or set the `ignored` property on the contract itself: include::{contract_spec_path}/src/test/groovy/org/springframework/cloud/contract/spec/internal/ContractSpec.groovy[tags=ignored,indent=0] ---- +[[contract-dsl-passing-values-from-files]] +==== Passing Values from Files + +Starting with version `1.2.0`, you can pass values from files. Assume that you have the +following resources in our project. + +[source,bash,indent=0] +---- +└── src +    └── test +       └── resources +          └── contracts +    ├── readFromFile.groovy +    ├── request.json +    └── response.json +---- + +Further assume that your contract is as follows: + +[source,groovy,indent=0] +---- +include::{verifier_core_path}/src/test/resources/classpath/readFromFile.groovy[indent=0] +---- + +Further assume that the JSON files is as follows: + +*request.json* +[source,json,indent=0] +---- +include::{verifier_core_path}/src/test/resources/classpath/request.json[indent=0] +---- + +*response.json* +[source,json,indent=0] +---- +include::{verifier_core_path}/src/test/resources/classpath/response.json[indent=0] +---- + +When test or stub generation takes place, the contents of the file is passed to the body +of a request or a response. That works because of the `file(...)` method. The argument of +that method needs to be a file with location relative to the folder in which the contract +lays. + [[contract-dsl-http-top-level-elements]] ==== HTTP Top-Level Elements @@ -512,7 +555,7 @@ The following is an example of a custom extension: .TestWireMockExtensions.groovy [source,groovy,indent=0] ---- -include::{stubrunner_core_path}/src/test/groovy/org/springframework/cloud/contract/verifier/dsl/wiremock/TestWireMockExtensions.groovy[indent=0] +include::{verifier_core_path}/src/test/groovy/org/springframework/cloud/contract/verifier/dsl/wiremock/TestWireMockExtensions.groovy[indent=0] ---- IMPORTANT: Remember to override the `applyGlobally()` method and set it to `false` if you