BeforeInterceptor actionBefore2 = createStrictMock(BeforeInterceptor.class);
List<BeforeInterceptor> actionBefores = new ArrayList<BeforeInterceptor>();
actionBefores.add(actionBefore1);
actionBefores.add(actionBefore2);
AfterInterceptor after1 = createStrictMock(AfterInterceptor.class);
AfterInterceptor after2 = createStrictMock(AfterInterceptor.class);
Collection<AfterInterceptor> afters = new ArrayList<AfterInterceptor>();
afters.add(after1);
afters.add(after2);
AfterInterceptor actionAfter1 = createStrictMock(AfterInterceptor.class);
AfterInterceptor actionAfter2 = createStrictMock(AfterInterceptor.class);
List<AfterInterceptor> actionAfters = new ArrayList<AfterInterceptor>();
actionAfters.add(actionAfter1);
actionAfters.add(actionAfter2);
ControllerAction action = createStrictMock(ControllerAction.class);
HttpServletRequest request = createStrictMock(HttpServletRequest.class);
TestAction actionBean = createStrictMock(TestAction.class);
ActionBeanSource beanSource = createStrictMock(ActionBeanSource.class);
ActionContext actionContext = new TestContextImpl(request);
// check the expected order of method invocation
expect(action.getBeanSource()).andReturn(beanSource);
expect(beanSource.createBean(actionContext)).andReturn(actionBean);
action.preExecute(actionBean, actionContext);
before1.beforeExecute(actionBean, actionContext);
before2.beforeExecute(actionBean, actionContext);
expect(action.getBeforeInterceptors()).andReturn(actionBefores);
actionBefore1.beforeExecute(actionBean, actionContext);
actionBefore2.beforeExecute(actionBean, actionContext);
expect(action.executeController(actionBean, actionContext)).andReturn(
new ActionForwardViewAdapter(actionForward));
expect(action.getAfterInterceptors()).andReturn(actionAfters);
actionAfter1.afterExecute(actionBean, actionContext, null);
actionAfter2.afterExecute(actionBean, actionContext, null);
after1.afterExecute(actionBean, actionContext, null);
after2.afterExecute(actionBean, actionContext, null);
action.postExecute(actionBean, actionContext, null);