Java Doc for AbstractFlowExecutionTests.java in  » Workflow-Engines » spring-webflow-1.0.4 » org » springframework » webflow » test » execution » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » spring webflow 1.0.4 » org.springframework.webflow.test.execution 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.springframework.webflow.test.execution.AbstractFlowExecutionTests

All known Subclasses:   org.springframework.webflow.test.execution.AbstractExternalizedFlowExecutionTests,
AbstractFlowExecutionTests
abstract public class AbstractFlowExecutionTests extends TestCase (Code)
Base class for integration tests that verify a flow executes as expected. Flow execution tests captured 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 occurence of possible external (user) events.

More specifically, a typical flow execution test case will test:

  • That the flow execution starts as expected given a request from an external context containing potential input attributes (see the AbstractFlowExecutionTests.startFlow(MutableAttributeMap,ExternalContext) variants).
  • That given the set of supported state transition criteria a state executes the appropriate transition when a matching event is signaled (with potential input request parameters, see the AbstractFlowExecutionTests.signalEvent(String,ExternalContext) variants). A test case should be coded for each logical event that can occur, where an event drives a possible path through the flow. The goal should be to exercise all possible paths of the flow. Use a test coverage tool like Clover or Emma to assist with measuring your test's effectiveness.
  • That given a transition that leads to an interactive state type (a view state or an end state) that the view selection returned to the client matches what was expected and the current state of the flow matches what is expected.

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. Both styles of testing are valuable and supported.
author:
   Keith Donald




Constructor Summary
public  AbstractFlowExecutionTests()
     Constructs a default flow execution test.
public  AbstractFlowExecutionTests(String name)
     Constructs a flow execution test with given name.

Method Summary
protected  ApplicationViewapplicationView(ViewSelection viewSelection)
     Assert that the returned view selection is an instance of ApplicationView .
protected  voidassertActiveFlowEquals(String expectedActiveFlowId)
     Assert that the active flow session is for the flow with the provided id.
protected  voidassertCurrentStateEquals(String expectedCurrentStateId)
     Assert that the current state of the flow execution equals the provided state id.
protected  voidassertFlowExecutionActive()
     Assert that the entire flow execution is active; that is, it has not ended and has been started.
protected  voidassertFlowExecutionEnded()
     Assert that the entire flow execution has ended; that is, it is no longer active.
protected  voidassertModelAttributeCollectionSize(int expectedSize, String attributeName, ApplicationView viewSelection)
     Assert that the selected view contains the specified collection model attribute with the provided expected size.
protected  voidassertModelAttributeEquals(Object expectedValue, String attributeName, ApplicationView viewSelection)
     Assert that the selected view contains the specified model attribute with the provided expected value.
protected  voidassertModelAttributeNotNull(String attributeName, ApplicationView viewSelection)
     Assert that the selected view contains the specified model attribute.
protected  voidassertModelAttributeNull(String attributeName, ApplicationView viewSelection)
     Assert that the selected view does not contain the specified model attribute.
protected  voidassertViewNameEquals(String expectedViewName, ApplicationView viewSelection)
     Assert that the view name equals the provided value.
protected  ExternalContextcreateExternalContext(ParameterMap requestParameters)
     Creates an ExternalContext instance.
protected  FlowExecutionFactorycreateFlowExecutionFactory()
     Factory method to create the flow execution factory.
protected  ObjectevaluateModelAttributeExpression(String attributeName, Map model)
     Evaluates a model attribute expression.
protected  ExternalRedirectexternalRedirect(ViewSelection viewSelection)
     Assert that the returned view selection is an instance of ExternalRedirect .
protected  FlowDefinitionRedirectflowDefinitionRedirect(ViewSelection viewSelection)
     Assert that the returned view selection is an instance of FlowDefinitionRedirect .
protected  FlowExecutionRedirectflowExecutionRedirect(ViewSelection viewSelection)
     Assert that the returned view selection is an instance of FlowExecutionRedirect .
protected  ObjectgetConversationAttribute(String attributeName)
     Returns the attribute in conversation scope.
protected  ObjectgetFlashAttribute(String attributeName)
     Returns the attribute in flash scope.
protected  ObjectgetFlowAttribute(String attributeName)
     Returns the attribute in flow scope.
