use of org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter in project spring-framework by spring-projects.
the class TestDispatcherServlet method registerAsyncResultInterceptors.
private void registerAsyncResultInterceptors(final HttpServletRequest request) {
WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
asyncManager.registerCallableInterceptor(KEY, new CallableProcessingInterceptorAdapter() {
@Override
public <T> void postProcess(NativeWebRequest r, Callable<T> task, Object value) throws Exception {
getMvcResult(request).setAsyncResult(value);
}
});
asyncManager.registerDeferredResultInterceptor(KEY, new DeferredResultProcessingInterceptorAdapter() {
@Override
public <T> void postProcess(NativeWebRequest r, DeferredResult<T> result, Object value) throws Exception {
getMvcResult(request).setAsyncResult(value);
}
});
}
use of org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter in project spring-security by spring-projects.
the class WebAsyncManagerIntegrationFilterTests method doFilterInternalRegistersSecurityContextCallableProcessor.
@Test
public void doFilterInternalRegistersSecurityContextCallableProcessor() throws Exception {
SecurityContextHolder.setContext(securityContext);
asyncManager.registerCallableInterceptors(new CallableProcessingInterceptorAdapter() {
@Override
public <T> void postProcess(NativeWebRequest request, Callable<T> task, Object concurrentResult) throws Exception {
assertThat(SecurityContextHolder.getContext()).isNotSameAs(securityContext);
}
});
filter.doFilterInternal(request, response, filterChain);
VerifyingCallable verifyingCallable = new VerifyingCallable();
asyncManager.startCallableProcessing(verifyingCallable);
threadFactory.join();
assertThat(asyncManager.getConcurrentResult()).isSameAs(securityContext);
}
use of org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter in project spring-security by spring-projects.
the class WebAsyncManagerIntegrationFilterTests method doFilterInternalRegistersSecurityContextCallableProcessorContextUpdated.
@Test
public void doFilterInternalRegistersSecurityContextCallableProcessorContextUpdated() throws Exception {
SecurityContextHolder.setContext(SecurityContextHolder.createEmptyContext());
asyncManager.registerCallableInterceptors(new CallableProcessingInterceptorAdapter() {
@Override
public <T> void postProcess(NativeWebRequest request, Callable<T> task, Object concurrentResult) throws Exception {
assertThat(SecurityContextHolder.getContext()).isNotSameAs(securityContext);
}
});
filter.doFilterInternal(request, response, filterChain);
SecurityContextHolder.setContext(securityContext);
VerifyingCallable verifyingCallable = new VerifyingCallable();
asyncManager.startCallableProcessing(verifyingCallable);
threadFactory.join();
assertThat(asyncManager.getConcurrentResult()).isSameAs(securityContext);
}
Aggregations