use of org.springframework.web.servlet.HandlerInterceptor in project spring-framework by spring-projects.
the class MappedInterceptorTests method afterCompletion.
@Test
void afterCompletion() throws Exception {
HandlerInterceptor delegate = mock(HandlerInterceptor.class);
new MappedInterceptor(null, delegate).afterCompletion(mock(HttpServletRequest.class), mock(HttpServletResponse.class), null, mock(Exception.class));
then(delegate).should().afterCompletion(any(), any(), any(), any());
}
use of org.springframework.web.servlet.HandlerInterceptor in project spring-framework by spring-projects.
the class MappedInterceptorTests method preHandle.
@Test
void preHandle() throws Exception {
HandlerInterceptor delegate = mock(HandlerInterceptor.class);
new MappedInterceptor(null, delegate).preHandle(mock(HttpServletRequest.class), mock(HttpServletResponse.class), null);
then(delegate).should().preHandle(any(HttpServletRequest.class), any(HttpServletResponse.class), any());
}
use of org.springframework.web.servlet.HandlerInterceptor in project spring-framework by spring-projects.
the class MappedInterceptorTests method postHandle.
@Test
void postHandle() throws Exception {
HandlerInterceptor delegate = mock(HandlerInterceptor.class);
new MappedInterceptor(null, delegate).postHandle(mock(HttpServletRequest.class), mock(HttpServletResponse.class), null, mock(ModelAndView.class));
then(delegate).should().postHandle(any(), any(), any(), any());
}
use of org.springframework.web.servlet.HandlerInterceptor in project gocd by gocd.
the class InterceptorInjectorTest method testShouldMergeInterceptors.
@Test
public void testShouldMergeInterceptors() throws Throwable {
HandlerInterceptor interceptorOfFramework = new HandlerInterceptorSub();
HandlerInterceptor interceptorOfTab = new HandlerInterceptorSub();
HandlerInterceptor[] interceptorsOfFramework = new HandlerInterceptor[] { interceptorOfFramework };
HandlerInterceptor[] interceptorsOfTab = new HandlerInterceptor[] { interceptorOfTab };
ProceedingJoinPoint proceedingJoinPoint = mock(ProceedingJoinPoint.class);
when(proceedingJoinPoint.proceed()).thenReturn(new HandlerExecutionChain(null, interceptorsOfTab));
InterceptorInjector injector = new InterceptorInjector();
injector.setInterceptors(interceptorsOfFramework);
HandlerExecutionChain handlers = injector.mergeInterceptorsToTabs(proceedingJoinPoint);
assertEquals(2, handlers.getInterceptors().length);
assertSame(interceptorOfFramework, handlers.getInterceptors()[0]);
assertSame(interceptorOfTab, handlers.getInterceptors()[1]);
}
use of org.springframework.web.servlet.HandlerInterceptor in project gocd by gocd.
the class InterceptorInjectorTest method testShouldJustReturnInterceptorsOfFrameworkIfNoTabInterceptors.
@Test
public void testShouldJustReturnInterceptorsOfFrameworkIfNoTabInterceptors() throws Throwable {
HandlerInterceptor interceptorOfFramework = new HandlerInterceptorSub();
HandlerInterceptor[] interceptorsOfFramework = new HandlerInterceptor[] { interceptorOfFramework };
ProceedingJoinPoint proceedingJoinPoint = mock(ProceedingJoinPoint.class);
when(proceedingJoinPoint.proceed()).thenReturn(new HandlerExecutionChain(null, null));
InterceptorInjector injector = new InterceptorInjector();
injector.setInterceptors(interceptorsOfFramework);
HandlerExecutionChain handlers = injector.mergeInterceptorsToTabs(proceedingJoinPoint);
assertEquals(1, handlers.getInterceptors().length);
assertSame(interceptorOfFramework, handlers.getInterceptors()[0]);
}
Aggregations