org.springframework.webflow.test
Class MockExternalContext

java.lang.Object
  extended by org.springframework.webflow.test.MockExternalContext
All Implemented Interfaces:
ExternalContext

public class MockExternalContext
extends java.lang.Object
implements ExternalContext

Mock implementation of the ExternalContext interface.

Author:
Keith Donald
See Also:
ExternalContext

Constructor Summary
MockExternalContext()
          Creates a mock external context with an empty request parameter map.
MockExternalContext(ParameterMap requestParameterMap)
          Creates a mock external context with the specified parameters in the request parameter map.
 
Method Summary
 SharedAttributeMap getApplicationMap()
          Provides access to the external application map, providing a storage for data local to the current user application and accessible to both internal and external SWF artifacts.
 java.lang.String getContextPath()
          Returns the path (or identifier) of the application that is executing.
 java.lang.String getDispatcherPath()
          Returns the path (or identifier) of the dispatcher within the application that dispatched this request.
 SharedAttributeMap getGlobalSessionMap()
          Provides access to the global external session map, providing a storage for data globally accross the user session and accessible to both internal and external SWF artifacts.
 MockParameterMap getMockRequestParameterMap()
          Returns the request parameter map as a MockParameterMap for convenient access in a unit test.
 MutableAttributeMap getRequestMap()
          Provides access to the external request attribute map, providing a storage for data local to the current user request and accessible to both internal and external SWF artifacts.
 ParameterMap getRequestParameterMap()
          Provides access to the parameters associated with the user request that led to SWF being called.
 java.lang.String getRequestPathInfo()
          Returns the path info of this external request.
 SharedAttributeMap getSessionMap()
          Provides access to the external session map, providing a storage for data local to the current user session and accessible to both internal and external SWF artifacts.
 void putRequestParameter(java.lang.String parameterName, java.lang.String parameterValue)
          Puts a request parameter into the mock parameter map.
 void putRequestParameter(java.lang.String parameterName, java.lang.String[] parameterValues)
          Puts a multi-valued request parameter into the mock parameter map.
 void setApplicationMap(SharedAttributeMap applicationMap)
          Set the application attribute map.
 void setContextPath(java.lang.String contextPath)
          Set the context path.
 void setDispatcherPath(java.lang.String dispatcherPath)
          Set the dispatcher path.
 void setGlobalSessionMap(SharedAttributeMap globalSessionMap)
          Set the global session attribute map.
 void setRequestMap(MutableAttributeMap requestMap)
          Set the request attribute map.
 void setRequestParameterMap(ParameterMap requestParameterMap)
          Set the request parameter map.
 void setRequestPathInfo(java.lang.String requestPathInfo)
          Set the request path info.
 void setSessionMap(SharedAttributeMap sessionMap)
          Set the session attribute map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockExternalContext

public MockExternalContext()
Creates a mock external context with an empty request parameter map. Allows for bean style usage.


MockExternalContext

public MockExternalContext(ParameterMap requestParameterMap)
Creates a mock external context with the specified parameters in the request parameter map. All other properties of the external context can be set using the appropriate setter.

Parameters:
requestParameterMap - the request parameters
Method Detail

getContextPath

public java.lang.String getContextPath()
Description copied from interface: ExternalContext
Returns the path (or identifier) of the application that is executing.

Specified by:
getContextPath in interface ExternalContext
Returns:
the application context path (e.g. "/myapp")

getDispatcherPath

public java.lang.String getDispatcherPath()
Description copied from interface: ExternalContext
Returns the path (or identifier) of the dispatcher within the application that dispatched this request.

Specified by:
getDispatcherPath in interface ExternalContext
Returns:
the dispatcher path (e.g. "/dispatcher")

getRequestPathInfo

public java.lang.String getRequestPathInfo()
Description copied from interface: ExternalContext
Returns the path info of this external request. Could be null.

Specified by:
getRequestPathInfo in interface ExternalContext
Returns:
the request path info (e.g. "/flows.htm")

