KickJava   Java API By Example, From Geeks To Geeks.

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


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.PasswordTag;
16
17
18 /**
19  * <p>
20  * This class has the tests for the password tag.
21  * </p>
22  *
23  * @author Brian Pontarelli
24  * @since 2.0
25  * @version 2.0
26  */

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

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

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

65     public void testValueSupression() {
66         FormTag parent = new FormTag();
67         PasswordTag tag = new PasswordTag();
68         tag.setParent(parent);
69         tag.setPageContext(pageContext);
70         tag.setId("test");
71         tag.setName("test");
72         tag.setValue("test");
73         
74         try {
75             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
76             String JavaDoc tagStr = getPageContext().getMockOut().getText();
77
78             System.out.println("Password tag: " + tagStr);
79             assertEquals("Should be password tag", tagStr,
80                 "<input type=\"password\" id=\"test\" name=\"test\"/>");
81         } catch (JspException JavaDoc e) {
82             fail(e.toString());
83         }
84     }
85
86     /**
87      * Tests the value
88      */

89     public void testValue() {
90         FormTag parent = new FormTag();
91         PasswordTag tag = new PasswordTag();
92         tag.setParent(parent);
93         tag.setPageContext(pageContext);
94         tag.setId("test");
95         tag.setName("test");
96         tag.setValue("test");
97         tag.setShowPassword(true);
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("Password tag: " + tagStr);
104             assertEquals("Should be password tag", tagStr,
105                 "<input type=\"password\" id=\"test\" name=\"test\" value=\"test\"/>");
106         } catch (JspException JavaDoc e) {
107             fail(e.toString());
108         }
109     }
110
111     /**
112      * Tests the value
113      */

114     public void testValueObject() {
115         FormTag parent = new FormTag();
116         PasswordTag tag = new PasswordTag();
117         tag.setParent(parent);
118         tag.setPageContext(pageContext);
119         tag.setId("test");
120         tag.setName("test");
121         tag.setValue(new Bean("test2", "test2"));
122         tag.setShowPassword(true);
123
124         try {
125             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
126             String JavaDoc tagStr = getPageContext().getMockOut().getText();
127
128             System.out.println("Password tag: " + tagStr);
129             assertEquals("Should be password tag", tagStr,
130                 "<input type=\"password\" id=\"test\" name=\"test\" value=\"test2\"/>");
131         } catch (JspException JavaDoc e) {
132             fail(e.toString());
133         }
134     }
135 }
Popular Tags