org.springframework.webflow.test.execution
Class AbstractExternalizedFlowExecutionTests

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.springframework.webflow.test.execution.AbstractFlowExecutionTests
              extended by org.springframework.webflow.test.execution.AbstractExternalizedFlowExecutionTests
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AbstractXmlFlowExecutionTests

public abstract class AbstractExternalizedFlowExecutionTests
extends AbstractFlowExecutionTests

Base class for flow integration tests that verify an externalized flow definition executes as expected. Supports caching of the flow definition built from an externalized resource to speed up test execution.

Author:
Keith Donald

Constructor Summary
AbstractExternalizedFlowExecutionTests()
          Constructs a default externalized flow execution test.
AbstractExternalizedFlowExecutionTests(java.lang.String name)
          Constructs an externalized flow execution test with given name.
 
Method Summary
protected  Flow createFlow(FlowDefinitionResource resource, FlowServiceLocator serviceLocator)
          Factory method to assemble a flow definition from a resource.
protected abstract  FlowBuilder createFlowBuilder(org.springframework.core.io.Resource resource, FlowServiceLocator serviceLocator)
          Factory method to create the builder that will build the flow definition whose execution will be tested.
protected  FlowDefinitionResource createFlowDefinitionResource(java.io.File file)
          Convenient factory method that creates a FlowDefinitionResource from a file.
protected  FlowDefinitionResource createFlowDefinitionResource(java.lang.String filePath)
          Convenient factory method that creates a FlowDefinitionResource from a file path.
protected  FlowDefinitionResource createFlowDefinitionResource(java.lang.String fileDirectory, java.lang.String fileName)
          Convenient factory method that creates a FlowDefinitionResource from a file in a directory.
protected  FlowServiceLocator createFlowServiceLocator()
          Returns the flow service locator to use during flow definition construction time for accessing externally managed flow artifacts such as actions and flows to be used as subflows.
protected  FlowDefinition getFlowDefinition()
          Returns the flow definition being tested.
protected abstract  FlowDefinitionResource getFlowDefinitionResource()
          Returns the pointer to the resource that houses the definition of the flow to be tested.
protected  boolean isCacheFlowDefinition()
          Returns if flow definition caching is turned on.
protected  void registerMockServices(MockFlowServiceLocator serviceRegistry)
          Template method called by createFlowServiceLocator() to allow registration of mock implementations of services needed to test the flow execution.
protected  void setCacheFlowDefinition(boolean cacheFlowDefinition)
          Sets the flag indicating if the flow definition built from an externalized resource as part of this test should be cached.
protected  void setFlowExecutionAttributes(AttributeMap executionAttributes)
          Sets system attributes to be associated with the flow execution the next time one is started by this test.
protected  void setFlowExecutionListener(FlowExecutionListener executionListener)
          Set a single listener to be attached to the flow execution the next time one is started by this test.
protected  void setFlowExecutionListeners(FlowExecutionListener[] executionListeners)
          Set the listeners to be attached to the flow execution the next time one is started by this test.
 
Methods inherited from class org.springframework.webflow.test.execution.AbstractFlowExecutionTests
applicationView, assertActiveFlowEquals, assertCurrentStateEquals, assertFlowExecutionActive, assertFlowExecutionEnded, assertModelAttributeCollectionSize, assertModelAttributeEquals, assertModelAttributeNotNull, assertModelAttributeNull, assertViewNameEquals, createExternalContext, createFlowExecutionFactory, evaluateModelAttributeExpression, externalRedirect, flowDefinitionRedirect, flowExecutionRedirect, getConversationAttribute, getFlashAttribute, getFlowAttribute, getFlowExecution, getFlowExecutionFactory, getRequiredConversationAttribute, getRequiredConversationAttribute, getRequiredFlashAttribute, getRequiredFlashAttribute, getRequiredFlowAttribute, getRequiredFlowAttribute, nullView, refresh, refresh, setExpressionParser, signalEvent, signalEvent, signalEvent, startFlow, startFlow, startFlow, updateFlowExecution
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractExternalizedFlowExecutionTests

public AbstractExternalizedFlowExecutionTests()
Constructs a default externalized flow execution test.

See Also:
TestCase.setName(String)

AbstractExternalizedFlowExecutionTests

public AbstractExternalizedFlowExecutionTests(java.lang.String name)
Constructs an externalized flow execution test with given name.

Parameters:
name - the name of the test
Since:
1.0.2
Method Detail

isCacheFlowDefinition

protected boolean isCacheFlowDefinition()
Returns if flow definition caching is turned on.


