|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.webflow.test.MockRequestContext
public class MockRequestContext
Mock implementation of the RequestContext
interface to facilitate standalone flow artifact (e.g.
action) unit tests.
RequestContext
,
Action
Constructor Summary | |
---|---|
MockRequestContext()
Creates a new mock request context with the following defaults: A flow execution context with a active session of flow "mockFlow" in state "mockState". |
|
MockRequestContext(Flow flow)
Creates a new mock request context with the following defaults: A flow execution context with an active session for the specified flow. |
|
MockRequestContext(ParameterMap requestParameterMap)
Creates a new mock request context with the following defaults: A flow execution context with a active session of flow "mockFlow" in state "mockState". |
Method Summary | |
---|---|
FlowDefinition |
getActiveFlow()
Returns the definition of the flow that is currently executing. |
MutableAttributeMap |
getAttributeMap()
Returns the contained mutable context attribute map allowing setting of mock context
attributes. |
AttributeMap |
getAttributes()
Returns a context map for accessing arbitrary attributes about the state of the current request. |
MutableAttributeMap |
getConversationScope()
Returns a mutable accessor for accessing and/or setting attributes in conversation scope. |
StateDefinition |
getCurrentState()
Returns the current state of the executing flow. |
ExternalContext |
getExternalContext()
Returns the external client context that originated (or triggered) this request. |
MutableAttributeMap |
getFlashScope()
Returns a mutable accessor for accessing and/or setting attributes in flash scope. |
FlowExecutionContext |
getFlowExecutionContext()
Returns contextual information about the flow execution itself. |
MutableAttributeMap |
getFlowScope()
Returns a mutable accessor for accessing and/or setting attributes in flow scope. |
Event |
getLastEvent()
Returns the last event signaled during this request. |
TransitionDefinition |
getLastTransition()
Returns the last state transition that executed in this request. |
MockExternalContext |
getMockExternalContext()
Returns the external context as a MockExternalContext . |
MockFlowExecutionContext |
getMockFlowExecutionContext()
Returns the flow execution context as a MockFlowExecutionContext . |
AttributeMap |
getModel()
Returns the data model capturing the state of this context, suitable for exposing to clients (mostly web views). |
ParameterMap |
getRequestParameters()
Returns the immutable input parameters associated with this request into Spring Web Flow. |
MutableAttributeMap |
getRequestScope()
Returns a mutable accessor for accessing and/or setting attributes in request scope. |
void |
putRequestParameter(java.lang.String parameterName,
java.lang.String parameterValue)
Adds a request parameter to the configured external context. |
void |
putRequestParameter(java.lang.String parameterName,
java.lang.String[] parameterValues)
Adds a multi-valued request parameter to the configured external context. |
void |
removeAttribute(java.lang.String attributeName)
Remove a request context attribute. |
void |
setActiveSession(FlowSession flowSession)
Sets the active flow session of the executing flow associated with this request. |
void |
setAttribute(java.lang.String attributeName,
java.lang.Object attributeValue)
Set a request context attribute. |
void |
setAttributes(AttributeMap attributes)
Set the contextual attributes describing the state of this request. |
void |
setExternalContext(ExternalContext externalContext)
Sets the external context. |
void |
setFlowExecutionContext(FlowExecutionContext flowExecutionContext)
Sets the flow execution context. |
void |
setLastEvent(Event lastEvent)
Set the last event that occured in this request context. |
void |
setLastTransition(Transition lastTransition)
Set the last transition that executed in this request context. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MockRequestContext()
putRequestParameter(String, String)
method.
public MockRequestContext(Flow flow)
putRequestParameter(String, String)
method.
public MockRequestContext(ParameterMap requestParameterMap)
Method Detail |
---|
public FlowDefinition getActiveFlow()
RequestContext
getActiveFlow
in interface RequestContext
public StateDefinition getCurrentState()
RequestContext
null
if this flow execution is in the
process of starting and has not yet entered its start state.
getCurrentState
in interface RequestContext
null
if in the process of startingpublic MutableAttributeMap getRequestScope()
RequestContext
getRequestScope
in interface RequestContext
public MutableAttributeMap getFlashScope()
RequestContext
getFlashScope
in interface RequestContext
public MutableAttributeMap getFlowScope()
RequestContext
getFlowScope
in interface RequestContext
FlowSession
public MutableAttributeMap getConversationScope()
RequestContext
getConversationScope
in interface RequestContext
FlowExecutionContext
public ParameterMap getRequestParameters()
RequestContext
This is typically a convenient shortcut for accessing the ExternalContext.getRequestParameterMap()
directly.
getRequestParameters
in interface RequestContext
RequestContext.getExternalContext()
public ExternalContext getExternalContext()
RequestContext
Acting as a facade, the returned context object provides a single point of access to the calling client's environment. It provides normalized access to attributes of the client environment without tying you to specific constructs within that environment.
In addition, this context may be downcastable to a specific context type for a specific client environment, such
as a ServletExternalContext
for servlets or a
PortletExternalContext
for portlets. Such downcasting will
give you full access to a native HttpServletRequest, for example. With that said, for portability reasons you
should avoid coupling your flow artifacts to a specific deployment environment when possible.
getExternalContext
in interface RequestContext
public FlowExecutionContext getFlowExecutionContext()
RequestContext
getFlowExecutionContext
in interface RequestContext
public Event getLastEvent()
RequestContext
getLastEvent
in interface RequestContext
public TransitionDefinition getLastTransition()
RequestContext
getLastTransition
in interface RequestContext
null
if no transition has occured yetpublic AttributeMap getAttributes()
RequestContext
getAttributes
in interface RequestContext
public void setAttributes(AttributeMap attributes)
RequestContext
setAttributes
in interface RequestContext
attributes
- the attributespublic AttributeMap getModel()
RequestContext
getModel
in interface RequestContext
public void setActiveSession(FlowSession flowSession)
getActiveFlow()
and getCurrentState()
, as well as getFlowScope()
and
getFlashScope()
.
public void setExternalContext(ExternalContext externalContext)
public void setFlowExecutionContext(FlowExecutionContext flowExecutionContext)
public void setLastEvent(Event lastEvent)
lastEvent
- the event to setpublic void setLastTransition(Transition lastTransition)
lastTransition
- the last transition to setpublic void setAttribute(java.lang.String attributeName, java.lang.Object attributeValue)
attributeName
- the attribute nameattributeValue
- the attribute valuepublic void removeAttribute(java.lang.String attributeName)
attributeName
- the attribute namepublic MutableAttributeMap getAttributeMap()
attribute map
allowing setting of mock context
attributes.
public MockFlowExecutionContext getMockFlowExecutionContext()
MockFlowExecutionContext
.
public MockExternalContext getMockExternalContext()
MockExternalContext
.
public void putRequestParameter(java.lang.String parameterName, java.lang.String parameterValue)
parameterName
- the parameter nameparameterValue
- the parameter valuepublic void putRequestParameter(java.lang.String parameterName, java.lang.String[] parameterValues)
parameterName
- the parameter nameparameterValues
- the parameter values
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |