|
|
|
|
@@ -32,10 +32,9 @@ import org.springframework.webflow.execution.factory.StaticFlowExecutionListener
|
|
|
|
|
import org.springframework.webflow.test.MockFlowServiceLocator;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
|
|
|
|
public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlowExecutionTests {
|
|
|
|
|
@@ -46,8 +45,8 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
|
|
|
|
|
private static FlowDefinition cachedFlowDefinition;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The flag indicating if the flow definition built from an externalized
|
|
|
|
|
* resource as part of this test should be cached.
|
|
|
|
|
* The flag indicating if the flow definition built from an externalized resource as part of this test should be
|
|
|
|
|
* cached.
|
|
|
|
|
*/
|
|
|
|
|
private boolean cacheFlowDefinition = false;
|
|
|
|
|
|
|
|
|
|
@@ -58,7 +57,7 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
|
|
|
|
|
public AbstractExternalizedFlowExecutionTests() {
|
|
|
|
|
super();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructs an externalized flow execution test with given name.
|
|
|
|
|
* @param name the name of the test
|
|
|
|
|
@@ -69,13 +68,13 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Internal helper that return the flow execution factory used by the
|
|
|
|
|
* test cast to a {@link FlowExecutionImplFactory}.
|
|
|
|
|
* Internal helper that returns the flow execution factory used by the test cast to a
|
|
|
|
|
* {@link FlowExecutionImplFactory}.
|
|
|
|
|
*/
|
|
|
|
|
private FlowExecutionImplFactory getFlowExecutionImplFactory() {
|
|
|
|
|
return (FlowExecutionImplFactory)getFlowExecutionFactory();
|
|
|
|
|
return (FlowExecutionImplFactory) getFlowExecutionFactory();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns if flow definition caching is turned on.
|
|
|
|
|
*/
|
|
|
|
|
@@ -84,18 +83,16 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the flag indicating if the flow definition built from an
|
|
|
|
|
* externalized resource as part of this test should be cached.
|
|
|
|
|
* Default is false.
|
|
|
|
|
* Sets the flag indicating if the flow definition built from an externalized resource as part of this test should
|
|
|
|
|
* be cached. Default is false.
|
|
|
|
|
*/
|
|
|
|
|
protected void setCacheFlowDefinition(boolean cacheFlowDefinition) {
|
|
|
|
|
this.cacheFlowDefinition = cacheFlowDefinition;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets system attributes to be associated with the flow execution the next
|
|
|
|
|
* time one is {@link #startFlow() started} by this test. Useful for
|
|
|
|
|
* assigning attributes that influence flow execution behavior.
|
|
|
|
|
* Sets system attributes to be associated with the flow execution the next time one is {@link #startFlow() started}
|
|
|
|
|
* by this test. Useful for assigning attributes that influence flow execution behavior.
|
|
|
|
|
* @param executionAttributes the system attributes to assign
|
|
|
|
|
*/
|
|
|
|
|
protected void setFlowExecutionAttributes(AttributeMap executionAttributes) {
|
|
|
|
|
@@ -103,27 +100,29 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the listener to be attached to the flow execution the next time one
|
|
|
|
|
* is {@link #startFlow() started} by this test. Useful for attaching a
|
|
|
|
|
* listener that does test assertions during the execution of the flow.
|
|
|
|
|
* Set a single listener to be attached to the flow execution the next time one is {@link #startFlow() started} by
|
|
|
|
|
* this test. Useful for attaching a listener that does test assertions during the execution of the flow.
|
|
|
|
|
* @param executionListener the listener to attach
|
|
|
|
|
*/
|
|
|
|
|
protected void setFlowExecutionListener(FlowExecutionListener executionListener) {
|
|
|
|
|
getFlowExecutionImplFactory().setExecutionListenerLoader(
|
|
|
|
|
new StaticFlowExecutionListenerLoader(executionListener));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the listeners to be attached to the flow execution the next time one
|
|
|
|
|
* is {@link #startFlow() started} by this test. Useful for attaching
|
|
|
|
|
* listeners that do test assertions during the execution of the flow.
|
|
|
|
|
* Set the listeners to be attached to the flow execution the next time one is {@link #startFlow() started} by this
|
|
|
|
|
* test. Useful for attaching listeners that do test assertions during the execution of the flow.
|
|
|
|
|
* @param executionListeners the listeners to attach
|
|
|
|
|
* @since 1.0.4
|
|
|
|
|
*/
|
|
|
|
|
protected void setFlowExecutionListeners(FlowExecutionListener[] executionListeners) {
|
|
|
|
|
getFlowExecutionImplFactory().setExecutionListenerLoader(
|
|
|
|
|
new StaticFlowExecutionListenerLoader(executionListeners));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the flow definition being tested.
|
|
|
|
|
*/
|
|
|
|
|
protected final FlowDefinition getFlowDefinition() {
|
|
|
|
|
if (isCacheFlowDefinition() && cachedFlowDefinition != null) {
|
|
|
|
|
return cachedFlowDefinition;
|
|
|
|
|
@@ -137,12 +136,11 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the flow artifact factory to use during flow definition
|
|
|
|
|
* construction time for accessing externally managed flow artifacts such as
|
|
|
|
|
* actions and flows to be used as subflows.
|
|
|
|
|
* 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.
|
|
|
|
|
* <p>
|
|
|
|
|
* This implementation just creates a {@link MockFlowServiceLocator} and
|
|
|
|
|
* populates it with services by calling {@link #registerMockServices(MockFlowServiceLocator)}.
|
|
|
|
|
* This implementation just creates a {@link MockFlowServiceLocator} and populates it with services by calling
|
|
|
|
|
* {@link #registerMockServices(MockFlowServiceLocator)}.
|
|
|
|
|
* @return the flow artifact factory
|
|
|
|
|
*/
|
|
|
|
|
protected FlowServiceLocator createFlowServiceLocator() {
|
|
|
|
|
@@ -152,20 +150,18 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Template method called by {@link #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.
|
|
|
|
|
* Template method called by {@link #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.
|
|
|
|
|
* @param serviceRegistry the mock service registry (and locator)
|
|
|
|
|
*/
|
|
|
|
|
protected void registerMockServices(MockFlowServiceLocator serviceRegistry) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Factory method to assemble another flow definition from a resource.
|
|
|
|
|
* Called by {@link #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.
|
|
|
|
|
* Factory method to assemble a flow definition from a resource. Called by {@link #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.
|
|
|
|
|
* @param resource the flow definition resource
|
|
|
|
|
* @return the built flow definition, ready for execution
|
|
|
|
|
* @see #createFlowBuilder(Resource, FlowServiceLocator)
|
|
|
|
|
@@ -177,22 +173,25 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the pointer to the resource that houses the definition of the
|
|
|
|
|
* flow to be tested. Subclasses must implement.
|
|
|
|
|
* Returns the pointer to the resource that houses the definition of the flow to be tested. Subclasses must
|
|
|
|
|
* implement.
|
|
|
|
|
* <p>
|
|
|
|
|
* Example usage:
|
|
|
|
|
* <pre class="code">
|
|
|
|
|
* protected FlowDefinitionResource getFlowDefinitionResource() {
|
|
|
|
|
* return createFlowDefinitionResource("/WEB-INF/flows/order-flow.xml");
|
|
|
|
|
* }
|
|
|
|
|
* protected FlowDefinitionResource getFlowDefinitionResource() {
|
|
|
|
|
* return createFlowDefinitionResource("/WEB-INF/flows/order-flow.xml");
|
|
|
|
|
* }
|
|
|
|
|
* </pre>
|
|
|
|
|
* @return the flow definition resource
|
|
|
|
|
*/
|
|
|
|
|
protected abstract FlowDefinitionResource getFlowDefinitionResource();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Factory method to create the builder that will build the flow whose
|
|
|
|
|
* execution will be tested. Subclasses must override.
|
|
|
|
|
* Factory method to create the builder that will build the flow definition whose execution will be tested.
|
|
|
|
|
* Subclasses must implement.
|
|
|
|
|
* <p>
|
|
|
|
|
* A subclass may return a builder that sets up mock implementations of services needed locally by the flow
|
|
|
|
|
* definition at runtime.
|
|
|
|
|
* @param resource the externalized flow definition resource location
|
|
|
|
|
* @param serviceLocator the flow service locator
|
|
|
|
|
* @return the flow builder that will build the flow to be tested
|
|
|
|
|
@@ -200,9 +199,8 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
|
|
|
|
|
protected abstract FlowBuilder createFlowBuilder(Resource resource, FlowServiceLocator serviceLocator);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Convenient factory method that creates a {@link FlowDefinitionResource}
|
|
|
|
|
* from a file path. Typically called by subclasses overriding
|
|
|
|
|
* {@link #getFlowDefinitionResource()}.
|
|
|
|
|
* Convenient factory method that creates a {@link FlowDefinitionResource} from a file path. Typically called by
|
|
|
|
|
* subclasses overriding {@link #getFlowDefinitionResource()}.
|
|
|
|
|
* @param filePath the full path to the externalized flow definition file
|
|
|
|
|
* @return the flow definition resource
|
|
|
|
|
*/
|
|
|
|
|
@@ -211,9 +209,8 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Convenient factory method that creates a {@link FlowDefinitionResource}
|
|
|
|
|
* from a file in a directory. Typically called by subclasses overriding
|
|
|
|
|
* {@link #getFlowDefinitionResource()}.
|
|
|
|
|
* Convenient factory method that creates a {@link FlowDefinitionResource} from a file in a directory. Typically
|
|
|
|
|
* called by subclasses overriding {@link #getFlowDefinitionResource()}.
|
|
|
|
|
* @param fileDirectory the directory containing the file
|
|
|
|
|
* @param fileName the short file name
|
|
|
|
|
* @return the flow definition resource pointing to the file
|
|
|
|
|
@@ -223,8 +220,8 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Convenient factory method that creates a {@link FlowDefinitionResource}
|
|
|
|
|
* from a file.
|
|
|
|
|
* Convenient factory method that creates a {@link FlowDefinitionResource} from a file. Typically
|
|
|
|
|
* called by subclasses overriding {@link #getFlowDefinitionResource()}.
|
|
|
|
|
* @param file the file
|
|
|
|
|
* @return the flow definition resource
|
|
|
|
|
*/
|
|
|
|
|
|