getRequestParameterMap

public ParameterMap getRequestParameterMap()
Description copied from interface: ExternalContext
Provides access to the parameters associated with the user request that led to SWF being called. This map is expected to be immutable and cannot be changed.

Specified by:
getRequestParameterMap in interface ExternalContext
Returns:
the immutable request parameter map

getRequestMap

public MutableAttributeMap getRequestMap()
Description copied from interface: ExternalContext
Provides access to the external request attribute map, providing a storage for data local to the current user request and accessible to both internal and external SWF artifacts.

Specified by:
getRequestMap in interface ExternalContext
Returns:
the mutable request attribute map

getSessionMap

public SharedAttributeMap getSessionMap()
Description copied from interface: ExternalContext
Provides access to the external session map, providing a storage for data local to the current user session and accessible to both internal and external SWF artifacts.

Specified by:
getSessionMap in interface ExternalContext
Returns:
the mutable session attribute map

getGlobalSessionMap

public SharedAttributeMap getGlobalSessionMap()
Description copied from interface: ExternalContext
Provides access to the global external session map, providing a storage for data globally accross the user session and accessible to both internal and external SWF artifacts.

Note: most external context implementations do not distinguish between the concept of a "local" user session scope and a "global" session scope. The Portlet world does, but not the Servlet for example. In those cases calling this method returns the same map as calling ExternalContext.getSessionMap().

Specified by:
getGlobalSessionMap in interface ExternalContext
Returns:
the mutable global session attribute map

getApplicationMap

public SharedAttributeMap getApplicationMap()
Description copied from interface: ExternalContext
Provides access to the external application map, providing a storage for data local to the current user application and accessible to both internal and external SWF artifacts.

Specified by:
getApplicationMap in interface ExternalContext
Returns:
the mutable application attribute map

setContextPath

public void setContextPath(java.lang.String contextPath)
Set the context path.

See Also:
ExternalContext.getContextPath()

setDispatcherPath

public void setDispatcherPath(java.lang.String dispatcherPath)
Set the dispatcher path.

See Also:
ExternalContext.getDispatcherPath()

setRequestPathInfo

public void setRequestPathInfo(java.lang.String requestPathInfo)
Set the request path info.

See Also:
ExternalContext.getRequestPathInfo()

setRequestParameterMap

public void setRequestParameterMap(ParameterMap requestParameterMap)
Set the request parameter map.

See Also:
ExternalContext.getRequestParameterMap()

setRequestMap

public void setRequestMap(MutableAttributeMap requestMap)
Set the request attribute map.

See Also:
ExternalContext.getRequestMap()

setSessionMap

public void setSessionMap(SharedAttributeMap sessionMap)
Set the session attribute map.

See Also:
ExternalContext.getSessionMap()

setGlobalSessionMap

public void setGlobalSessionMap(SharedAttributeMap globalSessionMap)
Set the global session attribute map. By default the session attribute map and the global session attribute map are one and the same.

See Also:
ExternalContext.getGlobalSessionMap()

setApplicationMap

public void setApplicationMap(SharedAttributeMap applicationMap)
Set the application attribute map.

See Also:
ExternalContext.getApplicationMap()

getMockRequestParameterMap

public MockParameterMap getMockRequestParameterMap()
Returns the request parameter map as a MockParameterMap for convenient access in a unit test.

See Also:
getRequestParameterMap()

putRequestParameter

public void putRequestParameter(java.lang.String parameterName,
                                java.lang.String parameterValue)
Puts a request parameter into the mock parameter map.

Parameters:
parameterName - the parameter name
parameterValue - the parameter value

putRequestParameter

public void putRequestParameter(java.lang.String parameterName,
                                java.lang.String[] parameterValues)
Puts a multi-valued request parameter into the mock parameter map.

Parameters:
parameterName - the parameter name
parameterValues - the parameter values


Copyright © 2004-2007. All Rights Reserved.