com.redhat.rhn.testing
Class ActionHelper

java.lang.Object
  extended by Assert
      extended by com.redhat.rhn.testing.ActionHelper

public class ActionHelper
extends Assert

ActionHelper - abstract base class that can be used to setup tests to verify our struts Actions.


Constructor Summary
ActionHelper()
           
 
Method Summary
 ForwardWrapper executeAction()
          Execute the Action and check for success
 ForwardWrapper executeAction(java.lang.String methodName)
          Execute the Action and check for success.
 ForwardWrapper executeAction(java.lang.String methodName, boolean successCheck)
          Execute the Action and check for success.
 RhnMockDynaActionForm getForm()
          Get the Form associated with this test
 ActionMapping getMapping()
          Return the ActionMapping used by the Action
 RhnMockHttpServletRequest getRequest()
          Get the Request associated with this test
 RhnMockHttpServletResponse getResponse()
          Get the response used by the helper.
 User getUser()
          Get the User associated with this test
 void setExpectedForward(java.lang.String name)
          Sets the expected forward to an ActionForward with the specified name and adds this forward to the mapping
 void setUpAction(Action actionIn)
          Setup the Action with the proper Request, Form, Response, etc...
 void setUpAction(Action actionIn, java.lang.String expectedForwardName)
          Setup the Action with the proper Request, Form, Response.
 void setupClampListBounds()
          Necessary setup for an action that calls clampListBounds.
 void setupClampListBounds(java.lang.String filterString)
          Necessary setup for an action that calls clampListBounds.
 void setupListSelection(java.lang.String listName)
          Setup the request parameters for ListSelection
 void setupProcessPagination()
          Setup request parameters that are often used by listview Actions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionHelper

public ActionHelper()
Method Detail

setUpAction

public void setUpAction(Action actionIn)
                 throws java.lang.Exception
Setup the Action with the proper Request, Form, Response, etc...

Parameters:
actionIn - The Action we want to setup to test.
Throws:
java.lang.Exception - if error occurs setting up the Action.

setUpAction

public void setUpAction(Action actionIn,
                        java.lang.String expectedForwardName)
                 throws java.lang.Exception
Setup the Action with the proper Request, Form, Response. With this version of the method we allow the caller to specify the expected name of the Forward the Action should generate.

Parameters:
actionIn - The Action we want to setup to test.
expectedForwardName - expected name of the forward you want the Action to generate.
Throws:
java.lang.Exception - if error occurs setting up the Action.

executeAction

public ForwardWrapper executeAction(java.lang.String methodName)
                             throws java.lang.Exception
Execute the Action and check for success.

Parameters:
methodName - the name of the method you want to execute in the Action. If not specified, will call execute()
Returns:
ActionForward the ActionForward the Action gave us. Can be examined to assert its state and make sure things were returned properly
Throws:
java.lang.Exception - if error occurs executing Action.

executeAction

public ForwardWrapper executeAction(java.lang.String methodName,
                                    boolean successCheck)
                             throws java.lang.Exception
Execute the Action and check for success.

Parameters:
methodName - the name of the method you want to execute in the Action. If not specified, will call execute()
successCheck - validate expected ActionForward here
Returns:
ActionForward the ActionForward the Action gave us. Can be examined to assert its state and make sure things were returned properly
Throws:
java.lang.Exception - if error occurs executing Action.

executeAction

public ForwardWrapper executeAction()
                             throws java.lang.Exception
Execute the Action and check for success

Returns:
ActionForward the ActionForward the Action gave us. Can be examined to assert its state and make sure things were returned properly
Throws:
java.lang.Exception - if error occurs executing Action.

getResponse

public RhnMockHttpServletResponse getResponse()
Get the response used by the helper.

Returns:
response used

getRequest

public RhnMockHttpServletRequest getRequest()
Get the Request associated with this test

Returns:
RhnMockHttpServletRequest used.

getForm

public RhnMockDynaActionForm getForm()
Get the Form associated with this test

Returns:
RhnMockDynaActionForm used.

getUser

public User getUser()
Get the User associated with this test

Returns:
User used.

getMapping

public ActionMapping getMapping()
Return the ActionMapping used by the Action

Returns:
ActionMapping used to execute the Action

setupClampListBounds

public void setupClampListBounds()
Necessary setup for an action that calls clampListBounds. Declares necessary request parameters and sets them to moderately bogus values.


setupClampListBounds

public void setupClampListBounds(java.lang.String filterString)
Necessary setup for an action that calls clampListBounds. Declares necessary request parameters and sets them to moderately bogus values. This version allows you to specify a filter string.

Parameters:
filterString - the filter string we want to test out.

setupProcessPagination

public void setupProcessPagination()
Setup request parameters that are often used by listview Actions.


setupListSelection

public void setupListSelection(java.lang.String listName)
Setup the request parameters for ListSelection

Parameters:
listName - The name of the list, from com.redhat.rhn.frontend.taglibs.list.ListTag

setExpectedForward

public void setExpectedForward(java.lang.String name)
Sets the expected forward to an ActionForward with the specified name and adds this forward to the mapping

Parameters:
name - The name of the expected forward