KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > view > jsp > html > test > TextAreaTagTest


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.mvc.view.jsp.html.test;
8
9
10 import javax.servlet.jsp.JspException JavaDoc;
11 import javax.servlet.jsp.tagext.Tag JavaDoc;
12
13 import com.inversoft.junit.JspTestCase;
14 import com.inversoft.verge.mvc.view.jsp.html.FormTag;
15 import com.inversoft.verge.mvc.view.jsp.html.TextAreaTag;
16
17
18 /**
19  * <p>
20  * This class has the tests of the text area tag
21  * </p>
22  *
23  * @author Brian Pontarelli
24  * @since 2.0
25  * @version 2.0
26  */

27 public class TextAreaTagTest extends JspTestCase {
28
29     /**
30      * Constructor for TextAreaTagTest.
31      * @param name
32      */

33     public TextAreaTagTest(String JavaDoc name) {
34         super(name);
35         setLocal(true);
36     }
37
38
39     /**
40      * Tests the id attribute
41      */

42     public void testId() {
43         FormTag parent = new FormTag();
44         TextAreaTag tag = new TextAreaTag();
45         tag.setParent(parent);
46         tag.setPageContext(pageContext);
47         tag.setName("test");
48         tag.setId("test");
49         tag.setBodyContent(createBodyContent());
50         
51         try {
52             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
53             String JavaDoc tagStr = getPageContext().getMockOut().getText();
54
55             System.out.println("TextArea tag: " + tagStr);
56             assertEquals("Should be textarea tag", tagStr,
57                 "<textarea id=\"test\" name=\"test\"></textarea>");
58         } catch (JspException JavaDoc e) {
59             fail(e.toString());
60         }
61     }
62
63     /**
64      * Tests the cols attribute
65      */

66     public void testCols() {
67         FormTag parent = new FormTag();
68         TextAreaTag tag = new TextAreaTag();
69         tag.setParent(parent);
70         tag.setPageContext(pageContext);
71         tag.setName("test");
72         tag.setCols(new Integer JavaDoc(10));
73         tag.setBodyContent(createBodyContent());
74
75         try {
76             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
77             String JavaDoc tagStr = getPageContext().getMockOut().getText();
78
79             System.out.println("TextArea tag: " + tagStr);
80             assertEquals("Should be textarea tag", tagStr,
81                 "<textarea name=\"test\" cols=\"10\"></textarea>");
82         } catch (JspException JavaDoc e) {
83             fail(e.toString());
84         }
85     }
86
87     /**
88      * Tests the rows attribute
89      */

90     public void testRows() {
91         FormTag parent = new FormTag();
92         TextAreaTag tag = new TextAreaTag();
93         tag.setParent(parent);
94         tag.setPageContext(pageContext);
95         tag.setName("test");
96         tag.setRows(new Integer JavaDoc(15));
97         tag.setBodyContent(createBodyContent());
98         
99         try {
100             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
101             String JavaDoc tagStr = getPageContext().getMockOut().getText();
102
103             System.out.println("TextArea tag: " + tagStr);
104             assertEquals("Should be textarea tag", tagStr,
105                 "<textarea name=\"test\" rows=\"15\"></textarea>");
106         } catch (JspException JavaDoc e) {
107             fail(e.toString());
108         }
109     }
110
111     /**
112      * Tests the text attribute
113      */

114     public void testText() {
115         FormTag parent = new FormTag();
116         TextAreaTag tag = new TextAreaTag();
117         tag.setParent(parent);
118         tag.setPageContext(pageContext);
119         tag.setName("test");
120         tag.setText("text body");
121         
122         try {
123             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
124             String JavaDoc tagStr = getPageContext().getMockOut().getText();
125
126             System.out.println("TextArea tag: " + tagStr);
127             assertEquals("Should be textarea tag", tagStr,
128                 "<textarea name=\"test\">text body</textarea>");
129         } catch (JspException JavaDoc e) {
130             fail(e.toString());
131         }
132     }
133 }
Popular Tags