webflow测试,找不到流量模型
我有一个非常烦人的问题,我无法弄清楚。
这是我的webflow项目的主要结构:
- WEB-INF/flows/basic/basic-flow.xml
- WEB-INF/flows/error/error-flow.xml
错误流包含常见的异常处理,并且是抽象的。基本流程将错误流程作为父流程。
当我尝试编写 JUnit 测试时,遇到了无法加载错误流的问题。我已经测试了 basic 本身(只是删除了父属性),它工作得很好。对我可能做错的事情有什么建议吗?
以下是测试代码的重要部分:
@Override
protected FlowDefinitionResource getResource(FlowDefinitionResourceFactory resourceFactory) {
return resourceFactory.createFileResource("src/main/webapp/WEB-INF/flows/basic/basic-flow.xml");
}
@Override
protected FlowDefinitionResource[] getModelResources(FlowDefinitionResourceFactory resourceFactory) {
FlowDefinitionResource flowDefinitionResource = resourceFactory
.createFileResource("src/main/webapp/WEB-INF/flows/error/error-flow.xml");
return new FlowDefinitionResource[] { flowDefinitionResource };
}
public void testStartBasicFlow() {
MockExternalContext context = new MockExternalContext();
startFlow(context);
}
我得到的异常是这样的:
Caused by: org.springframework.webflow.engine.model.registry.NoSuchFlowModelException: No flow model 'error' found
I have this very annoying problem I cannot figure out.
This is the main structure of my webflow project:
- WEB-INF/flows/basic/basic-flow.xml
- WEB-INF/flows/error/error-flow.xml
The error flow contains common exception handling and is abstract. Basic flow has the error flow as parent.
When I try to write a JUnit test I get into a problem where it is not able to load the error flow. I have tested basic by itself (just removing the parent attribute) and it works just fine. Any advice to what I could be doing wrong?
Here are the important parts of the test code:
@Override
protected FlowDefinitionResource getResource(FlowDefinitionResourceFactory resourceFactory) {
return resourceFactory.createFileResource("src/main/webapp/WEB-INF/flows/basic/basic-flow.xml");
}
@Override
protected FlowDefinitionResource[] getModelResources(FlowDefinitionResourceFactory resourceFactory) {
FlowDefinitionResource flowDefinitionResource = resourceFactory
.createFileResource("src/main/webapp/WEB-INF/flows/error/error-flow.xml");
return new FlowDefinitionResource[] { flowDefinitionResource };
}
public void testStartBasicFlow() {
MockExternalContext context = new MockExternalContext();
startFlow(context);
}
The exception I get is this:
Caused by: org.springframework.webflow.engine.model.registry.NoSuchFlowModelException: No flow model 'error' found
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于您的
error
流程,您可能应该显式传递flowId
:当使用
FlowDefinitionResource.createFileResource(..)
时,flowId
> 是FlowDefinitionResource.getFlowId(..)
的结果,在您的情况下可能不会评估为error
。For Your
error
flow You should probably explicitelly pass aflowId
:When using
FlowDefinitionResource.createFileResource(..)
theflowId
is the result of theFlowDefinitionResource.getFlowId(..)
, wich may not evaluate toerror
in Your case.