Results 1 to 7 of 7

Thread: Autobinding in AbstractXmlFlowExecutionTests in SWF 2.0.1

  1. #1

    Default Autobinding in AbstractXmlFlowExecutionTests in SWF 2.0.1

    Hi I am trying to test the following flow:

    Code:
    <flow xmlns="..namespace removed..">
    
    	<var name="domainObject" class="domain.DomainObject"/>
        
    	<view-state id="enterPropertyEj" model="domainObject">
            <transition on="next" to="enterPropertyBi" />
        </view-state>
        
    	<view-state id="enterPropertyBi" model="domainObject" view="/WEB-INF/jsp/enterPropertyBi.jsp" >
            <transition on="next" to="enterPropertySi" >
                <evaluate expression="businessLogic.doBusinessOne(domainObject)" result="flowScope.domainObject"/>
            </transition>
        </view-state>
        
    	<view-state id="enterPropertySi" model="domainObject" >
            <transition on="next" to="finished" >
                <evaluate expression="businessLogic.doBusinessTwo(domainObject)" result="flowScope.result"/>
            </transition>
        </view-state>
        
        <end-state id="finished" view="finished.jsp" />
    </flow>
    In SWF 1.0.5 I was able to test the whole execution of the flow. The business methods were invoked as well as binding, validation etc.

    Here I am trying to achieve similar effect with SWF 2.0.1

    Code:
        /**
         * A simple test of passing through the whole flow, and mimicking
         * setting individual properties in subsequent states.
         */
        public void testSimpleStartUp(){
            MockExternalContext context = new MockExternalContext();
            startFlow(context);
            assertCurrentStateEquals("enterPropertyEj");
            DomainObject domainObject = (DomainObject) getRequiredFlowAttribute("domainObject");
            assertNull(domainObject.getPropBi());
            assertNull(domainObject.getPropEj());
            assertNull(domainObject.getPropSi());
            
            context.getMockRequestParameterMap().put("propEj", "A");
            context.setEventId("next");
            resumeFlow(context);
            
            assertCurrentStateEquals("enterPropertyBi");
            domainObject = (DomainObject) getRequiredFlowAttribute("domainObject");
            assertEquals("A", domainObject.getPropEj());
        }
    DomainObject class looks like this:
    Code:
    public class DomainObject implements Serializable {
        private String propEj;
        private String propBi;
        private String propSi;
    /*setters, getters and the default constructor follow here*/
    The test I pasted above fails. There is no binding of value provided by me in
    Code:
    context.getMockRequestParameterMap().put("propEj", "A");
    to model object in the view state.

    What am I doing wrong? What is the proper way of writing such tests in SWF2? The samples from the Reference Guide seem to test only the individual states, but never the whole flow. Please help

    Regards

    Maciek

  2. #2

    Default WebFlow 2.0.1 Binding Problems

    I'm having the same problem. One of my form models gets bound when I deploy to Jetty but does not work in AbstractXmlFlowExecutionTests. Additionally, two of my other models do not bind at all either in test or when deployed. Do we have to prefix the request params like, 'command.property' or something? I can't seem to get this to work.

    Joe

  3. #3

    Default Resolution / new problem with OGNL?

    I fixed my problem by moving my model bean declaration to earlier in the flow, I had:
    Code:
    <view-state id="addresses" view="checkout-addresses" model="checkoutAddressForm">
            <on-entry>
                    <evaluate expression="checkoutAddressFormAction.createAddressForm(currentUser.name)"
                          result="flowScope.checkoutAddressForm" />
            </on-entry>
    ...
    which apparently caused problems with the binding to the model="checkoutAddressForm" which makes some sense although it is annoying. I suppose I could put the model in the scope on the transition to this state. In order to fix this I put the evaluate in my flow's on-start.

    However, I'm having a new problem with binding enums. I suspect that it is not due to flow configuration and that it is a problem with Spring calling OGNL with a String instead of an enum.

  4. #4

    Default The flow actually work

    My flow on the other hand works correctly, when deployed. It is the test that fails. It just behaves differently in the test environment.

    My model object is created at startup of the flow, and I use it in the first view state. What I don't understand is why my test case fails to bind the model to my request attributes.

    In my test code:
    Code:
            context.getMockRequestParameterMap().put("propEj", "A");
            context.setEventId("next");
            resumeFlow(context);
    This unfortunately is not treated by the test like form submission in the browser. In SWF 1.0.5 I was able to do that. Now AbstractXmlFlowExecutionTests differs it doesn't have signalEvent anymore. I just don't know what to use instead in SWF2.

    Regards

    Maciek

  5. #5
    Join Date
    Jun 2007
    Posts
    14

    Default

    Quote Originally Posted by maciej.kapusta View Post
    This unfortunately is not treated by the test like form submission in the browser. In SWF 1.0.5 I was able to do that. Now AbstractXmlFlowExecutionTests differs it doesn't have signalEvent anymore. I just don't know what to use instead in SWF2.

    Regards

    Maciek
    WHile this thread is extremely old, it appears to still be valid. I'm running into the same problem Maciek was. Tracing through the code I'm guessing it has something to do with the MockViewFactoryCreator's MockView inner class.

    The method
    Code:
    public void processUserEvent() {
    			// TODO - implement me as appropriate for a test environment
    		}
    appears to leave some code as an exercise for the tester.

    Anyone have a solution for this in hand? The current testing support seems to be limited to unit testing each state. You can't perform any type of integration testing between states beyond simply verifying the transition that would occur.

    Thanks,
    Bob

  6. #6
    Join Date
    Jun 2007
    Posts
    14

    Default JIRA Issue

    This was entered as a JIRA issue a while ago.

    http://jira.springframework.org/browse/SWF-689

    Hopefully it will get resolved...

  7. #7
    Join Date
    Nov 2006
    Posts
    9

    Default

    I know this is an old thread, but nothing seems to have changed with SWF-689 and I'm stuck wondering what others are doing to work around the issue.

    We integration test our flows (outside of any container), so having binding and validation is pretty important.

    I've been able to get binding working by injecting our own version of MockViewFactoryCreator:
    Code:
    /*
     * (non-Javadoc)
     * @see org.springframework.webflow.test.execution.AbstractExternalizedFlowExecutionTests#configureFlowBuilderContext(org.springframework.webflow.test.MockFlowBuilderContext)
     */
    @Override
    protected final void configureFlowBuilderContext(MockFlowBuilderContext builderContext) {
    	builderContext.getFlowBuilderServices().setViewFactoryCreator(new MockViewFactoryCreator());
    	builderContext.getFlowBuilderServices().setApplicationContext(appContext);
    	registerSubflows(builderContext);
    }
    Our MockViewFactoryCreator mostly uses the related MVC classes (AbstractMvcViewFactory, AbstractMvcView, etc) but doesn't do any real view resolution. It feels like I'm heading down the rabbit's hole and I'm wondering whether it's worth trying to go deeper and get validation to work.

    How are people working around this issue and why hasn't there been any Spring developer response (like whether it will ever be addressed?)

    Doug

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •