Announcement Announcement Module
Collapse
No announcement yet.
Testing output mappings using FlowExecutionListenerAdapter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Testing output mappings using FlowExecutionListenerAdapter

    Hi there,

    I am currently trying to test on of my sub flows and want to make sure that the values I return as output mappers are indeed what I think they should be.

    Searching the forums brought up this post (quoted below)

    Originally posted by Keith Donald View Post
    What you want to test here are that any flow output attributes are returned correctly by your end state. You can do this by attaching a custom FlowExecutionListener for your end-state test scenario and verifying the sessionOutput in the sessionEnded callback has the right stuff. You can also get a hold of the FlowSession directly in that callback as well.

    Besides that I'd test what is put in the returned ViewSelection is accurate. I don't think it is correct to test the internals of a flow after the flow has ended--as the internals no longer exist!
    Keith
    From what I can see you are supposed to set up a FlowExecutionListenerAdapter on starting the flow, then check the values of the sessionOutput in the sessionEnded callback.

    The problem I am having is that I have no idea how to do this code wise, and was wondering whether anyone who has done this could post a simple code example of how they went about this, both the initial setting up then the testing of output mappings at the end.

    I have searched the samples, and also scoured existing posts on the forums to no avail, but no examples of this seem to exist.

    Many thanks!
    Al

  • #2
    What you want to do is override the createFlowExecutionFactory() method defined by the AbstractFlowExecutionTests and setup a FlowExecutionFactory that registers some listeners when the FlowExecution is created. Like so:

    Code:
    public class SearchFlowExecutionTests extends AbstractXmlFlowExecutionTests {
    	
    	protected FlowExecutionFactory createFlowExecutionFactory() {
    		FlowExecutionImplFactory factory = new FlowExecutionImplFactory();
    		FlowExecutionListener testListener = new FlowExecutionListenerAdapter() {
    			public void sessionEnded(RequestContext context, FlowSession session, AttributeMap output) {
    				// verify output here
    				System.out.println(output);
    			}
    		};
    		factory.setExecutionListenerLoader(new StaticFlowExecutionListenerLoader(testListener));
    		return factory;
    	}
    	...
    Erwin

    Comment


    • #3
      It should be easier than that---take a look at the set* methods on AbstractXmlFlowExecutionTest hierarchy and I believe there is a setFlowExectionListener...

      Keith

      Comment


      • #4
        It doesn't exist in SWF 1.0.1 but it would probably make sense to add something like that.

        Erwin

        Comment


        • #5
          Mmm,

          There is a setFlowExecutionListener on AbstractExternalizedFlowExecutionTests...
          It would probably have made more sense to have that method on the AbstractFlowExecutionTests.

          Erwin
          Last edited by klr8; Jan 15th, 2007, 11:09 AM.

          Comment


          • #6
            Thanks to both Erwin and Keith for their responses - Erwin's code sample worked perfectly.

            Al

            Comment

            Working...
            X