In SWF 2.0.7, I am trying to use AbstractXmlFlowExecutionTests to test a flow that starts with a subflow. Examples and documentation show how to register a mock subflow, and this post and JIRA (http://forum.springsource.org/showthread.php?p=232506) offer some description, but I can't get anything to work. Has anyone done this?
My main flow, signup-Member-flow.xml, starts
The subflow, common-signup-flow.xml, looks like:Code:<subflow-state id="common-signup" subflow="common-signup"> <input name="siteMemberForm" value="siteMemberForm"/> <transition on="endCollect" to="review"/> </subflow-state> <view-state id="review" model="siteMemberForm"> // .... do more stuff in the main flow
And my test class that extends AbstractXmlFlowExecutionTests has these lines:Code:<input name="siteMemberForm" required="true"/> <!-- form to add members --> <view-state id="signup" model="siteMemberForm"> <!-- set required fields and white-list --> <binder> //...bunch of bindings </binder> <transition on="signupMember" to="collectMemberData"/> <transition on="cancel" to="end" bind="false" validate="false"/> </view-state> <action-state id="collectMemberData"> <evaluate expression="signupMemberActions.collectMemberData"/> <transition on="success" to="endCollect"/> <transition on="error" to="signup"/> </action-state> <end-state id="endCollect"/>
The line startFlow(new MockExternalContext()); throws a NoSuchFlowDefinitionException: No flow definition 'common-signup' found. I've tried to override configureFlowBuilderContext, but I don't think I'm doing it right. It looks like:Code:@Override protected FlowDefinitionResource getResource(FlowDefinitionResourceFactory resourceFactory) { return resourceFactory.createFileResource("src/main/webapp/WEB-INF/signup/signupMember-flow.xml"); } @Test public void testStart() throws Exception { startFlow(new MockExternalContext()); assertCurrentStateEquals(COMMON_SIGNUP); assertNotNull(getRequiredFlowAttribute("siteMemberForm")); }
That clunky attempt at creating the flow was based off of other examples I've found through searching the web.Code:@Override protected void configureFlowBuilderContext(MockFlowBuilderContext builderContext) { Flow theFlow = createSubFlow(builderContext); builderContext.registerSubflow(theFlow); } protected Flow createSubFlow(MockFlowBuilderContext builderContext){ FlowBuilder builder = createFlowBuilder(getResourceFactory().createFileResource("src/main/webapp/WEB-INF/common-signup/common-signup-flow.xml")); FlowAssembler assembler = new FlowAssembler(builder, builderContext); Flow theFlow = assembler.assembleFlow(); return theFlow; }
Thanks in advance for the pointers and correction.


Reply With Quote
