Package org.strecks.form.controller

Examples of org.strecks.form.controller.DelegatingForm


  @Test
  public void testPrePopulate()
  {

    SimpleStrutsForm form = new SimpleStrutsForm();
    DelegatingForm delegator = new DelegatingForm(form);

    FormPopulateSourceImpl delegate = new FormPopulateSourceImpl();
   
    ActionForm form1 = delegate.prePopulate(form, null);
    ActionForm form2 = delegate.prePopulate(delegator, null);
View Full Code Here


    ActionForward actionForward = new ActionForward();

    HttpServletRequest request = createStrictMock(HttpServletRequest.class);
    NavigableFormRenderBean actionBean = createStrictMock(NavigableFormRenderBean.class);
    ActionMapping mapping = createStrictMock(ActionMapping.class);
    DelegatingForm form = createStrictMock(DelegatingForm.class);

    ActionErrors errors = new ActionErrors();
    errors.add("prop", new ActionMessage("key"));
    expect(request.getAttribute(Globals.ERROR_KEY)).andReturn(errors);
    actionBean.setInputError(true);
    actionBean.execute();
    expect(form.getBindOutwards()).andReturn(false);
    expect(actionBean.getSuccessResult()).andReturn("success");
    expect(mapping.findForward("success")).andReturn(actionForward);

    replay(actionBean);
    replay(mapping);
View Full Code Here

    ActionForward actionForward = new ActionForward();

    HttpServletRequest request = createStrictMock(HttpServletRequest.class);
    NavigableFormRenderBean actionBean = createStrictMock(NavigableFormRenderBean.class);
    ActionMapping mapping = createStrictMock(ActionMapping.class);
    DelegatingForm form = createStrictMock(DelegatingForm.class);

    expect(request.getAttribute(Globals.ERROR_KEY)).andReturn(null);
    actionBean.setInputError(false);
    form.setBindOutwards(true);
    actionBean.execute();
    expect(form.getBindOutwards()).andReturn(true);
    form.bindOutwards(actionBean);
    expect(actionBean.getSuccessResult()).andReturn("success");
    expect(mapping.findForward("success")).andReturn(actionForward);

    replay(actionBean);
    replay(mapping);
View Full Code Here

  @Test
  public void testGetFormClass()
  {

    SimpleStrutsForm form = new SimpleStrutsForm();
    DelegatingForm delegating = new DelegatingForm(form);

    ValidateBindFormWrapper validateBindFormHandler = new ValidateBindFormWrapper();
    Class formClass1 = validateBindFormHandler.getFormClass(delegating);
    Class formClass2 = validateBindFormHandler.getFormClass(form);
    assert formClass1 == formClass2;
View Full Code Here

  @Test
  public void testGetReadableObject()
  {

    SimpleStrutsForm form = new SimpleStrutsForm();
    DelegatingForm delegating = new DelegatingForm(form);

    ValidateBindFormWrapper validateBindFormHandler = new ValidateBindFormWrapper();
    Object readable1 = validateBindFormHandler.getReadableObject(delegating);
    Object readable2 = validateBindFormHandler.getReadableObject(form);
    assert readable1 == readable2;
View Full Code Here

  @Test
  public void testHandleValidForm()
  {

    SimpleStrutsForm form = new SimpleStrutsForm();
    DelegatingForm delegating = new DelegatingForm(form);
   
    HttpServletRequest request = createMock(HttpServletRequest.class);

    replay(request);

    ValidateBindFormWrapper delegate = new ValidateBindFormWrapper();
    delegate.handleValidForm(delegating, request);

    assert null != delegating.getValidationInfo();
    assert null == delegating.getBindConvertInfo();

    assert delegate.getBindConvertMap().size() == 0;
    assert delegate.getValidationHandlerMap().size() == 1;

    verify(request);
View Full Code Here

  @Test
  public void testHandleBindingForm()
  {

    SimpleStrutsForm form = new SimpleStrutsForm();
    DelegatingForm delegating = new DelegatingForm(form);
    HttpServletRequest request = createMock(HttpServletRequest.class);

    replay(request);

    ValidateBindFormWrapper delegate = new ValidateBindFormWrapper();
    delegate.handleBindingForm(delegating, request);

    assert null != delegating.getBindConvertInfo();
    assert null == delegating.getValidationInfo();

    Map<Class, BindConvertInfo> bindHandlerMap = delegate.getBindConvertMap();
    assert bindHandlerMap.size() == 1;

    assert delegate.getValidationHandlerMap().size() == 0;
View Full Code Here

  @Test
  public void testHandleFormMultiTimes()
  {

    SimpleStrutsForm form1 = new SimpleStrutsForm();
    DelegatingForm delegator1 = new DelegatingForm(form1);
    SimpleStrutsForm form2 = new SimpleStrutsForm();
    DelegatingForm delegator2 = new DelegatingForm(form2);

    HttpServletRequest request = createMock(HttpServletRequest.class);

    replay(request);

    FormWrapper delegate = new ValidateBindFormWrapper();
    delegate.handleValidForm(delegator1, request);
    delegate.handleValidForm(delegator2, request);
    delegate.handleBindingForm(delegator1, request);
    delegate.handleBindingForm(delegator2, request);

    assert null != delegator1.getBindConvertInfo();
    assert null != delegator2.getValidationInfo();

    // now check that the same instances are used for each invocation
    assert delegator1.getBindConvertInfo() == delegator2.getBindConvertInfo();
    assert delegator1.getValidationInfo() == delegator2.getValidationInfo();

    verify(request);
  }
View Full Code Here

    HttpSession session = createMock(HttpSession.class);
    ModuleConfig moduleConfig = createMock(ModuleConfig.class);
    ActionServlet servlet = createMock(ActionServlet.class);
    ServletContext context = createMock(ServletContext.class);
    MessageResources messageResources = createMock(MessageResources.class);
    DelegatingForm form = createStrictMock(DelegatingForm.class);

    action.setServlet(servlet);

    actionBean.preBind();
    form.bindInwards(actionBean);
    expect(request.getAttribute(Globals.CANCEL_KEY)).andReturn(null);
    expect(mapping.getParameter()).andReturn("method");
    expect(request.getParameter("method")).andReturn("Insert Stuff Here");
    expect(request.getSession(false)).andReturn(session);
    expect(session.getAttribute(Globals.LOCALE_KEY)).andReturn(Locale.getDefault());
View Full Code Here

    ActionForward actionForward = new ActionForward();

    NavigableFormSubmitBean actionBean = createStrictMock(NavigableFormSubmitBean.class);
    ActionMapping mapping = createStrictMock(ActionMapping.class);
    DelegatingForm form = createStrictMock(DelegatingForm.class);
    HttpServletRequest request = createStrictMock(HttpServletRequest.class);

    expect(request.getAttribute(Globals.CANCEL_KEY)).andReturn(null);
    actionBean.preBind();
    form.bindInwards(actionBean);
    actionBean.execute();
    expect(actionBean.getSuccessResult()).andReturn("success");
    expect(mapping.findForward("success")).andReturn(actionForward);

    replay(actionBean);
View Full Code Here

TOP

Related Classes of org.strecks.form.controller.DelegatingForm

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.