diff --git a/multi/multi__contract_dsl.html b/multi/multi__contract_dsl.html index ef47ab0788..8303a19275 100644 --- a/multi/multi__contract_dsl.html +++ b/multi/multi__contract_dsl.html @@ -1604,8 +1604,34 @@ socket.
Consider the following contract:
or } }
If you do it this way:
/my-context-path/url)./my-context-path/url).The DSL for messaging looks a little bit different than the one that focuses on HTTP. The -following sections explain the differences:
Spring Cloud Contract requires the usage of EXPLICIT mode in your generated tests
+to work with Web Flux.
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>
+
Gradle. +
contracts {
+ testMode = 'EXPLICIT'
+}+
The following example shows how to set up a base class and Rest Assured for Web Flux:
@RunWith(SpringRunner.class) +@SpringBootTest(classes = BeerRestBase.Config.class, + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = "server.port=0") +public abstract class BeerRestBase { + + // your tests go here + + // in this config class you define all controllers and mocked services + include::{samples_url}/producer_webflux/src/test/java/com/example/BeerRestBase.java[tags=config,indent=0] + +}
The DSL for messaging looks a little bit different than the one that focuses on HTTP. The +following sections explain the differences:
The output message can be triggered by calling a method (such as a Scheduler when a was
started and a message was sent), as shown in the following example:
Groovy DSL.
def dsl = Contract.make {
// Human readable description
@@ -1650,7 +1676,7 @@ outputMessage:
In the previous example case, the output message is sent to output if a method called
bookReturnedTriggered is executed. On the message publisher’s side, we generate a
test that calls that method to trigger the message. On the consumer side, you can use
-the some_label to trigger the message.
The output message can be triggered by receiving a message, as shown in the following
+the some_label to trigger the message.
The output message can be triggered by receiving a message, as shown in the following example:
Groovy DSL.
def dsl = Contract.make {
description 'Some Description'
@@ -1706,7 +1732,7 @@ outputMessage:
received on the input destination. On the message publisher’s side, the engine
generates a test that sends the input message to the defined destination. On the
consumer side, you can either send a message to the input destination or use a label
-(some_label in the example) to trigger the message.![]() | Important |
|---|---|
This section is valid only for Groovy DSL. |
In HTTP, you have a notion of client/stub and `server/test notation. You can also
+(some_label in the example) to trigger the message.
![]() | Important |
|---|---|
This section is valid only for Groovy DSL. |
In HTTP, you have a notion of client/stub and `server/test notation. You can also
use those paradigms in messaging. In addition, Spring Cloud Contract Verifier also
provides the consumer and producer methods, as presented in the following example
(note that you can use either $ or value methods to provide consumer and producer
@@ -1727,10 +1753,10 @@ parts):
Contract.make {
bookName: 'foo'
])
}
-}You can define multiple contracts in one file. Such a contract might resemble the +in the generated test.
You can define multiple contracts in one file. Such a contract might resemble the following example:
Groovy DSL.
import org.springframework.cloud.contract.spec.Contract @@ -1819,7 +1845,7 @@ index of the contract in the list.The generated stubs is shown in the fol 1_WithList.json
As you can see, the first file got the name parameter from the contract. The second
got the name of the contract file (WithList.groovy) prefixed with the index (in this
case, the contract had an index of 1 in the list of contracts in the file).
![]() | Tip |
|---|---|
As you can see, it is much better if you name your contracts because doing so makes -your tests far more meaningful. |
When you want to include the requests and responses of your API using Spring REST Docs, +your tests far more meaningful.
When you want to include the requests and responses of your API using Spring REST Docs, you only need to make some minor changes to your setup if you are using MockMvc and RestAssuredMockMvc. Simply include the following dependencies if you haven’t already.
Maven.
<dependency> diff --git a/multi/multi__using_the_pluggable_architecture.html b/multi/multi__using_the_pluggable_architecture.html index 2a541d2551..a22c482ac3 100644 --- a/multi/multi__using_the_pluggable_architecture.html +++ b/multi/multi__using_the_pluggable_architecture.html @@ -421,7 +421,7 @@ to clone the repository and use it as a source of contracts to generate tests or stubs.Either via environment variables, system properties, properties set inside the plugin or contracts repository configuration you can tweak the downloader’s behaviour. Below you can find the list of -properties
Table 10.1. SCM Stub Downloader properties