Package org.apache.struts.chain.contexts

Examples of org.apache.struts.chain.contexts.ServletActionContext


{
 
  @Test
  public void testDelegatingActionForm() throws Exception
  {
    ServletActionContext sac = getActionContext();
    FormWrapper wrapper = newMock(FormWrapper.class);
    ProcessActionForm processActionForm = getProcessActionForm(wrapper);
    HttpServletRequest request = newMock(HttpServletRequest.class);
    ActionForm actionForm = newMock(ActionForm.class);
    DelegatingForm delegatingForm = new DelegatingForm(actionForm);

    expect(sac.getActionForm()).andReturn(actionForm);
    expect(sac.getRequest()).andReturn(request);
   
    expect(wrapper.wrapForm(actionForm, request)).andReturn(delegatingForm);

    wrapper.handleBindingForm(isA(BindingForm.class), eq(request));
    wrapper.handleValidForm(isA(ValidForm.class), eq(request));
    sac.setActionForm(isA(ActionForm.class));
   
    replayMocks();
    processActionForm.execute(sac);
    verifyMocks();
  }
View Full Code Here


{

  @Test
  public void testPopulateActionForm() throws Exception
  {
    ServletActionContext sac = getActionContext();
    FormPopulateSource formPopulateSource = newMock(FormPopulateSource.class);
    PopulateActionForm populateActionForm = getPopulateActionForm(formPopulateSource);
    ActionMapping actionConfig = newMock(ActionMapping.class);
    ActionForm actionForm = newMock(ActionForm.class);
    HttpServletRequest request = newMock(HttpServletRequest.class);

    expect(sac.getActionForm()).andReturn(actionForm);
    expect(sac.getRequest()).andReturn(request);
    expect(formPopulateSource.prePopulate(actionForm, request)).andReturn(actionForm);

    replayMocks();
    populateActionForm.populate(sac, actionConfig, actionForm);
    verifyMocks();
View Full Code Here

{
 
  @Test
  public void testRegularActionForm() throws Exception
  {
    ServletActionContext sac = getActionContext();
    FormWrapper wrapper = newMock(FormWrapper.class);
    ProcessActionForm processActionForm = getProcessActionForm(wrapper);
    HttpServletRequest request = newMock(HttpServletRequest.class);
    ActionForm actionForm = newMock(ActionForm.class);

    expect(sac.getActionForm()).andReturn(actionForm);
    expect(sac.getRequest()).andReturn(request);
    expect(wrapper.wrapForm(actionForm, request)).andReturn(actionForm);
    sac.setActionForm(actionForm);

    replayMocks();
    processActionForm.execute(sac);
    verifyMocks();
  }
View Full Code Here

public class TestPreprocess extends AbstractTestChain
{
  @Test
  public void testPopulateActionForm() throws Exception
  {
    ServletActionContext sac = getActionContext();
    RequestPreprocessor requestPreprocessor = newMock(RequestPreprocessor.class);
    Preprocess preprocess = getPreprocess(requestPreprocessor);
    HttpServletRequest request = newMock(HttpServletRequest.class);

    expect(sac.getRequest()).andReturn(request);
    requestPreprocessor.preprocessRequest(request);

    replayMocks();
    preprocess.execute(sac);
    verifyMocks();
View Full Code Here

{
 
  @Test
  public void testCreateAction() throws Exception
  {
    ServletActionContext sac = getActionContext();
    ControllerProcessorDelegate delegate = newMock(ControllerProcessorDelegate.class);
    ActionContextFactory factory = newMock(ActionContextFactory.class);
    ExecuteAction executeAction = getExecuteAction(delegate, factory);
    Action action = newMock(Action.class);
    ActionMapping actionConfig = newMock(ActionMapping.class);
    ActionForm actionForm = newMock(ActionForm.class);
    ActionContext actionContext = newMock(ActionContext.class);
    ActionForward forwardConfig = newMock(ActionForward.class);
    HttpServletRequest request = newMock(HttpServletRequest.class);
    HttpServletResponse response = newMock(HttpServletResponse.class);
    ServletContext servletContext = newMock(ServletContext.class);
   
    expect(sac.getRequest()).andReturn(request);
    expect(sac.getResponse()).andReturn(response);
    expect(sac.getContext()).andReturn(servletContext);
    expect(factory.createActionContext(request, response, servletContext, actionForm, actionConfig)).andReturn(actionContext);
    expect(action.execute(actionConfig, actionForm, request, response)).andReturn(forwardConfig);
   
    replayMocks();
    executeAction.execute(sac, action, actionConfig, actionForm);
View Full Code Here

  @Test
  public void testCreateAction() throws Exception
  {
    ActionCreator actionCreator = newMock(ActionCreator.class);
    CreateAction createAction = getCreateAction(actionCreator);
    ServletActionContext actionContext = getActionContext();
    ActionConfig actionConfig = newMock(ActionConfig.class);
    ModuleConfig moduleConfig = newMock(ModuleConfig.class);
    ActionServlet servlet = newMock(ActionServlet.class);
    Map applicationScope = newMock(Map.class);
    Map actions = new HashMap();
    Action action = new Action();
   
    expect(actionConfig.getModuleConfig()).andReturn(moduleConfig);
    expect(moduleConfig.getPrefix()).andReturn("prefix");
    expect(actionContext.getApplicationScope()).andReturn(applicationScope);
    expect(applicationScope.get("actionsprefix")).andReturn(actions);
    expect(actionCreator.createAction(String.class)).andReturn(action);
    expect(actionContext.getActionServlet()).andReturn(servlet);

    replayMocks();
    createAction.getAction(actionContext, "java.lang.String", actionConfig);
    verifyMocks();
   
View Full Code Here

public class TestValidateActionForm extends AbstractTestChain
{
  @Test
  public void testPopulateActionForm() throws Exception
  {
    ServletActionContext sac = getActionContext();
    FormValidationHandler formValidationHandler = newMock(FormValidationHandler.class);
    ValidateActionForm validateActionForm = getValidateActionForm(formValidationHandler);

    ActionMapping actionConfig = newMock(ActionMapping.class);
    HttpServletRequest request = newMock(HttpServletRequest.class);
   
    expect(sac.getRequest()).andReturn(request);
    expect(sac.getActionConfig()).andReturn(actionConfig);
    expect(sac.getFormValid()).andReturn(true);
   
    formValidationHandler.postValidate(request, actionConfig, true);

    replayMocks();
    validateActionForm.postExecute(sac);
View Full Code Here

    return false;
  }

  void postExecute(ActionContext context)
  {
    ServletActionContext sc = (ServletActionContext) context;
   
    final HttpServletRequest request = sc.getRequest();
    final ActionMapping actionConfig = (ActionMapping) sc.getActionConfig();
    final Boolean formValid = context.getFormValid();
   
    formValidationHandler.postValidate(request, actionConfig, formValid);
  }
View Full Code Here

      if (isNew)
      {
        actions.put(className, action);
        if (action.getServlet() == null)
        {
          ServletActionContext saContext = (ServletActionContext) context;
          ActionServlet actionServlet = saContext.getActionServlet();

          action.setServlet(actionServlet);
        }
      }
    }
View Full Code Here

  }

  @Override
  protected void populate(ActionContext context, ActionConfig actionConfig, ActionForm actionForm) throws Exception
  {
    final ServletActionContext sc = (ServletActionContext) context;
    final ActionForm form = sc.getActionForm();
    final HttpServletRequest request = sc.getRequest();
    ActionForm wrappedForm = formPopulateSource.prePopulate(form, request);

        populateForm(actionConfig, request, wrappedForm);
  }
View Full Code Here

TOP

Related Classes of org.apache.struts.chain.contexts.ServletActionContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.