Support custom HTTP status in MockClientHttpResponse

See gh-28105
This commit is contained in:
azzureman
2022-03-16 08:41:33 +00:00
committed by rstoyanchev
parent 21d61316be
commit f1fdc11fab
4 changed files with 73 additions and 7 deletions

View File

@@ -128,6 +128,15 @@ class ResponseCreatorsTests {
assertThat(StreamUtils.copyToByteArray(response.getBody()).length).isEqualTo(0);
}
@Test
void withCustomStatus() throws Exception {
DefaultResponseCreator responseCreator = MockRestResponseCreators.withStatus(454);
MockClientHttpResponse response = (MockClientHttpResponse) responseCreator.createResponse(null);
assertThat(response.getRawStatusCode()).isEqualTo(454);
assertThat(response.getStatusText()).isEqualTo("Custom http status");
}
@Test
void withException() {
ResponseCreator responseCreator = MockRestResponseCreators.withException(new SocketTimeoutException());