abstract protected  FlowDefinitiongetFlowDefinition()
     Returns the flow definition to be tested.
protected  FlowExecutiongetFlowExecution()
     Returns the flow execution being tested.
protected  FlowExecutionFactorygetFlowExecutionFactory()
     Gets the factory that will create the flow execution to test.
protected  ObjectgetRequiredConversationAttribute(String attributeName)
     Returns the required attribute in conversation scope; asserts the attribute is present.
protected  ObjectgetRequiredConversationAttribute(String attributeName, Class requiredType)
     Returns the required attribute in conversation scope; asserts the attribute is present and of the required type.
protected  ObjectgetRequiredFlashAttribute(String attributeName)
     Returns the required attribute in flash scope; asserts the attribute is present.
protected  ObjectgetRequiredFlashAttribute(String attributeName, Class requiredType)
     Returns the required attribute in flash scope; asserts the attribute is present and of the correct type.
protected  ObjectgetRequiredFlowAttribute(String attributeName)
     Returns the required attribute in flow scope; asserts the attribute is present.
protected  ObjectgetRequiredFlowAttribute(String attributeName, Class requiredType)
     Returns the required attribute in flow scope; asserts the attribute is present and of the correct type.
protected  voidnullView(ViewSelection viewSelection)
     Assert that the returned view selection is the ViewSelection.NULL_VIEW .
protected  ViewSelectionrefresh()
     Refresh the flow execution being tested, asking the current view state to make a "refresh" view selection.
protected  ViewSelectionrefresh(ExternalContext context)
     Refresh the flow execution being tested, asking the current view state state to make a "refresh" view selection.
public  voidsetExpressionParser(ExpressionParser expressionParser)
     Set the expression parser responsible for parsing expression strings into evaluatable expression objects.
protected  ViewSelectionsignalEvent(String eventId)
     Signal an occurence of an event in the current state of the flow execution being tested.
protected  ViewSelectionsignalEvent(String eventId, ParameterMap requestParameters)
     Signal an occurence of an event in the current state of the flow execution being tested.
protected  ViewSelectionsignalEvent(String eventId, ExternalContext context)
     Signal an occurence of an event in the current state of the flow execution being tested.

Note: signaling an event will cause state transitions to occur in a chain until control is returned to the caller.

protected  ViewSelectionstartFlow()
     Start the flow execution to be tested.
protected  ViewSelectionstartFlow(MutableAttributeMap input)
     Start the flow execution to be tested.
protected  ViewSelectionstartFlow(MutableAttributeMap input, ExternalContext context)
     Start the flow execution to be tested.

This is the most flexible of the start methods.

protected  voidupdateFlowExecution(FlowExecution flowExecution)
     Directly update the flow execution used by the test by setting it to given flow execution.


Constructor Detail
AbstractFlowExecutionTests
public AbstractFlowExecutionTests()(Code)
Constructs a default flow execution test.
See Also:   AbstractFlowExecutionTests.setName(String)



AbstractFlowExecutionTests
public AbstractFlowExecutionTests(String name)(Code)
Constructs a flow execution test with given name.
Parameters:
  name - the name of the test
since:
   1.0.2




Method Detail
applicationView
protected ApplicationView applicationView(ViewSelection viewSelection)(Code)
Assert that the returned view selection is an instance of ApplicationView .
Parameters:
  viewSelection - the view selection



assertActiveFlowEquals
protected void assertActiveFlowEquals(String expectedActiveFlowId)(Code)
Assert that the active flow session is for the flow with the provided id.
Parameters:
  expectedActiveFlowId - the flow id that should have a session activein the tested flow execution



assertCurrentStateEquals
protected void assertCurrentStateEquals(String expectedCurrentStateId)(Code)
Assert that the current state of the flow execution equals the provided state id.
Parameters:
  expectedCurrentStateId - the expected current state



assertFlowExecutionActive
protected void assertFlowExecutionActive()(Code)
Assert that the entire flow execution is active; that is, it has not ended and has been started.



assertFlowExecutionEnded
protected void assertFlowExecutionEnded()(Code)
Assert that the entire flow execution has ended; that is, it is no longer active.



