Package org.apache.cactus.extension.jsp

Examples of org.apache.cactus.extension.jsp.JspTagLifecycle


     */
    public void testForEachTagStatus()
        throws JspException, IOException
    {
        ForEachTag tag = new ForEachTag();
        JspTagLifecycle lifecycle = new JspTagLifecycle(pageContext, tag);
        tag.setVarStatus("status");
        tag.setBegin("0");
        tag.setEnd("2");
        lifecycle.expectBodyEvaluated(3);
        lifecycle.addInterceptor(new JspTagLifecycle.Interceptor()
        {
            public void evalBody(int theIteration, BodyContent theBody)
            {
                LoopTagStatus status = (LoopTagStatus)
                    pageContext.findAttribute("status");
                assertNotNull(status);
                if (theIteration == 0)
                {
                    assertEquals(0, status.getIndex());
                    assertEquals(1, status.getCount());
                    assertTrue(status.isFirst());
                    assertTrue(!status.isLast());
                }
                else if (theIteration == 1)
                {
                    assertEquals(1, status.getIndex());
                    assertEquals(2, status.getCount());
                    assertTrue(!status.isFirst());
                    assertTrue(!status.isLast());
                }
                else if (theIteration == 2)
                {
                    assertEquals(2, status.getIndex());
                    assertEquals(3, status.getCount());
                    assertTrue(!status.isFirst());
                    assertTrue(status.isLast());
                }
            }
        });
        lifecycle.invoke();
    }
View Full Code Here


     */
    public void testIfTagTrue()
        throws JspException, IOException
    {
        IfTag tag = new IfTag();
        JspTagLifecycle lifecycle = new JspTagLifecycle(pageContext, tag);
        tag.setTest("true");
        lifecycle.addNestedText("Value");
        lifecycle.expectBodyEvaluated();
        lifecycle.invoke();
    }
View Full Code Here

     */
    public void testIfTagFalse()
        throws JspException, IOException
    {
        IfTag tag = new IfTag();
        JspTagLifecycle lifecycle = new JspTagLifecycle(pageContext, tag);
        tag.setTest("false");
        lifecycle.addNestedText("Value");
        lifecycle.expectBodySkipped();
        lifecycle.invoke();
    }
View Full Code Here

     */
    public void testWhenTag()
        throws JspException, IOException
    {
        ChooseTag chooseTag = new ChooseTag();
        JspTagLifecycle chooseLifecycle =
            new JspTagLifecycle(pageContext, chooseTag);
       
        WhenTag whenTag = new WhenTag();
        JspTagLifecycle whenLifecycle =
            chooseLifecycle.addNestedTag(whenTag);
        whenTag.setTest("true");
        whenLifecycle.expectBodyEvaluated();
       
        chooseLifecycle.invoke();
    }
View Full Code Here

     */
    public void testWhenTagNoPermission()
        throws JspException, IOException
    {
        ChooseTag chooseTag = new ChooseTag();
        JspTagLifecycle chooseLifecycle =
            new JspTagLifecycle(pageContext, chooseTag);
       
        WhenTag whenTag = new WhenTag();
        JspTagLifecycle whenLifecycle =
            chooseLifecycle.addNestedTag(whenTag);
        whenTag.setTest("false");
        whenLifecycle.expectBodySkipped();
       
        OtherwiseTag otherwiseTag = new OtherwiseTag();
        JspTagLifecycle otherwiseLifecycle =
            chooseLifecycle.addNestedTag(otherwiseTag);
        otherwiseLifecycle.expectBodyEvaluated();
       
        chooseLifecycle.invoke();
    }
View Full Code Here

     */
    public void testWhenTagWithoutChooseTag()
        throws JspException, IOException
    {
        WhenTag tag = new WhenTag();
        JspTagLifecycle lifecycle = new JspTagLifecycle(pageContext, tag);
        tag.setTest("true");
        try
        {
            lifecycle.invoke();
            fail("Expected JSPTagException");
        }
        catch (JspTagException expected)
        {
            // expected
View Full Code Here

TOP

Related Classes of org.apache.cactus.extension.jsp.JspTagLifecycle

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.