FileDocCategorySizeDatePackage
ElseIfTagTest.javaAPI DocExample3736Mon Jul 23 13:26:16 BST 2007org.apache.struts2.views.jsp

ElseIfTagTest

public class ElseIfTagTest extends org.apache.struts2.StrutsTestCase

Fields Summary
protected com.mockobjects.servlet.MockPageContext
pageContext
protected com.mockobjects.servlet.MockJspWriter
jspWriter
protected com.opensymphony.xwork2.util.ValueStack
stack
Constructors Summary
Methods Summary
protected voidsetUp()

        super.setUp();
        stack = ValueStackFactory.getFactory().createValueStack();

        jspWriter = new MockJspWriter();

        StrutsMockHttpServletRequest request = new StrutsMockHttpServletRequest();

        StrutsMockServletContext servletContext = new StrutsMockServletContext();
        servletContext.setServletInfo("not-weblogic");

        pageContext = new MockPageContext();
        pageContext.setJspWriter(jspWriter);
        pageContext.setRequest(request);
        pageContext.setServletContext(servletContext);

        request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack);
    
public voidtestIfIsFalseElseIfIsFalse()

        stack.getContext().put(If.ANSWER, Boolean.FALSE);

        ElseIfTag tag = new ElseIfTag();
        tag.setPageContext(pageContext);
        tag.setTest("false");

        int result = tag.doStartTag();
        tag.doEndTag();

        assertEquals(result, TagSupport.SKIP_BODY);
    
public voidtestIfIsFalseElseIfIsTrue()

        stack.getContext().put(If.ANSWER, Boolean.FALSE);

        ElseIfTag tag = new ElseIfTag();
        tag.setPageContext(pageContext);
        tag.setTest("true");

        int result = tag.doStartTag();
        tag.doEndTag();

        assertEquals(result, TagSupport.EVAL_BODY_INCLUDE);
    
public voidtestIfIsTrueElseIfIsFalse()

        stack.getContext().put(If.ANSWER, Boolean.TRUE);

        ElseIfTag tag = new ElseIfTag();
        tag.setPageContext(pageContext);
        tag.setTest("false");

        int result = tag.doStartTag();
        tag.doEndTag();

        assertEquals(result, TagSupport.SKIP_BODY);
    
public voidtestIfIsTrueElseIfIsTrue()

        stack.getContext().put(If.ANSWER, Boolean.TRUE);

        ElseIfTag tag = new ElseIfTag();
        tag.setPageContext(pageContext);
        tag.setTest("true");

        int result = tag.doStartTag();
        tag.doEndTag();

        assertEquals(result, TagSupport.SKIP_BODY);