ResponseErrorHandler provides access to URI and method

Issue: SPR-15511
This commit is contained in:
Rossen Stoyanchev
2017-05-24 15:34:40 -04:00
parent 9b53b86d24
commit 805fcc6a05
4 changed files with 21 additions and 4 deletions

View File

@@ -163,12 +163,14 @@ public class RestTemplateTests {
@Test
public void errorHandling() throws Exception {
given(requestFactory.createRequest(new URI("http://example.com"), HttpMethod.GET)).willReturn(request);
URI uri = new URI("http://example.com");
given(requestFactory.createRequest(uri, HttpMethod.GET)).willReturn(request);
given(request.execute()).willReturn(response);
given(errorHandler.hasError(response)).willReturn(true);
given(response.getStatusCode()).willReturn(HttpStatus.INTERNAL_SERVER_ERROR);
given(response.getStatusText()).willReturn("Internal Server Error");
willThrow(new HttpServerErrorException(HttpStatus.INTERNAL_SERVER_ERROR)).given(errorHandler).handleError(response);
willThrow(new HttpServerErrorException(HttpStatus.INTERNAL_SERVER_ERROR))
.given(errorHandler).handleError(uri, HttpMethod.GET, response);
try {
template.execute("http://example.com", HttpMethod.GET, null, null);