setCacheFlowDefinition

protected void setCacheFlowDefinition(boolean cacheFlowDefinition)
Sets the flag indicating if the flow definition built from an externalized resource as part of this test should be cached. Default is false.


setFlowExecutionAttributes

protected void setFlowExecutionAttributes(AttributeMap executionAttributes)
Sets system attributes to be associated with the flow execution the next time one is started by this test. Useful for assigning attributes that influence flow execution behavior.

Parameters:
executionAttributes - the system attributes to assign

setFlowExecutionListener

protected void setFlowExecutionListener(FlowExecutionListener executionListener)
Set a single listener to be attached to the flow execution the next time one is started by this test. Useful for attaching a listener that does test assertions during the execution of the flow.

Parameters:
executionListener - the listener to attach

setFlowExecutionListeners

protected void setFlowExecutionListeners(FlowExecutionListener[] executionListeners)
Set the listeners to be attached to the flow execution the next time one is started by this test. Useful for attaching listeners that do test assertions during the execution of the flow.

Parameters:
executionListeners - the listeners to attach
Since:
1.0.4

getFlowDefinition

protected final FlowDefinition getFlowDefinition()
Returns the flow definition being tested.

Specified by:
getFlowDefinition in class AbstractFlowExecutionTests
Returns:
the flow definition

createFlowServiceLocator

protected FlowServiceLocator createFlowServiceLocator()
Returns the flow service locator to use during flow definition construction time for accessing externally managed flow artifacts such as actions and flows to be used as subflows.

This implementation just creates a MockFlowServiceLocator and populates it with services by calling registerMockServices(MockFlowServiceLocator).

Returns:
the flow artifact factory

registerMockServices

protected void registerMockServices(MockFlowServiceLocator serviceRegistry)
Template method called by createFlowServiceLocator() to allow registration of mock implementations of services needed to test the flow execution. Useful when testing flow definitions in execution in isolation from flows and middle-tier services. Subclasses may override.

Parameters:
serviceRegistry - the mock service registry (and locator)

createFlow

protected final Flow createFlow(FlowDefinitionResource resource,
                                FlowServiceLocator serviceLocator)
Factory method to assemble a flow definition from a resource. Called by getFlowDefinition() to create the "main" flow to test. May also be called by subclasses to create subflow definitions whose executions should also be exercised by this test.

Parameters:
resource - the flow definition resource
Returns:
the built flow definition, ready for execution
See Also:
createFlowBuilder(Resource, FlowServiceLocator)

getFlowDefinitionResource

protected abstract FlowDefinitionResource getFlowDefinitionResource()
Returns the pointer to the resource that houses the definition of the flow to be tested. Subclasses must implement.

Example usage:

 protected FlowDefinitionResource getFlowDefinitionResource() {
        return createFlowDefinitionResource("/WEB-INF/flows/order-flow.xml");
 }
 

Returns:
the flow definition resource

createFlowBuilder

protected abstract FlowBuilder createFlowBuilder(org.springframework.core.io.Resource resource,
                                                 FlowServiceLocator serviceLocator)
Factory method to create the builder that will build the flow definition whose execution will be tested. Subclasses must implement.

A subclass may return a builder that sets up mock implementations of services needed locally by the flow definition at runtime.

Parameters:
resource - the externalized flow definition resource location
serviceLocator - the flow service locator
Returns:
the flow builder that will build the flow to be tested

createFlowDefinitionResource

protected final FlowDefinitionResource createFlowDefinitionResource(java.lang.String filePath)
Convenient factory method that creates a FlowDefinitionResource from a file path. Typically called by subclasses overriding getFlowDefinitionResource().

Parameters:
filePath - the full path to the externalized flow definition file
Returns:
the flow definition resource

createFlowDefinitionResource

protected final FlowDefinitionResource createFlowDefinitionResource(java.lang.String fileDirectory,
                                                                    java.lang.String fileName)
Convenient factory method that creates a FlowDefinitionResource from a file in a directory. Typically called by subclasses overriding getFlowDefinitionResource().

Parameters:
fileDirectory - the directory containing the file
fileName - the short file name
Returns:
the flow definition resource pointing to the file

createFlowDefinitionResource

protected FlowDefinitionResource createFlowDefinitionResource(java.io.File file)
Convenient factory method that creates a FlowDefinitionResource from a file. Typically called by subclasses overriding getFlowDefinitionResource().

Parameters:
file - the file
Returns:
the flow definition resource


Copyright © 2004-2007. All Rights Reserved.