我基本上需要调用 Struts 动作类的 execute() 方法。这甚至可能吗。如果是,我如何为执行调用加载 ActionMapping、ActionForm、HttpServletRequest 和 HttpServletResponse 对象。
加载 Spring 配置:
public class SpringColumnFixture extends ColumnFixture {
private static final ApplicationContext appContext =
new GenericXmlApplicationContext(new String[]{"classpath:spring/*.xml"});
}
尝试执行的测试:
ActionForm form = new IncidentDetailsForm();
ActionMapping mapping = new ActionMapping();
HttpServletResponse response = new MockHttpServletResponse();
MockHttpServletRequest request = new MockHttpServletRequest() {
@Override public String getMethod() {
return "GET"; }
};
request.setAttribute("userName","****");
request.setParameter("userName","****");
forward = appContext.getBean(AppLandingAction.class).execute(mapping, form, request, response);