org.springframework.webflow.test
Class MockRequestControlContext

java.lang.Object
  extended by org.springframework.webflow.test.MockRequestContext
      extended by org.springframework.webflow.test.MockRequestControlContext
All Implemented Interfaces:
RequestControlContext, RequestContext

public class MockRequestControlContext
extends MockRequestContext
implements RequestControlContext

Mock implementation of the RequestControlContext interface to facilitate standalone Flow and State unit tests.

Author:
Keith Donald
See Also:
RequestContext, FlowSession, State

Constructor Summary
MockRequestControlContext(Flow rootFlow)
          Creates a new mock request control context for controlling a mock execution of the provided flow definition.
 
Method Summary
 FlowSession endActiveFlowSession(MutableAttributeMap output)
          End the active flow session of the current flow execution.
 ViewSelection execute(Transition transition)
          Execute this transition out of the current source state.
 void setCurrentState(State state)
          Record the current state that has entered in the executing flow.
 ViewSelection signalEvent(Event event)
          Signals the occurence of an event in the current state of this flow execution request context.
 ViewSelection start(Flow flow, MutableAttributeMap input)
          Spawn a new flow session and activate it in the currently executing flow.
 
Methods inherited from class org.springframework.webflow.test.MockRequestContext
getActiveFlow, getAttributeMap, getAttributes, getConversationScope, getCurrentState, getExternalContext, getFlashScope, getFlowExecutionContext, getFlowScope, getLastEvent, getLastTransition, getMockExternalContext, getMockFlowExecutionContext, getModel, getRequestParameters, getRequestScope, putRequestParameter, putRequestParameter, removeAttribute, setActiveSession, setAttribute, setAttributes, setExternalContext, setFlowExecutionContext, setLastEvent, setLastTransition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.webflow.engine.RequestControlContext
setLastEvent, setLastTransition
 
Methods inherited from interface org.springframework.webflow.execution.RequestContext
getActiveFlow, getAttributes, getConversationScope, getCurrentState, getExternalContext, getFlashScope, getFlowExecutionContext, getFlowScope, getLastEvent, getLastTransition, getModel, getRequestParameters, getRequestScope, setAttributes
 

Constructor Detail

MockRequestControlContext

public MockRequestControlContext(Flow rootFlow)
Creates a new mock request control context for controlling a mock execution of the provided flow definition.

Method Detail

setCurrentState

public void setCurrentState(State state)
Description copied from interface: RequestControlContext
Record the current state that has entered in the executing flow. This method will be called as part of entering a new state by the State type itself.

Specified by:
setCurrentState in interface RequestControlContext
Parameters:
state - the current state
See Also:
State.enter(RequestControlContext)

start

public ViewSelection start(Flow flow,
                           MutableAttributeMap input)
                    throws java.lang.IllegalStateException
Description copied from interface: RequestControlContext
Spawn a new flow session and activate it in the currently executing flow. Also transitions the spawned flow to its start state. This method should be called by clients that wish to spawn new flows, such as subflow states.

This will start a new flow session in the current flow execution, which is already active.

Specified by:
start in interface RequestControlContext
Parameters:
flow - the flow to start, its start() method will be called
input - initial contents of the newly created flow session (may be null, e.g. empty)
Returns:
the selected starting view, which returns control to the client and requests that a view be rendered with model data
Throws:
java.lang.IllegalStateException
See Also:
Flow.start(RequestControlContext, MutableAttributeMap)

signalEvent

public ViewSelection signalEvent(Event event)
Description copied from interface: RequestControlContext
Signals the occurence of an event in the current state of this flow execution request context. This method should be called by clients that report internal event occurences, such as action states. The onEvent() method of the flow involved in the flow execution will be called.

Specified by:
signalEvent in interface RequestControlContext
Parameters:
event - the event that occured
Returns:
the next selected view, which returns control to the client and requests that a view be rendered with model data
See Also:
Flow.onEvent(RequestControlContext)

endActiveFlowSession

public FlowSession endActiveFlowSession(MutableAttributeMap output)
                                 throws java.lang.IllegalStateException
Description copied from interface: RequestControlContext
End the active flow session of the current flow execution. This method should be called by clients that terminate flows, such as end states. The end() method of the flow involved in the flow execution will be called.

Specified by:
endActiveFlowSession in interface RequestControlContext
Parameters:
output - output produced by the session that is eligible for mapping by a resuming parent flow
Returns:
the ended session
Throws:
java.lang.IllegalStateException - when the flow execution is not active
See Also:
Flow.end(RequestControlContext, MutableAttributeMap)

execute

public ViewSelection execute(Transition transition)
Description copied from interface: RequestControlContext
Execute this transition out of the current source state. Allows for privileged execution of an arbitrary transition.

Specified by:
execute in interface RequestControlContext
Parameters:
transition - the transition
Returns:
a new view selection
See Also:
Transition.execute(State, RequestControlContext)


Copyright © 2004-2007. All Rights Reserved.