【发布时间】:2015-11-27 17:24:51
【问题描述】:
我在使用 JUnit 测试我的 Spring webflows 时遇到问题。
按照文档中的建议,我编写了一个扩展 AbstractXmlFlowExecutionTests 的测试类。
public class MyFlowTest extends AbstractXmlFlowExecutionTests {
MockExternalContext context = new MockExternalContext();
String workingDirectory = null;
@Override
protected FlowDefinitionResource getResource(FlowDefinitionResourceFactory resourceFactory) {
return resourceFactory.createFileResource("WebContent/flows/myflow-flow.xml");
}
Test 下的 webflow 继承自定义了一些全局转换的抽象父 webflow。所以我尝试覆盖 getModelResources 来提供这个父 webflow。但这根本不起作用。
@Override
protected FlowDefinitionResource[] getModelResources(FlowDefinitionResourceFactory resourceFactory) {
FlowDefinitionResource[] flowDefResources = new FlowDefinitionResource[1];
see below...
return flowDefResources;
}
我的具体问题是:
当我将 resourceFactory.createFileResource 用于父流时,名称不正确,因此我收到消息 Unable to find flow 'main/parentflow' to inherit from 的异常。
当我使用resourceFactory.createResource(String path, null, "main/parentflow" 时,永远找不到定义流的.xml。异常打印路径并显示 FileNotFound 但路径确实存在(将此路径复制并粘贴到编辑器 - 文件 - 打开工作。
我在这里做错了什么?
非常感谢。
我正在使用 spring-webflow-2.3.2 和 jUnit 4
【问题讨论】:
标签: java spring junit4 spring-webflow