webflow测试,找不到流量模型

发布于 2024-11-16 05:09:13 字数 1167 浏览 3 评论 0原文

我有一个非常烦人的问题,我无法弄清楚。

这是我的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄荷→糖丶微凉 2024-11-23 05:09:13

对于您的 error 流程,您可能应该显式传递 flowId

FlowDefinitionResource flowDefinitionResource = resourceFactory.createResource(
    "src/main/webapp/WEB-INF/flows/error/error-flow.xml", null, "error");

当使用 FlowDefinitionResource.createFileResource(..) 时,flowId > 是 FlowDefinitionResource.getFlowId(..) 的结果,在您的情况下可能不会评估为 error

For Your error flow You should probably explicitelly pass a flowId:

FlowDefinitionResource flowDefinitionResource = resourceFactory.createResource(
    "src/main/webapp/WEB-INF/flows/error/error-flow.xml", null, "error");

When using FlowDefinitionResource.createFileResource(..) the flowId is the result of the FlowDefinitionResource.getFlowId(..), wich may not evaluate to error in Your case.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文