【发布时间】:2013-02-27 11:32:35
【问题描述】:
我基本上需要调用Struts动作类的execute()方法。这甚至可能吗。如果是,我如何加载 ActionMapping、ActionForm、HttpServletRequest 和 HttpServletResponse 对象以进行执行调用。
加载 Spring Config:
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);
【问题讨论】:
-
我能够以某种方式将所有需要的 spring 配置放到类路径中,并从我现有的 pom.xml 中调用 Fitnesse 进程作为任务。我加载了所有的 xml 文件。我还尝试创建请求、响应、actionMapping 和 actionform(都是虚拟的)。我什至在请求中设置了一些参数,但是在调用之后设置的参数在请求中不可用。我总是收到一个空请求。谁能帮我解决这个问题。
-
你能发布你的代码吗?
-
@ekims - 感谢您编辑问题。忘记了那个功能。你能告诉我我在做什么错吗,因为我总是收到一个空请求,有时甚至是 MockHttpServletRequest 的 classNotFoundException,尽管 jar 存在于类路径中。
-
我加载了请求和响应参数,但无法初始化我的 JAXRPC。我总是收到说明“创建 JAXRPC 服务接口时出错:null”的消息。欢迎任何帮助。同时,我也会及时发布我的更新。
标签: struts automated-tests integration-testing fitnesse