|
Spring Web Flow | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.springframework.webflow.test.execution.AbstractFlowExecutionTests
public abstract class AbstractFlowExecutionTests
Base class for tests that verify a flow executes as expected. Flow execution tests authored by subclasses should test that a flow responds to all supported transition criteria correctly, transitioning to the correct states and producing the expected results on the occurrence of external events.
A typical flow execution test case will test:
startFlow(MutableAttributeMap, ExternalContext)
).
resumeFlow(ExternalContext)
variants and the
setCurrentState(String)
for more information).
A flow execution test can effectively automate and validate the orchestration required to drive an end-to-end business task that spans several steps involving the user to complete. Such tests are a good way to test your system top-down starting at the web-tier and pushing through all the way to the DB without having to deploy to a servlet or portlet container. In addition, they can be used to effectively test a flow's execution (the web layer) standalone, typically with a mock service layer.
Constructor Summary | |
---|---|
AbstractFlowExecutionTests()
Constructs a default flow execution test. |
|
AbstractFlowExecutionTests(java.lang.String name)
Constructs a flow execution test with given name. |
Method Summary | |
---|---|
protected void |
assertActiveFlowEquals(java.lang.String expectedActiveFlowId)
Assert that the active flow session is for the flow with the provided id. |
protected void |
assertCurrentStateEquals(java.lang.String expectedCurrentStateId)
Assert that the current state of the flow execution equals the provided state id. |
protected void |
assertFlowExecutionActive()
Assert that the entire flow execution is active; that is, it has not ended and has been started. |
protected void |
assertFlowExecutionEnded()
Assert that the flow execution has ended; that is, it is no longer active. |
protected void |
assertFlowExecutionOutcomeEquals(java.lang.String outcome)
Assert that the flow execution has ended with the outcome specified. |
protected void |
assertResponseWrittenEquals(java.lang.String response,
MockExternalContext context)
Assert that the response written to the mock context equals the response provided. |
protected FlowExecutionFactory |
createFlowExecutionFactory()
Factory method to create the flow execution factory. |
protected java.lang.Object |
getConversationAttribute(java.lang.String attributeName)
Returns the attribute in conversation scope. |
protected MutableAttributeMap<java.lang.Object> |
getConversationScope()
Returns conversation scope. |
protected java.lang.Object |
getFlowAttribute(java.lang.String attributeName)
Returns the attribute in flow scope. |
protected abstract FlowDefinition |
getFlowDefinition()
Returns the flow definition to be tested. |
protected FlowExecution |
getFlowExecution()
Returns the flow execution being tested. |
protected FlowExecutionFactory |
getFlowExecutionFactory()
Gets the factory that will create the flow execution to test. |
protected FlowExecutionOutcome |
getFlowExecutionOutcome()
Returns the flow execution outcome that was reached. |
protected MutableAttributeMap<java.lang.Object> |
getFlowScope()
Returns flow scope. |
protected java.lang.Object |
getRequiredConversationAttribute(java.lang.String attributeName)
Returns the required attribute in conversation scope; asserts the attribute is present. |
protected java.lang.Object |
getRequiredConversationAttribute(java.lang.String attributeName,
java.lang.Class<?> requiredType)
Returns the required attribute in conversation scope; asserts the attribute is present and of the required type. |
protected java.lang.Object |
getRequiredFlowAttribute(java.lang.String attributeName)
Returns the required attribute in flow scope; asserts the attribute is present. |
protected java.lang.Object |
getRequiredFlowAttribute(java.lang.String attributeName,
java.lang.Class<java.lang.Object> requiredType)
Returns the required attribute in flow scope; asserts the attribute is present and of the correct type. |
protected java.lang.Object |
getRequiredViewAttribute(java.lang.String attributeName)
Returns the required attribute in view scope; asserts the attribute is present. |
protected java.lang.Object |
getRequiredViewAttribute(java.lang.String attributeName,
java.lang.Class<java.lang.Object> requiredType)
Returns the required attribute in view scope; asserts the attribute is present and of the correct type. |
protected java.lang.Object |
getViewAttribute(java.lang.String attributeName)
Returns the attribute in view scope. |
protected MutableAttributeMap<java.lang.Object> |
getViewScope()
Returns view scope. |
protected void |
resumeFlow(ExternalContext context)
Resume the flow execution to be tested. |
protected void |
setCurrentState(java.lang.String stateId)
Sets the current state of the flow execution being tested. |
protected void |
startFlow(ExternalContext context)
Start the flow execution to be tested. |
protected void |
startFlow(MutableAttributeMap<?> input,
ExternalContext context)
Start the flow execution to be tested. |
protected void |
updateFlowExecution(FlowExecution flowExecution)
Directly update the flow execution used by the test by setting it to given flow execution. |
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 |
---|
public AbstractFlowExecutionTests()
TestCase.setName(String)
public AbstractFlowExecutionTests(java.lang.String name)
name
- the name of the testMethod Detail |
---|
protected FlowExecutionFactory getFlowExecutionFactory()
createFlowExecutionFactory()
protected void startFlow(ExternalContext context) throws FlowExecutionException
context
- the external context providing information about the caller's environment, used by the flow
execution during the start operation
FlowExecutionException
- if an exception was thrown while starting the flow executionprotected void startFlow(MutableAttributeMap<?> input, ExternalContext context) throws FlowExecutionException
input
- input to pass the flowcontext
- the external context providing information about the caller's environment, used by the flow
execution during the start operation
FlowExecutionException
- if an exception was thrown while starting the flow executionprotected void resumeFlow(ExternalContext context) throws FlowExecutionException
context
- the external context providing information about the caller's environment, used by the flow
execution during the start operation
FlowExecutionException
- if an exception was thrown while starting the flow executionprotected void setCurrentState(java.lang.String stateId)
stateId
- the state idprotected FlowExecution getFlowExecution() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- the execution has not been startedprotected FlowExecutionOutcome getFlowExecutionOutcome()
protected MutableAttributeMap<java.lang.Object> getViewScope() throws java.lang.IllegalStateException
java.lang.IllegalStateException
protected MutableAttributeMap<java.lang.Object> getFlowScope() throws java.lang.IllegalStateException
java.lang.IllegalStateException
protected MutableAttributeMap<java.lang.Object> getConversationScope() throws java.lang.IllegalStateException
java.lang.IllegalStateException
protected java.lang.Object getViewAttribute(java.lang.String attributeName)
attributeName
- the name of the attribute
protected java.lang.Object getRequiredViewAttribute(java.lang.String attributeName) throws java.lang.IllegalStateException
attributeName
- the name of the attribute
java.lang.IllegalStateException
- if the attribute was not presentprotected java.lang.Object getRequiredViewAttribute(java.lang.String attributeName, java.lang.Class<java.lang.Object> requiredType) throws java.lang.IllegalStateException
attributeName
- the name of the attribute
java.lang.IllegalStateException
- if the attribute was not present or was of the wrong typeprotected java.lang.Object getFlowAttribute(java.lang.String attributeName)
attributeName
- the name of the attribute
protected java.lang.Object getRequiredFlowAttribute(java.lang.String attributeName) throws java.lang.IllegalStateException
attributeName
- the name of the attribute
java.lang.IllegalStateException
- if the attribute was not presentprotected java.lang.Object getRequiredFlowAttribute(java.lang.String attributeName, java.lang.Class<java.lang.Object> requiredType) throws java.lang.IllegalStateException
attributeName
- the name of the attribute
java.lang.IllegalStateException
- if the attribute was not present or was of the wrong typeprotected java.lang.Object getConversationAttribute(java.lang.String attributeName)
attributeName
- the name of the attribute
protected java.lang.Object getRequiredConversationAttribute(java.lang.String attributeName) throws java.lang.IllegalStateException
attributeName
- the name of the attribute
java.lang.IllegalStateException
- if the attribute was not presentprotected java.lang.Object getRequiredConversationAttribute(java.lang.String attributeName, java.lang.Class<?> requiredType) throws java.lang.IllegalStateException
attributeName
- the name of the attribute
java.lang.IllegalStateException
- if the attribute was not present or not of the required typeprotected void assertFlowExecutionActive()
protected void assertActiveFlowEquals(java.lang.String expectedActiveFlowId)
expectedActiveFlowId
- the flow id that should have a session active in the tested flow executionprotected void assertFlowExecutionEnded()
protected void assertFlowExecutionOutcomeEquals(java.lang.String outcome)
outcome
- the name of the flow execution outcomeprotected void assertCurrentStateEquals(java.lang.String expectedCurrentStateId)
expectedCurrentStateId
- the expected current stateprotected void assertResponseWrittenEquals(java.lang.String response, MockExternalContext context)
response
- the expected responsecontext
- the mock external context that was written toprotected FlowExecutionFactory createFlowExecutionFactory()
FlowExecutionImplFactory
instance.
protected void updateFlowExecution(FlowExecution flowExecution)
flowExecution
- the flow execution to useprotected abstract FlowDefinition getFlowDefinition()
|
Spring Web Flow | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |