FileDocCategorySizeDatePackage
TokenTagTest.javaAPI DocExample3049Mon Jul 23 13:26:16 BST 2007org.apache.struts2.views.jsp.ui

TokenTagTest

public class TokenTagTest extends org.apache.struts2.views.jsp.AbstractUITagTest
TokenTagTest

Fields Summary
Constructors Summary
Methods Summary
private java.lang.StringdoTokenTest(java.lang.String tokenName, TokenTag tag)

        tag.setPageContext(pageContext);

        String token = null;

        try {
            tag.doStartTag();
            tag.doEndTag();

            token = (String) context.get(tokenName);
            assertNotNull(token);
            assertEquals(token, pageContext.getSession().getAttribute(tokenName));
        } catch (JspException e) {
            e.printStackTrace();
            fail();
        }

        return token;
    
public voidtestDefaultName()

        String tokenName = TokenHelper.DEFAULT_TOKEN_NAME;
        TokenTag tag = new TokenTag();
        doTokenTest(tokenName, tag);
    
public voidtestMultipleTagsWithSameName()

        String tokenName = "sameName";
        TokenTag tag = new TokenTag();
        tag.setName(tokenName);

        String token = doTokenTest(tokenName, tag);

        TokenTag anotherTag = new TokenTag();
        anotherTag.setName(tokenName);

        String anotherToken = doTokenTest(tokenName, anotherTag);
        assertEquals(token, anotherToken);
    
public voidtestNotFindableName()
WW-480

        String tokenName = "foo";
        TokenTag tag = new TokenTag();
        tag.setName(tokenName);
        doTokenTest(tokenName, tag);

        String s = writer.toString();
        assertTrue(s.indexOf("name=\"" + TokenHelper.DEFAULT_TOKEN_NAME) > -1);
        assertTrue(s.indexOf("value=\"" + tokenName + "\"") > -1);
        assertTrue(s.indexOf("name=\"" + tokenName + "\"") > -1);

        //System.out.println(s);
    
public voidtestSuppliedName()

        String tokenName = "my.very.long.token.name";
        TokenTag tag = new TokenTag();
        tag.setName(tokenName);
        doTokenTest(tokenName, tag);