StandardServletAsyncWebRequest handling for onError

This change ensures that an onError outcome from an async request is
also routed to onCompletion handlers registered with
StandardServletAsyncWebRequest.

Issue: SPR-13292
This commit is contained in:
Rossen Stoyanchev
2015-07-30 10:50:57 -04:00
parent 24285956a5
commit 27cd87926a
2 changed files with 27 additions and 1 deletions

View File

@@ -121,7 +121,7 @@ public class StandardServletAsyncWebRequestTests {
}
@Test
public void onTimeoutTimeoutHandler() throws Exception {
public void onTimeoutHandler() throws Exception {
Runnable timeoutHandler = mock(Runnable.class);
this.asyncRequest.addTimeoutHandler(timeoutHandler);
this.asyncRequest.onTimeout(new AsyncEvent(null));
@@ -134,4 +134,29 @@ public class StandardServletAsyncWebRequestTests {
this.asyncRequest.setTimeout(25L);
}
@Test
public void onCompletionHandler() throws Exception {
Runnable handler = mock(Runnable.class);
this.asyncRequest.addCompletionHandler(handler);
this.asyncRequest.startAsync();
this.asyncRequest.onComplete(new AsyncEvent(null));
verify(handler).run();
assertTrue(this.asyncRequest.isAsyncComplete());
}
// SPR-13292
@Test
public void onCompletionHandlerAfterOnErrorEvent() throws Exception {
Runnable handler = mock(Runnable.class);
this.asyncRequest.addCompletionHandler(handler);
this.asyncRequest.startAsync();
this.asyncRequest.onError(new AsyncEvent(null));
verify(handler).run();
assertTrue(this.asyncRequest.isAsyncComplete());
}
}