com.mockrunner.mock.web
Class ActionMockObjectFactory

java.lang.Object
  extended by com.mockrunner.mock.web.WebMockObjectFactory
      extended by com.mockrunner.mock.web.ActionMockObjectFactory

public class ActionMockObjectFactory
extends WebMockObjectFactory

Used to create all types of struts mock objects. Maintains the necessary dependencies between the mock objects. If you use the mock objects returned by this factory in your tests you can be sure that they are all up to date.


Constructor Summary
ActionMockObjectFactory()
          Creates a new set of mock objects.
ActionMockObjectFactory(WebMockObjectFactory factory)
          Creates a set of mock objects based on another one.
ActionMockObjectFactory(WebMockObjectFactory factory, boolean createNewSession)
          Creates a set of mock objects based on another one.
 
Method Summary
 MockActionMapping createMockActionMapping()
          Creates the MockActionMapping using new.
 MockActionServlet createMockActionServlet()
          Creates the MockActionServlet using new.
 MockModuleConfig createMockModuleConfig()
          Creates the MockModuleConfig using new.
 org.apache.struts.action.ActionMapping getActionMapping()
          Returns the ActionMapping.
 MockActionMapping getMockActionMapping()
          Returns the MockActionMapping.
 MockActionServlet getMockActionServlet()
          Returns the MockActionServlet.
 MockModuleConfig getMockModuleConfig()
          Returns the MockModuleConfig.
 org.apache.struts.action.ActionMapping prepareActionMapping(java.lang.Class mappingClass)
          Prepares an ActionMapping.
 void refresh()
          Refreshes the mock objects dependencies.
 void resetActionMapping()
          Resets ActionMapping configuration, i.e. sets the current ActionMapping returned by getActionMapping() to the mock action mapping returned by getMockActionMapping().
 
Methods inherited from class com.mockrunner.mock.web.WebMockObjectFactory
addRequestWrapper, addRequestWrapper, addResponseWrapper, addResponseWrapper, createMockFilterChain, createMockFilterConfig, createMockJspFactory, createMockPageContext, createMockRequest, createMockResponse, createMockServletConfig, createMockServletContext, createMockSession, getJspFactory, getMockFilterChain, getMockFilterConfig, getMockJspFactory, getMockPageContext, getMockRequest, getMockResponse, getMockServletConfig, getMockServletContext, getMockSession, getSession, getWrappedRequest, getWrappedResponse, setDefaultJspFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionMockObjectFactory

public ActionMockObjectFactory()
Creates a new set of mock objects.


ActionMockObjectFactory

public ActionMockObjectFactory(WebMockObjectFactory factory)
Creates a set of mock objects based on another one. The created mock objects will have their own request and session objects, but they will share one ServletContext.

Parameters:
factory - the other factory
See Also:
BaseTestCase.createWebMockObjectFactory(WebMockObjectFactory)

ActionMockObjectFactory

public ActionMockObjectFactory(WebMockObjectFactory factory,
                               boolean createNewSession)
Creates a set of mock objects based on another one. You can specify, if the created mock objects should share the same session. They will share one ServletContext anyway.

Parameters:
factory - the other factory
createNewSession - true creates a new session, false uses the session from factory
See Also:
BaseTestCase.createWebMockObjectFactory(WebMockObjectFactory, boolean)
Method Detail

refresh

public void refresh()
Refreshes the mock objects dependencies. May be called after setting request and response wrappers.

Overrides:
refresh in class WebMockObjectFactory

createMockActionServlet

public MockActionServlet createMockActionServlet()
Creates the MockActionServlet using new. This method can be overridden to return a subclass of MockActionServlet.

Returns:
the MockActionServlet

createMockModuleConfig

public MockModuleConfig createMockModuleConfig()
Creates the MockModuleConfig using new. This method can be overridden to return a subclass of MockModuleConfig.

Returns:
the MockModuleConfig

createMockActionMapping

public MockActionMapping createMockActionMapping()
Creates the MockActionMapping using new. This method can be overridden to return a subclass of MockActionMapping.

Returns:
the MockActionMapping

prepareActionMapping

public org.apache.struts.action.ActionMapping prepareActionMapping(java.lang.Class mappingClass)
Prepares an ActionMapping. If your actions rely on a custom subclass of ActionMapping, use this method to prepare it. Since ActionTestModule relies on the behaviour of MockActionMapping, this method creates a subclass CGLib proxy of the specified mapping class. You can cast the returned ActionMapping to your custom mapping class and the subclass proxy will redirect the necessary methods to the MockActionMapping. Redirected are methods for retrieving forwards. If an ActionMapping is prepared, getActionMapping() returns the prepared mapping while getMockActionMapping() returns the the underlying MockActionMapping. This method relies on CGLib. CGLib is not required by the Struts test framework if this method is not used.

Parameters:
mappingClass - the class of the custom action mapping
Returns:
an instance of the custom action mapping class

resetActionMapping

public void resetActionMapping()
Resets ActionMapping configuration, i.e. sets the current ActionMapping returned by getActionMapping() to the mock action mapping returned by getMockActionMapping().


getActionMapping

public org.apache.struts.action.ActionMapping getActionMapping()
Returns the ActionMapping. Unless you prepare an ActionMapping using prepareActionMapping(java.lang.Class), this method returns the same object as getMockActionMapping(). If an ActionMapping is prepared, this method returns the prepared ActionMapping while getMockActionMapping() returns the underlying MockActionMapping.

Returns:
the ActionMapping

getMockActionMapping

public MockActionMapping getMockActionMapping()
Returns the MockActionMapping.

Returns:
the MockActionMapping

getMockModuleConfig

public MockModuleConfig getMockModuleConfig()
Returns the MockModuleConfig.

Returns:
the MockModuleConfig

getMockActionServlet

public MockActionServlet getMockActionServlet()
Returns the MockActionServlet.

Returns:
the MockActionServlet