Use IntrospectingClientHttpResponse in RestClient
This commit ensures that the RestClient uses the IntrospectingClientHttpResponse to verify whether the response has a body, and return null if it does not. See gh-12671 Closes gh-31719
This commit is contained in:
@@ -348,6 +348,23 @@ class RestClientIntegrationTests {
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
@ParameterizedRestClientTest
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
void retrieveJsonEmpty(ClientHttpRequestFactory requestFactory) {
|
||||
startServer(requestFactory);
|
||||
|
||||
prepareResponse(response -> response
|
||||
.setResponseCode(200)
|
||||
.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE));
|
||||
|
||||
Pojo result = this.restClient.get()
|
||||
.uri("/null")
|
||||
.retrieve()
|
||||
.body(Pojo.class);
|
||||
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
@ParameterizedRestClientTest
|
||||
void retrieve404(ClientHttpRequestFactory requestFactory) {
|
||||
startServer(requestFactory);
|
||||
|
||||
Reference in New Issue
Block a user