FileDocCategorySizeDatePackage
FormButtonTest.javaAPI DocExample4901Mon Jul 23 13:26:10 BST 2007org.apache.struts2.components

FormButtonTest

public class FormButtonTest extends org.apache.struts2.StrutsTestCase
version
$Date: 2006-11-06 10:01:43 -0500 (Mon, 06 Nov 2006) $ $Id: FormButtonTest.java 471756 2006-11-06 15:01:43Z husted $

Fields Summary
Constructors Summary
Methods Summary
public voidtestPopulateComponentHtmlId1()

        MockHttpServletRequest req = new MockHttpServletRequest();
        MockHttpServletResponse res = new MockHttpServletResponse();
        ValueStack stack = ValueStackFactory.getFactory().createValueStack();

        Form form = new Form(stack, req, res);
        form.getParameters().put("id", "formId");

        Submit submit = new Submit(stack, req, res);
        submit.setId("submitId");

        submit.populateComponentHtmlId(form);

        assertEquals("submitId", submit.getParameters().get("id"));
    
public voidtestPopulateComponentHtmlId2()

        MockHttpServletRequest req = new MockHttpServletRequest();
        MockHttpServletResponse res = new MockHttpServletResponse();
        ValueStack stack = ValueStackFactory.getFactory().createValueStack();

        Form form = new Form(stack, req, res);
        form.getParameters().put("id", "formId");

        Submit submit = new Submit(stack, req, res);
        submit.setName("submitName");

        submit.populateComponentHtmlId(form);

        assertEquals("formId_submitName", submit.getParameters().get("id"));
    
public voidtestPopulateComponentHtmlId3()

        MockHttpServletRequest req = new MockHttpServletRequest();
        MockHttpServletResponse res = new MockHttpServletResponse();
        ValueStack stack = ValueStackFactory.getFactory().createValueStack();

        Form form = new Form(stack, req, res);
        form.getParameters().put("id", "formId");

        Submit submit = new Submit(stack, req, res);
        submit.setAction("submitAction");
        submit.setMethod("submitMethod");

        submit.populateComponentHtmlId(form);

        assertEquals("formId_submitAction_submitMethod", submit.getParameters().get("id"));
    
public voidtestPopulateComponentHtmlId4()

        MockHttpServletRequest req = new MockHttpServletRequest();
        MockHttpServletResponse res = new MockHttpServletResponse();
        ValueStack stack = ValueStackFactory.getFactory().createValueStack();

        Submit submit = new Submit(stack, req, res);
        submit.setId("submitId");

        submit.populateComponentHtmlId(null);

        assertEquals("submitId", submit.getParameters().get("id"));
    
public voidtestPopulateComponentHtmlId5()

        MockHttpServletRequest req = new MockHttpServletRequest();
        MockHttpServletResponse res = new MockHttpServletResponse();
        ValueStack stack = ValueStackFactory.getFactory().createValueStack();

        Submit submit = new Submit(stack, req, res);
        submit.setName("submitName");

        submit.populateComponentHtmlId(null);

        assertEquals("submitName", submit.getParameters().get("id"));
    
public voidtestPopulateComponentHtmlId6()

        MockHttpServletRequest req = new MockHttpServletRequest();
        MockHttpServletResponse res = new MockHttpServletResponse();
        ValueStack stack = ValueStackFactory.getFactory().createValueStack();

        Submit submit = new Submit(stack, req, res);
        submit.setAction("submitAction");
        submit.setMethod("submitMethod");

        submit.populateComponentHtmlId(null);

        assertEquals("submitAction_submitMethod", submit.getParameters().get("id"));