assertModelAttributeCollectionSize
protected void assertModelAttributeCollectionSize(int expectedSize, String attributeName, ApplicationView viewSelection)(Code)
Assert that the selected view contains the specified collection model attribute with the provided expected size.
Parameters:
  expectedSize - the expected size
Parameters:
  attributeName - the collection attribute name (can be an expression
Parameters:
  viewSelection - the selected view with a model attribute map toassert against



assertModelAttributeEquals
protected void assertModelAttributeEquals(Object expectedValue, String attributeName, ApplicationView viewSelection)(Code)
Assert that the selected view contains the specified model attribute with the provided expected value.
Parameters:
  expectedValue - the expected value
Parameters:
  attributeName - the attribute name (can be an expression)
Parameters:
  viewSelection - the selected view with a model attribute map toassert against



assertModelAttributeNotNull
protected void assertModelAttributeNotNull(String attributeName, ApplicationView viewSelection)(Code)
Assert that the selected view contains the specified model attribute.
Parameters:
  attributeName - the attribute name (can be an expression)
Parameters:
  viewSelection - the selected view with a model attribute map toassert against



assertModelAttributeNull
protected void assertModelAttributeNull(String attributeName, ApplicationView viewSelection)(Code)
Assert that the selected view does not contain the specified model attribute.
Parameters:
  attributeName - the attribute name (can be an expression)
Parameters:
  viewSelection - the selected view with a model attribute map toassert against



assertViewNameEquals
protected void assertViewNameEquals(String expectedViewName, ApplicationView viewSelection)(Code)
Assert that the view name equals the provided value.
Parameters:
  expectedViewName - the expected name
Parameters:
  viewSelection - the selected view



createExternalContext
protected ExternalContext createExternalContext(ParameterMap requestParameters)(Code)
Creates an ExternalContext instance. Defaults to using MockExternalContext . Subclasses can override if they which to use another external context implementation.
Parameters:
  requestParameters - request parameters to put into theexternal context (optional) a new ExternalContext instance



createFlowExecutionFactory
protected FlowExecutionFactory createFlowExecutionFactory()(Code)
Factory method to create the flow execution factory. Subclasses could override this if they want to use a custom flow execution factory or custom configuration of the flow execution factory, registering flow execution listeners for instance. The default implementation just returns a FlowExecutionImplFactory instance. the flow execution factory



evaluateModelAttributeExpression
protected Object evaluateModelAttributeExpression(String attributeName, Map model)(Code)
Evaluates a model attribute expression.
Parameters:
  attributeName - the attribute expression
Parameters:
  model - the model map the attribute expression value



externalRedirect
protected ExternalRedirect externalRedirect(ViewSelection viewSelection)(Code)
Assert that the returned view selection is an instance of ExternalRedirect .
Parameters:
  viewSelection - the view selection



flowDefinitionRedirect
protected FlowDefinitionRedirect flowDefinitionRedirect(ViewSelection viewSelection)(Code)
Assert that the returned view selection is an instance of FlowDefinitionRedirect .
Parameters:
  viewSelection - the view selection



flowExecutionRedirect
protected FlowExecutionRedirect flowExecutionRedirect(ViewSelection viewSelection)(Code)
Assert that the returned view selection is an instance of FlowExecutionRedirect .
Parameters:
  viewSelection - the view selection



getConversationAttribute
protected Object getConversationAttribute(String attributeName)(Code)
Returns the attribute in conversation scope. Conversation-scoped attributes are shared by all flow sessions.
Parameters:
  attributeName - the name of the attribute the attribute value



getFlashAttribute
protected Object getFlashAttribute(String attributeName)(Code)
Returns the attribute in flash scope. Flash-scoped attributes are local to the active flow session and cleared on the next user event.
Parameters:
  attributeName - the name of the attribute the attribute value
since:
   1.0.2



getFlowAttribute
protected Object getFlowAttribute(String attributeName)(Code)
Returns the attribute in flow scope. Flow-scoped attributes are local to the active flow session.
Parameters:
  attributeName - the name of the attribute the attribute value



getFlowDefinition
abstract protected FlowDefinition getFlowDefinition()(Code)
Returns the flow definition to be tested. Subclasses must implement. the flow definition



getFlowExecution
protected FlowExecution getFlowExecution() throws IllegalStateException(Code)
Returns the flow execution being tested. the flow execution
throws:
  IllegalStateException - the execution has not been started



getFlowExecutionFactory
protected FlowExecutionFactory getFlowExecutionFactory()(Code)
Gets the factory that will create the flow execution to test. This method will create the factory if it is not already set. the flow execution factory
See Also:   AbstractFlowExecutionTests.createFlowExecutionFactory()



getRequiredConversationAttribute
protected Object getRequiredConversationAttribute(String attributeName) throws IllegalStateException(Code)
Returns the required attribute in conversation scope; asserts the attribute is present. Conversation-scoped attributes are shared by all flow sessions.
Parameters:
  attributeName - the name of the attribute the attribute value
throws:
  IllegalStateException - if the attribute was not present



getRequiredConversationAttribute
protected Object getRequiredConversationAttribute(String attributeName, Class requiredType) throws IllegalStateException(Code)
Returns the required attribute in conversation scope; asserts the attribute is present and of the required type. Conversation-scoped attributes are shared by all flow sessions.
Parameters:
  attributeName - the name of the attribute the attribute value
throws:
  IllegalStateException - if the attribute was not present or not ofthe required type



getRequiredFlashAttribute
protected Object getRequiredFlashAttribute(String attributeName) throws IllegalStateException(Code)
Returns the required attribute in flash scope; asserts the attribute is present. Flash-scoped attributes are local to the active flow session and cleared on the next user event.
Parameters:
  attributeName - the name of the attribute the attribute value
throws:
  IllegalStateException - if the attribute was not present
since:
   1.0.2



getRequiredFlashAttribute
protected Object getRequiredFlashAttribute(String attributeName, Class requiredType) throws IllegalStateException(Code)
Returns the required attribute in flash scope; asserts the attribute is present and of the correct type. Flash-scoped attributes are local to the active flow session and cleared on the next user event.
Parameters:
  attributeName - the name of the attribute the attribute value
throws:
  IllegalStateException - if the attribute was not present or was ofthe wrong type



getRequiredFlowAttribute
protected Object getRequiredFlowAttribute(String attributeName) throws IllegalStateException(Code)
Returns the required attribute in flow scope; asserts the attribute is present. Flow-scoped attributes are local to the active flow session.
Parameters:
  attributeName - the name of the attribute the attribute value
throws:
  IllegalStateException - if the attribute was not present



getRequiredFlowAttribute
protected Object getRequiredFlowAttribute(String attributeName, Class requiredType) throws IllegalStateException(Code)
Returns the required attribute in flow scope; asserts the attribute is present and of the correct type. Flow-scoped attributes are local to the active flow session.
Parameters:
  attributeName - the name of the attribute the attribute value
throws:
  IllegalStateException - if the attribute was not present or was ofthe wrong type



nullView
protected void nullView(ViewSelection viewSelection)(Code)
Assert that the returned view selection is the ViewSelection.NULL_VIEW .
Parameters:
  viewSelection - the view selection



refresh
protected ViewSelection refresh() throws FlowExecutionException(Code)
Refresh the flow execution being tested, asking the current view state to make a "refresh" view selection. This is idempotent operation that may be safely called on an active but currently paused execution. Used to simulate a browser flow execution redirect. the current view selection for this flow execution
throws:
  FlowExecutionException - if an exception was thrown during refresh



refresh
protected ViewSelection refresh(ExternalContext context) throws FlowExecutionException(Code)
Refresh the flow execution being tested, asking the current view state state to make a "refresh" view selection. This is idempotent operation that may be safely called on an active but currently paused execution. Used to simulate a browser flow execution redirect.
Parameters:
  context - the external context providing information about thecaller's environment, used by the flow execution during the refreshoperation the current view selection for this flow execution
throws:
  FlowExecutionException - if an exception was thrown during refresh



setExpressionParser
public void setExpressionParser(ExpressionParser expressionParser)(Code)
Set the expression parser responsible for parsing expression strings into evaluatable expression objects.



signalEvent
protected ViewSelection signalEvent(String eventId) throws FlowExecutionException(Code)
Signal an occurence of an event in the current state of the flow execution being tested.
Parameters:
  eventId - the event that occured
throws:
  FlowExecutionException - if an exception was thrown within a stateof the resumed flow execution during event processing



signalEvent
protected ViewSelection signalEvent(String eventId, ParameterMap requestParameters) throws FlowExecutionException(Code)
Signal an occurence of an event in the current state of the flow execution being tested.
Parameters:
  eventId - the event that occured
Parameters:
  requestParameters - request parameters needed by the flow executionto complete event processing
throws:
  FlowExecutionException - if an exception was thrown within a stateof the resumed flow execution during event processing



signalEvent
protected ViewSelection signalEvent(String eventId, ExternalContext context) throws FlowExecutionException(Code)
Signal an occurence of an event in the current state of the flow execution being tested.

Note: signaling an event will cause state transitions to occur in a chain until control is returned to the caller. Control is returned once an "interactive" state type is entered: either a view state when the flow is paused or an end state when the flow terminates. Action states are executed without returning control, as their result always triggers another state transition, executed internally. Action states can also be executed in a chain like fashion (e.g. action state 1 (result), action state 2 (result), action state 3 (result), view state ).

If you wish to verify expected behavior on each state transition (and not just when the view state triggers return of control back to the client), you have a few options:

First, you may implement standalone unit tests for your org.springframework.webflow.execution.Action implementations. There you can verify that an Action executes its logic properly in isolation. When you do this, you may mock or stub out services the Action implementation needs that are expensive to initialize. You can also verify there that the action puts everything in the flow or request scope it was expected to (to meet its contract with the view it is prepping for display, for example).

Second, you can attach one or more FlowExecutionListeners to the flow execution at start time within your test code, which will allow you to receive a callback on each state transition (among other points). It is recommended you extend org.springframework.webflow.execution.FlowExecutionListenerAdapter and only override the callback methods you are interested in.
Parameters:
  eventId - the event that occured
Parameters:
  context - the external context providing information about thecaller's environment, used by the flow execution during the signal eventoperation the view selection that was made, returned once control isreturned to the client (occurs when the flow enters a view state, or anend state)
throws:
  FlowExecutionException - if an exception was thrown within a stateof the resumed flow execution during event processing




startFlow
protected ViewSelection startFlow() throws FlowExecutionException(Code)
Start the flow execution to be tested.

Convenience operation that starts the execution with:

  • no input attributes
  • an empty ExternalContext with no environmental request parameters set
the view selection made as a result of starting the flow(returned when the first interactive state (a view state or end state) isentered)
throws:
  FlowExecutionException - if an exception was thrown while startingthe flow execution



startFlow
protected ViewSelection startFlow(MutableAttributeMap input) throws FlowExecutionException(Code)
Start the flow execution to be tested.

Convenience operation that starts the execution with:

  • the specified input attributes, eligible for mapping by the root flow
  • an empty ExternalContext with no environmental request parameters set

Parameters:
  input - the flow execution input attributes eligible for mapping bythe root flow the view selection made as a result of starting the flow(returned when the first interactive state (a view state or end state) isentered)
throws:
  FlowExecutionException - if an exception was thrown while startingthe flow execution



startFlow
protected ViewSelection startFlow(MutableAttributeMap input, ExternalContext context) throws FlowExecutionException(Code)
Start the flow execution to be tested.

This is the most flexible of the start methods. It allows you to specify:

  1. a map of input attributes to pass to the flow execution, eligible for mapping by the root flow definition
  2. an external context that provides the flow execution being tested access to the calling environment for this request

Parameters:
  input - the flow execution input attributes eligible for mapping bythe root flow
Parameters:
  context - the external context providing information about thecaller's environment, used by the flow execution during the startoperation the view selection made as a result of starting the flow(returned when the first interactive state (a view state or end state) isentered)
throws:
  FlowExecutionException - if an exception was thrown while startingthe flow execution



updateFlowExecution
protected void updateFlowExecution(FlowExecution flowExecution)(Code)
Directly update the flow execution used by the test by setting it to given flow execution. Use this if you have somehow manipulated the flow execution being tested and want to continue the test with another flow execution.
Parameters:
  flowExecution - the flow execution to use



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.