webflow testing, unable to find flow model

一个人想着一个人 提交于 2019-12-25 05:15:15

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/6422748/webflow-testing-unable-to-find-flow-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!