开发者

webflow testing, unable to find flow model

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);
}
开发者_如何学Python

The exception I get is this:

Caused by: org.springframework.webflow.engine.model.registry.NoSuchFlowModelException: No flow model 'error' found


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