List of usage examples for org.springframework.web.client AsyncRestTemplate setErrorHandler
public void setErrorHandler(ResponseErrorHandler errorHandler)
From source file:org.zalando.riptide.OAuth2CompatibilityTest.java
@Test public void dispatchesConsumedAsyncResponseAgain() throws IOException { final AsyncRestTemplate template = new AsyncRestTemplate(); final MockRestServiceServer server = MockRestServiceServer.createServer(template); server.expect(requestTo(url)).andRespond(withUnauthorizedRequest().body(new byte[] { 0x13, 0x37 })); template.setErrorHandler(new OAuth2ErrorHandler(new OAuth2CompatibilityResponseErrorHandler(), null)); final AsyncRest rest = AsyncRest.create(template); final AtomicReference<ClientHttpResponse> reference = new AtomicReference<>(); rest.execute(GET, url).dispatch(status(), on(UNAUTHORIZED).call(reference::set)); assertThat(reference.get().getBody().available(), is(2)); }