Document the need to explicitly reset mock servers

When MockServerRestTemplateCustomizer and MockServerRestClientCustomizer
are used directly instead of via auto-configuration, it is necessary to
manually reset the MockRestServiceServer expectations between tests.

Closes gh-41848
This commit is contained in:
Scott Frederick 2024-08-13 16:00:32 -05:00
parent c0e61d1a86
commit b43d97b359
2 changed files with 8 additions and 0 deletions

View File

@ -50,6 +50,10 @@ import org.springframework.web.client.RestClient.Builder;
* obtain the mock server. If the customizer has been used more than once the
* {@link #getServer(RestClient.Builder)} or {@link #getServers()} method must be used to
* access the related server.
* <p>
* If a mock server is used in more than one test case in a test class, it might be
* necessary to reset the expectations on the server between tests using
* {@code getServer().reset()} or {@code getServer(restClientBuilder).reset()}.
*
* @author Scott Frederick
* @since 3.2.0

View File

@ -48,6 +48,10 @@ import org.springframework.web.client.RestTemplate;
* obtain the mock server. If the customizer has been used more than once the
* {@link #getServer(RestTemplate)} or {@link #getServers()} method must be used to access
* the related server.
* <p>
* If a mock server is used in more than one test case in a test class, it might be
* necessary to reset the expectations on the server between tests using
* {@code getServer().reset()} or {@code getServer(restTemplate).reset()}.
*
* @author Phillip Webb
* @author Moritz Halbritter