KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

42     public void testChecked() {
43         FormTag parent = new FormTag();
44         RadioTag tag = new RadioTag();
45         tag.setParent(parent);
46         tag.setPageContext(pageContext);
47         tag.setName("test");
48         tag.setChecked(Boolean.TRUE);
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("Radio tag: " + tagStr);
55             assertEquals("Should be radio tag", tagStr,
56                 "<input type=\"radio\" name=\"test\" checked/>");
57         } catch (JspException JavaDoc e) {
58             fail(e.toString());
59         }
60     }
61
62     /**
63      * Tests the rest of the tag
64      */

65     public void testAll() {
66         FormTag parent = new FormTag();
67         RadioTag tag = new RadioTag();
68         tag.setParent(parent);
69         tag.setPageContext(pageContext);
70         tag.setName("test");
71         tag.setId("test");
72         
73         try {
74             assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE);
75             String JavaDoc tagStr = getPageContext().getMockOut().getText();
76
77             System.out.println("Radio tag: " + tagStr);
78             assertEquals("Should be radio tag", tagStr,
79                 "<input type=\"radio\" id=\"test\" name=\"test\"/>");
80         } catch (JspException JavaDoc e) {
81             fail(e.toString());
82         }
83     }
84 }
Popular Tags