diff --git a/2.0.x/multi/multi__spring_cloud_contract_faq.html b/2.0.x/multi/multi__spring_cloud_contract_faq.html index 40ba7eb1a3..44afbb48f9 100644 --- a/2.0.x/multi/multi__spring_cloud_contract_faq.html +++ b/2.0.x/multi/multi__spring_cloud_contract_faq.html @@ -67,7 +67,7 @@ for time and UUID are simplified and most likely invalid but we want to keep thi body: "bar" ]) } -}
![]() | Important | |||||
|---|---|---|---|---|---|---|
Please read the Groovy docs related to JSON to understand how to +}
Let’s try to answer a question what versioning really means. If you’re referring to the API version then there are different approaches.
I will not try to answer a question which approach is better. Whatever suit your needs and allows you to generate business value should be picked. Let’s assume that you do version your API. In that case you should provide as many contracts as many versions you support. diff --git a/2.0.x/multi/multi__spring_cloud_contract_stub_runner.html b/2.0.x/multi/multi__spring_cloud_contract_stub_runner.html index d0d92462d0..0fc1536fa9 100644 --- a/2.0.x/multi/multi__spring_cloud_contract_stub_runner.html +++ b/2.0.x/multi/multi__spring_cloud_contract_stub_runner.html @@ -246,7 +246,7 @@ HTTP stubs without the need to download artifacts. Stubs are defined in JSON documents, whose syntax is defined in WireMock documentation Example: {
+ repositoryStubs are defined in JSON documents, whose syntax is defined in WireMock documentation Example: {
"request": {
"method": "GET",
"url": "/ping"
@@ -630,7 +630,7 @@ the Stub Runner server. It will be available at port As you can see we want to start a Stub Runner Boot server Now let’s assume that we want to start this application so that the stubs get automatically registered.
We can do it by running the app -Dstubrunner.repositoryRoot=https://repo.spring.io/snapshots (1) + |
Spring Cloud Contract Verifier enables Consumer Driven Contract (CDC) development of JVM-based applications. It moves TDD to the level of software architecture.
Spring Cloud Contract Verifier ships with Contract Definition Language (CDL). Contract definitions are used to produce the following resources:
![]() | Tip |
|---|---|
You must understand the map notation in order to set up contracts. Please read the -Groovy docs regarding JSON. |
The previously shown contract is an agreement between two sides that:
if an HTTP request is sent with all of
PUT method on the /fraudcheck endpoint,client.id that matches the regular expression [0-9]{10} and
+Groovy docs regarding JSON.The previously shown contract is an agreement between two sides that:
if an HTTP request is sent with all of
PUT method on the /fraudcheck endpoint,client.id that matches the regular expression [0-9]{10} and
loanAmount equal to 99999,Content-Type header with a value of application/vnd.fraud.v1+json,then an HTTP response is sent to the consumer that
200,fraudCheckStatus field containing a value FRAUD and
the rejectionReason field having value Amount too high,Content-Type header with a value of application/vnd.fraud.v1+json.Once you are ready to check the API in practice in the integration tests, you need to install the stubs locally.
Add the Spring Cloud Contract Verifier plugin.
We can add either a Maven or a Gradle plugin. In this example, you see how to add Maven.
@@ -690,7 +690,7 @@ make the name of the base test class. In our case, the contracts were placed und
src/test/resources/contracts/fraud. Since you do not have two packages starting from
the contracts folder, pick only one, which should be fraud. Add the Base suffix and
capitalize fraud. That gives you the FraudBase test class name.
All the generated tests extend that class. Over there, you can set up your Spring Context
-or whatever is necessary. In this case, use Rest Assured MVC to
+or whatever is necessary. In this case, use Rest Assured MVC to
start the server side FraudDetectionController.
package com.example.fraud; import org.junit.Before; @@ -770,5 +770,5 @@ achieving the same thing by changing the properties.repositoryRoot: https://repo.spring.io/libs-snapshotThat’s it!
The best way to add dependencies is to use the proper starter dependency.
For stub-runner, use spring-cloud-starter-stub-runner. When you use a plugin, add
spring-cloud-starter-contract-verifier.
Here are some resources related to Spring Cloud Contract Verifier and Stub Runner. Note that some may be outdated, because the Spring Cloud Contract Verifier project is under -constant development.
You can check out the video from the Warsaw JUG about Spring Cloud Contract:
You can find some samples at +constant development.
You can check out the video from the Warsaw JUG about Spring Cloud Contract:
You can find some samples at samples.
Such a tree causes Spring Cloud Contract Verifier to generate WireMock’s scenario with a
name of scenario1 and the three following steps:
Started pointing to…Step1 pointing to…Step2 which will close the scenario.More details about WireMock scenarios can be found at -http://wiremock.org/docs/stateful-behaviour/
Spring Cloud Contract Verifier also generates tests with a guaranteed order of execution.
We’re publishing a springcloud/spring-cloud-contract Docker image
+https://wiremock.org/docs/stateful-behaviour/
Spring Cloud Contract Verifier also generates tests with a guaranteed order of execution.
We’re publishing a springcloud/spring-cloud-contract Docker image
that contains a project that will generate tests and execute them in EXPLICIT mode
against a running application.
![]() | Tip |
|---|---|
The |
Since the Docker image can be used by non JVM projects, it’s good to @@ -650,7 +650,7 @@ or Nexus/spring-cloud-contract/build folder (it’s useful for debugging purposes).
It’s enough for you to mount your contracts, pass the environment variables - and the image will:
The Docker image requires some environment variables to point to + and the image will:
The Docker image requires some environment variables to point to your running application, to the Artifact manager instance etc.
PROJECT_GROUP - your project’s group id. Defaults to com.examplePROJECT_VERSION - your project’s version. Defaults to 0.0.1-SNAPSHOTPROJECT_NAME - artifact id. Defaults to exampleREPO_WITH_BINARIES_URL - URL of your Artifact Manager. Defaults to http://localhost:8081/artifactory/libs-release-local
which is the default URL of Artifactory running locallyREPO_WITH_BINARIES_USERNAME - (optional) username when the Artifact Manager is securedREPO_WITH_BINARIES_PASSWORD - (optional) password when the Artifact Manager is securedPUBLISH_ARTIFACTS - if set to true then will publish artifact to binary storage. Defaults to true.These environment variables are used when contracts lay in an external repository. To enable
this feature you must set the EXTERNAL_CONTRACTS_ARTIFACT_ID environment variable.
EXTERNAL_CONTRACTS_GROUP_ID - group id of the project with contracts. Defaults to com.exampleEXTERNAL_CONTRACTS_ARTIFACT_ID- artifact id of the project with contracts.EXTERNAL_CONTRACTS_CLASSIFIER- classifier of the project with contracts. Empty by defaultEXTERNAL_CONTRACTS_VERSION - version of the project with contracts. Defaults to +, equivalent to picking the latestEXTERNAL_CONTRACTS_REPO_WITH_BINARIES_URL - URL of your Artifact Manager. Defaults to value of REPO_WITH_BINARIES_URL env var.
diff --git a/2.0.x/multi/multi__spring_cloud_contract_wiremock.html b/2.0.x/multi/multi__spring_cloud_contract_wiremock.html
index cfa75d78be..9d4bf77ec5 100644
--- a/2.0.x/multi/multi__spring_cloud_contract_wiremock.html
+++ b/2.0.x/multi/multi__spring_cloud_contract_wiremock.html
@@ -1,6 +1,6 @@
- The Spring Cloud Contract WireMock modules let you use WireMock in a +
The Spring Cloud Contract WireMock modules let you use WireMock in a Spring Boot application. Check out the samples for more details.
If you have a Spring Boot application that uses Tomcat as an embedded server (which is
@@ -142,7 +142,7 @@ visit WireMock website.
Currently, the Spring Cloud Contract Verifier supports Tomcat, Jetty, and Undertow as +WireMock website.
Currently, the Spring Cloud Contract Verifier supports Tomcat, Jetty, and Undertow as Spring Boot embedded servers, and Wiremock itself has "native" support for a particular version of Jetty (currently 9.2). To use the native Jetty, you need to add the native Wiremock dependencies and exclude the Spring Boot container (if there is one).
You can register a bean of org.springframework.cloud.contract.wiremock.WireMockConfigurationCustomizer type
diff --git a/2.0.x/multi/multi_contract-dsl.html b/2.0.x/multi/multi_contract-dsl.html
index 86bec3df68..01ad48f66f 100644
--- a/2.0.x/multi/multi_contract-dsl.html
+++ b/2.0.x/multi/multi_contract-dsl.html
@@ -769,7 +769,7 @@ Pattern nonBlank() {
}
body(
email: $(consumer(optional(regex(email()))), producer('abc@abc.com')),
- callback_url: $(consumer(regex(hostname())), producer('http://partners.com'))
+ callback_url: $(consumer(regex(hostname())), producer('https://partners.com'))
)
}
response {
@@ -794,7 +794,7 @@ optional parameters only for the following:
If you use Spock for, the given: def request = given() .header("Content-Type", "application/json") - .body('''{"email":"abc@abc.com","callback_url":"http://partners.com"}''') + .body('''{"email":"abc@abc.com","callback_url":"https://partners.com"}''') when: def response = given().spec(request) diff --git a/2.0.x/single/spring-cloud-contract.html b/2.0.x/single/spring-cloud-contract.html index eca2c6716e..85bdd9b1d4 100644 --- a/2.0.x/single/spring-cloud-contract.html +++ b/2.0.x/single/spring-cloud-contract.html @@ -6,7 +6,7 @@ distributed system. This project provides support for Consumer Driven Contracts service schemas in Spring applications (for both HTTP and message-based interactions), covering a range of options for writing tests, publishing them as assets, and asserting that a contract is kept by producers and consumers.
![]() | Tip |
|---|---|
The Accurest project was initially started by Marcin Grzejszczak and Jakub Kubrynski -(codearte.io) |
Spring Cloud Contract Verifier enables Consumer Driven Contract (CDC) development of +(Codearte)
Spring Cloud Contract Verifier enables Consumer Driven Contract (CDC) development of JVM-based applications. It moves TDD to the level of software architecture.
Spring Cloud Contract Verifier ships with Contract Definition Language (CDL). Contract definitions are used to produce the following resources:
![]() | Tip |
|---|---|
You must understand the map notation in order to set up contracts. Please read the -Groovy docs regarding JSON. |
The previously shown contract is an agreement between two sides that:
if an HTTP request is sent with all of
PUT method on the /fraudcheck endpoint,client.id that matches the regular expression [0-9]{10} and
+Groovy docs regarding JSON.The previously shown contract is an agreement between two sides that:
if an HTTP request is sent with all of
PUT method on the /fraudcheck endpoint,client.id that matches the regular expression [0-9]{10} and
loanAmount equal to 99999,Content-Type header with a value of application/vnd.fraud.v1+json,then an HTTP response is sent to the consumer that
200,fraudCheckStatus field containing a value FRAUD and
the rejectionReason field having value Amount too high,Content-Type header with a value of application/vnd.fraud.v1+json.Once you are ready to check the API in practice in the integration tests, you need to install the stubs locally.
Add the Spring Cloud Contract Verifier plugin.
We can add either a Maven or a Gradle plugin. In this example, you see how to add Maven.
@@ -695,7 +695,7 @@ make the name of the base test class. In our case, the contracts were placed und
src/test/resources/contracts/fraud. Since you do not have two packages starting from
the contracts folder, pick only one, which should be fraud. Add the Base suffix and
capitalize fraud. That gives you the FraudBase test class name.
All the generated tests extend that class. Over there, you can set up your Spring Context
-or whatever is necessary. In this case, use Rest Assured MVC to
+or whatever is necessary. In this case, use Rest Assured MVC to
start the server side FraudDetectionController.
package com.example.fraud; import org.junit.Before; @@ -775,7 +775,7 @@ achieving the same thing by changing the properties.repositoryRoot: https://repo.spring.io/libs-snapshotThat’s it!
The best way to add dependencies is to use the proper starter dependency.
For stub-runner, use spring-cloud-starter-stub-runner. When you use a plugin, add
spring-cloud-starter-contract-verifier.
Here are some resources related to Spring Cloud Contract Verifier and Stub Runner. Note that some may be outdated, because the Spring Cloud Contract Verifier project is under -constant development.
You can check out the video from the Warsaw JUG about Spring Cloud Contract:
You can find some samples at +constant development.
You can check out the video from the Warsaw JUG about Spring Cloud Contract:
You can find some samples at samples.
For the time being Spring Cloud Contract is a JVM based tool. So it could be your first pick when you’re already creating software for the JVM. This project has a lot of really interesting features but especially quite a few of them definitely make Spring Cloud Contract Verifier stand out on the "market" of Consumer Driven Contract (CDC) tooling. Out of many the most interesting are:
One of the biggest challenges related to stubs is their reusability. Only if they can be vastly used, will they serve their purpose. @@ -843,7 +843,7 @@ for time and UUID are simplified and most likely invalid but we want to keep thi body: "bar" ]) } -}
![]() | Important | |||||||
|---|---|---|---|---|---|---|---|---|
Please read the Groovy docs related to JSON to understand how to +}
Let’s try to answer a question what versioning really means. If you’re referring to the API version then there are different approaches.
I will not try to answer a question which approach is better. Whatever suit your needs and allows you to generate business value should be picked. Let’s assume that you do version your API. In that case you should provide as many contracts as many versions you support. @@ -2036,7 +2036,7 @@ requires including an order number followed by an underscore. This will work reg 2_showCart.groovy 3_logout.groovy Such a tree causes Spring Cloud Contract Verifier to generate WireMock’s scenario with a
name of
More details about WireMock scenarios can be found at -http://wiremock.org/docs/stateful-behaviour/ Spring Cloud Contract Verifier also generates tests with a guaranteed order of execution. We’re publishing a Spring Cloud Contract Verifier also generates tests with a guaranteed order of execution. We’re publishing a
Since the Docker image can be used by non JVM projects, it’s good to @@ -2070,7 +2070,7 @@ or Nexus/spring-cloud-contract/build folder (it’s useful for debugging purposes). It’s enough for you to mount your contracts, pass the environment variables - and the image will:
The Docker image requires some environment variables to point to + and the image will:
The Docker image requires some environment variables to point to your running application, to the Artifact manager instance etc.
These environment variables are used when contracts lay in an external repository. To enable
this feature you must set the
Stubs are defined in JSON documents, whose syntax is defined in WireMock documentation Example: {
+ repositoryStubs are defined in JSON documents, whose syntax is defined in WireMock documentation Example: {
"request": {
"method": "GET",
"url": "/ping"
@@ -3001,7 +3001,7 @@ the Stub Runner server. It will be available at port As you can see we want to start a Stub Runner Boot server Now let’s assume that we want to start this application so that the stubs get automatically registered.
We can do it by running the app -Dstubrunner.repositoryRoot=https://repo.spring.io/snapshots (1) + | The password passed to | Password used to connect to the Pact Broker | ||||||
* * * | false | When |
The Spring Cloud Contract WireMock modules let you use WireMock in a +
* STUBRUNNER_PROPERTIES_PACTBROKER_PROVIDER_NAME_WITH_GROUP_ID (env prop)
false
When true, the provider name will be a combination of groupId:artifactId. If false, just artifactId is used
The Spring Cloud Contract WireMock modules let you use WireMock in a Spring Boot application. Check out the samples for more details.
If you have a Spring Boot application that uses Tomcat as an embedded server (which is
@@ -6245,7 +6245,7 @@ visit WireMock website.
Currently, the Spring Cloud Contract Verifier supports Tomcat, Jetty, and Undertow as +WireMock website.
Currently, the Spring Cloud Contract Verifier supports Tomcat, Jetty, and Undertow as Spring Boot embedded servers, and Wiremock itself has "native" support for a particular version of Jetty (currently 9.2). To use the native Jetty, you need to add the native Wiremock dependencies and exclude the Spring Boot container (if there is one).
You can register a bean of org.springframework.cloud.contract.wiremock.WireMockConfigurationCustomizer type
diff --git a/2.0.x/spring-cloud-contract.xml b/2.0.x/spring-cloud-contract.xml
index 91111832f9..be7debf664 100644
--- a/2.0.x/spring-cloud-contract.xml
+++ b/2.0.x/spring-cloud-contract.xml
@@ -24,7 +24,7 @@ that a contract is kept by producers and consumers.