Add mechanism to expose mock server results

WebTestClient is an actual client and generally it's only possible
to assert the client response (i.e. what goes over HTTP). However,
in a mock server scenario technically we have access to the server
request and response and can make those available for further
assertions.

This will be helpful for the WebTestClient integration with MockMvc
where many more assertions can be performed on the server request
and response when needed.

See gh-19647
This commit is contained in:
Rossen Stoyanchev
2020-08-19 17:47:49 +01:00
parent cb02b0e776
commit f500ab0f9b
5 changed files with 77 additions and 11 deletions

View File

@@ -244,7 +244,7 @@ class HeaderAssertionTests {
MonoProcessor<byte[]> emptyContent = MonoProcessor.fromSink(Sinks.one());
emptyContent.onComplete();
ExchangeResult result = new ExchangeResult(request, response, emptyContent, emptyContent, Duration.ZERO, null);
ExchangeResult result = new ExchangeResult(request, response, emptyContent, emptyContent, Duration.ZERO, null, null);
return new HeaderAssertions(result, mock(WebTestClient.ResponseSpec.class));
}

View File

@@ -160,7 +160,7 @@ class StatusAssertionTests {
MonoProcessor<byte[]> emptyContent = MonoProcessor.fromSink(Sinks.one());
emptyContent.onComplete();
ExchangeResult result = new ExchangeResult(request, response, emptyContent, emptyContent, Duration.ZERO, null);
ExchangeResult result = new ExchangeResult(request, response, emptyContent, emptyContent, Duration.ZERO, null, null);
return new StatusAssertions(result, mock(WebTestClient.ResponseSpec.class));
}