Provide method to set async TimeoutHandler

Issue: SPR-9914
This commit is contained in:
Rossen Stoyanchev
2012-10-25 12:35:23 -04:00
parent b093b30315
commit cb86712187
2 changed files with 40 additions and 10 deletions

View File

@@ -91,11 +91,7 @@ public class WebAsyncManagerTests {
@Test
public void startCallableProcessing() throws Exception {
Callable<Object> task = new Callable<Object>() {
public Object call() throws Exception {
return 1;
}
};
Callable<Object> task = new StubCallable();
CallableProcessingInterceptor interceptor = createStrictMock(CallableProcessingInterceptor.class);
interceptor.preProcess(this.asyncWebRequest, task);
@@ -146,11 +142,7 @@ public class WebAsyncManagerTests {
public void startCallableProcessingNullRequest() {
WebAsyncManager manager = WebAsyncUtils.getAsyncManager(new MockHttpServletRequest());
try {
manager.startCallableProcessing(new Callable<Object>() {
public Object call() throws Exception {
return 1;
}
});
manager.startCallableProcessing(new StubCallable());
fail("Expected exception");
}
catch (IllegalStateException ex) {
@@ -191,6 +183,29 @@ public class WebAsyncManagerTests {
verify(this.asyncWebRequest, interceptor);
}
@Test
public void setTimeoutHandler() throws Exception {
Runnable timeoutHandler = new Runnable() { public void run() {} };
this.asyncManager.setTimeoutHandler(timeoutHandler);
this.asyncWebRequest.startAsync();
this.asyncWebRequest.setTimeoutHandler(timeoutHandler);
expect(this.asyncWebRequest.isAsyncComplete()).andReturn(false);
this.asyncWebRequest.dispatch();
replay(this.asyncWebRequest);
this.asyncManager.startCallableProcessing(new StubCallable());
verify(this.asyncWebRequest);
}
private final class StubCallable implements Callable<Object> {
public Object call() throws Exception {
return 1;
}
}
@SuppressWarnings("serial")
private static class SyncTaskExecutor extends SimpleAsyncTaskExecutor {