@Test public void earlyExitInPreHandle() throws Exception { given(this.interceptor1.preHandle(this.request, this.response, this.handler)).willReturn(true); given(this.interceptor2.preHandle(this.request, this.response, this.handler)).willReturn(false); this.chain.applyPreHandle(request, response); verify(this.interceptor1).afterCompletion(this.request, this.response, this.handler, null); }
if (!mappedHandler.applyPreHandle(processedRequest, response)) { return;
@Test public void exceptionDuringPreHandle() throws Exception { Exception ex = new Exception(""); given(this.interceptor1.preHandle(this.request, this.response, this.handler)).willReturn(true); given(this.interceptor2.preHandle(this.request, this.response, this.handler)).willThrow(ex); try { this.chain.applyPreHandle(request, response); } catch (Exception actual) { assertSame(ex, actual); } this.chain.triggerAfterCompletion(this.request, this.response, ex); verify(this.interceptor1).afterCompletion(this.request, this.response, this.handler, ex); verify(this.interceptor3, never()).preHandle(this.request, this.response, this.handler); }
@Test public void exceptionAfterPreHandle() throws Exception { Exception ex = new Exception(""); given(this.interceptor1.preHandle(this.request, this.response, this.handler)).willReturn(true); given(this.interceptor2.preHandle(this.request, this.response, this.handler)).willReturn(true); given(this.interceptor3.preHandle(this.request, this.response, this.handler)).willReturn(true); this.chain.applyPreHandle(request, response); this.chain.triggerAfterCompletion(this.request, this.response, ex); verify(this.interceptor3).afterCompletion(this.request, this.response, this.handler, ex); verify(this.interceptor2).afterCompletion(this.request, this.response, this.handler, ex); verify(this.interceptor1).afterCompletion(this.request, this.response, this.handler, ex); }
if (!mappedHandler.applyPreHandle(processedRequest, response)) { return;
@Test public void successAsyncScenario() throws Exception { given(this.interceptor1.preHandle(this.request, this.response, this.handler)).willReturn(true); given(this.interceptor2.preHandle(this.request, this.response, this.handler)).willReturn(true); given(this.interceptor3.preHandle(this.request, this.response, this.handler)).willReturn(true); this.chain.applyPreHandle(request, response); this.chain.applyAfterConcurrentHandlingStarted(request, response); this.chain.triggerAfterCompletion(this.request, this.response, null); verify(this.interceptor1).afterConcurrentHandlingStarted(request, response, this.handler); verify(this.interceptor2).afterConcurrentHandlingStarted(request, response, this.handler); verify(this.interceptor3).afterConcurrentHandlingStarted(request, response, this.handler); }
@Test public void successScenario() throws Exception { ModelAndView mav = new ModelAndView(); given(this.interceptor1.preHandle(this.request, this.response, this.handler)).willReturn(true); given(this.interceptor2.preHandle(this.request, this.response, this.handler)).willReturn(true); given(this.interceptor3.preHandle(this.request, this.response, this.handler)).willReturn(true); this.chain.applyPreHandle(request, response); this.chain.applyPostHandle(request, response, mav); this.chain.triggerAfterCompletion(this.request, this.response, null); verify(this.interceptor1).postHandle(this.request, this.response, this.handler, mav); verify(this.interceptor2).postHandle(this.request, this.response, this.handler, mav); verify(this.interceptor3).postHandle(this.request, this.response, this.handler, mav); verify(this.interceptor3).afterCompletion(this.request, this.response, this.handler, null); verify(this.interceptor2).afterCompletion(this.request, this.response, this.handler, null); verify(this.interceptor1).afterCompletion(this.request, this.response, this.handler, null); }
if (!mappedHandler.applyPreHandle(processedRequest, response)) { return;