KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > views > jsp > ui > ComponentTest


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.webwork.views.jsp.ui;
6
7 import com.opensymphony.webwork.TestAction;
8 import com.opensymphony.webwork.views.jsp.AbstractUITagTest;
9
10
11 /**
12  * @author Matt Ho <a HREF="mailto:matt@enginegreen.com">&lt;matt@enginegreen.com&gt;</a>
13  * @version $Id: ComponentTest.java,v 1.15 2005/08/02 14:48:13 plightbo Exp $
14  */

15 public class ComponentTest extends AbstractUITagTest {
16     //~ Methods ////////////////////////////////////////////////////////////////
17

18     /**
19      * Note -- this test uses empty.vm, so it's basically clear
20      */

21     public void testSimple() throws Exception JavaDoc {
22         TestAction testAction = (TestAction) action;
23         testAction.setFoo("bar");
24
25         ComponentTag tag = new ComponentTag();
26         tag.setPageContext(pageContext);
27         tag.setLabel("mylabel");
28         tag.setName("myname");
29         tag.setValue("foo");
30
31         tag.doStartTag();
32         tag.doEndTag();
33
34         verify(ComponentTag.class.getResource("Component-1.txt"));
35     }
36
37     /**
38      * executes a component test passing in a custom parameter. it also executes calling a custom template using an
39      * absolute reference.
40      */

41     public void testWithParam() throws Exception JavaDoc {
42         TestAction testAction = (TestAction) action;
43         testAction.setFoo("bar");
44
45         ComponentTag tag = new ComponentTag();
46         tag.setPageContext(pageContext);
47         tag.setLabel("mylabel");
48         tag.setName("myname");
49         tag.setValue("foo");
50         tag.setTheme("test");
51         tag.setTemplate("Component");
52
53         tag.addParameter("hello", "world");
54         tag.addParameter("argle", "bargle");
55         tag.addParameter("glip", "glop");
56         tag.addParameter("array", new String JavaDoc[]{"a", "b", "c"});
57         tag.addParameter("obj", tag);
58
59         tag.doStartTag();
60         tag.doEndTag();
61
62         // System.out.println(writer);
63
verify(ComponentTag.class.getResource("Component-param.txt"));
64     }
65 }
66
Popular Tags