FileDocCategorySizeDatePackage
FreemarkerTest.javaAPI DocExample3181Mon Jul 23 13:26:12 BST 2007org.apache.struts2.views.freemarker

FreemarkerTest

public class FreemarkerTest extends TestCase

Fields Summary
TestAction
testAction
Constructors Summary
public FreemarkerTest(String name)



         
       
        super(name);
    
Methods Summary
protected voidsetUp()

        super.setUp();

        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
        ActionContext.setContext(new ActionContext(stack.getContext()));

        testAction = new TestAction();
        ActionContext.getContext().getValueStack().push(testAction);
    
protected voidtearDown()

        super.tearDown();
        ActionContext.setContext(null);
    
public voidtestSelectHelper()

        StrutsUtil wwUtil = new StrutsUtil(ActionContext.getContext().getValueStack(), null, null);

        List selectList = null;

        selectList = wwUtil.makeSelectList("ignored", "stringList", null, null);
        assertEquals("one", ((ListEntry) selectList.get(0)).getKey());
        assertEquals("one", ((ListEntry) selectList.get(0)).getValue());

        selectList = wwUtil.makeSelectList("ignored", "beanList", "name", "value");
        assertEquals("one", ((ListEntry) selectList.get(0)).getKey());
        assertEquals("1", ((ListEntry) selectList.get(0)).getValue());
    
public voidtestValueStackMode()

        ScopesHashModel model = new ScopesHashModel(ObjectWrapper.BEANS_WRAPPER, null, null, ActionContext.getContext().getValueStack());

        CollectionModel stringList = null;

        stringList = (CollectionModel) model.get("stringList");
        assertEquals("one", stringList.get(0).toString());

        assertEquals("one", model.get("stringList[0]").toString());
        assertEquals("one", model.get("beanList[0].name").toString());