KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > taglib > html > TestCheckboxTag4


1 /*
2  * $Id: TestCheckboxTag4.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.struts.taglib.html;
19
20 import java.util.ArrayList JavaDoc;
21 import java.util.HashMap JavaDoc;
22 import java.util.Locale JavaDoc;
23 import java.util.StringTokenizer JavaDoc;
24
25 import javax.servlet.jsp.PageContext JavaDoc;
26 import junit.framework.Test;
27 import junit.framework.TestSuite;
28
29 import org.apache.cactus.JspTestCase;
30 import org.apache.struts.Globals;
31 import org.apache.struts.taglib.SimpleBeanForTesting;
32
33 /**
34  * Suite of unit tests for the
35  * <code>org.apache.struts.taglib.html.CheckboxTag</code> class.
36  *
37  */

38 public class TestCheckboxTag4 extends JspTestCase {
39
40     /**
41      * Defines the testcase name for JUnit.
42      *
43      * @param theName the testcase's name.
44      */

45     public TestCheckboxTag4(String JavaDoc theName) {
46         super(theName);
47     }
48
49     /**
50      * Start the tests.
51      *
52      * @param theArgs the arguments. Not used
53      */

54     public static void main(String JavaDoc[] theArgs) {
55         junit.awtui.TestRunner.main(new String JavaDoc[] {TestCheckboxTag4.class.getName()});
56     }
57
58     /**
59      * @return a test suite (<code>TestSuite</code>) that includes all methods
60      * starting with "test"
61      */

62     public static Test suite() {
63         // All methods starting with "test" will be executed in the test suite.
64
return new TestSuite(TestCheckboxTag4.class);
65     }
66
67     private void runMyTest(String JavaDoc whichTest, String JavaDoc locale) throws Exception JavaDoc {
68         pageContext.setAttribute(Globals.LOCALE_KEY, new Locale JavaDoc(locale, locale), PageContext.SESSION_SCOPE);
69         pageContext.setAttribute(Constants.BEAN_KEY, new SimpleBeanForTesting(false), PageContext.REQUEST_SCOPE);
70         request.setAttribute("runTest", whichTest);
71         pageContext.forward("/test/org/apache/struts/taglib/html/TestCheckboxTag4.jsp");
72     }
73
74     /*
75      * Testing CheckboxTag.
76      */

77
78     public void testCheckboxPropertybooleanFalseStyle() throws Exception JavaDoc {
79         runMyTest("testCheckboxPropertybooleanFalseStyle", "");
80         }
81
82     public void testCheckboxPropertybooleanFalseStyleClass() throws Exception JavaDoc {
83         runMyTest("testCheckboxPropertybooleanFalseStyleClass", "");
84         }
85
86     public void testCheckboxPropertybooleanFalseStyleId() throws Exception JavaDoc {
87         runMyTest("testCheckboxPropertybooleanFalseStyleId", "");
88         }
89
90     public void testCheckboxPropertybooleanFalseTabindex() throws Exception JavaDoc {
91         runMyTest("testCheckboxPropertybooleanFalseTabindex", "");
92         }
93
94     public void testCheckboxPropertybooleanFalseTitle() throws Exception JavaDoc {
95         runMyTest("testCheckboxPropertybooleanFalseTitle", "");
96         }
97
98     public void testCheckboxPropertybooleanFalseTitleKey() throws Exception JavaDoc {
99         runMyTest("testCheckboxPropertybooleanFalseTitleKey", "");
100         }
101
102     public void testCheckboxPropertybooleanFalseTitleKey_fr() throws Exception JavaDoc {
103         runMyTest("testCheckboxPropertybooleanFalseTitleKey_fr", "fr");
104         }
105
106     public void testCheckboxPropertybooleanFalseValue() throws Exception JavaDoc {
107         runMyTest("testCheckboxPropertybooleanFalseValue", "");
108         }
109
110     public void testCheckboxPropertybooleanFalseBodyContent() throws Exception JavaDoc {
111         runMyTest("testCheckboxPropertybooleanFalseBodyContent", "");
112         }
113
114     public void testCheckboxPropertybooleanFalseBodyContentMessageKey() throws Exception JavaDoc {
115         runMyTest("testCheckboxPropertybooleanFalseBodyContentMessageKey", "");
116         }
117
118     public void testCheckboxPropertybooleanFalseBodyContentMessageKey_fr() throws Exception JavaDoc {
119         runMyTest("testCheckboxPropertybooleanFalseBodyContentMessageKey_fr", "fr");
120         }
121
122     public void testCheckboxPropertybooleanFalseIndexedArray() throws Exception JavaDoc {
123         ArrayList JavaDoc lst = new ArrayList JavaDoc();
124         lst.add("Test Message");
125         pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE);
126         runMyTest("testCheckboxPropertybooleanFalseIndexedArray", "");
127         }
128
129     public void testCheckboxPropertybooleanFalseIndexedArrayProperty() throws Exception JavaDoc {
130         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
131         ArrayList JavaDoc lst = new ArrayList JavaDoc();
132         lst.add("Test Message");
133         sbft.setList(lst);
134         pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
135         runMyTest("testCheckboxPropertybooleanFalseIndexedArrayProperty", "");
136         }
137
138     public void testCheckboxPropertybooleanFalseIndexedMap() throws Exception JavaDoc {
139         HashMap JavaDoc map = new HashMap JavaDoc();
140         map.put("tst1", "Test Message");
141         pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE);
142         runMyTest("testCheckboxPropertybooleanFalseIndexedMap", "");
143         }
144
145     public void testCheckboxPropertybooleanFalseIndexedMapProperty() throws Exception JavaDoc {
146         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
147         HashMap JavaDoc map = new HashMap JavaDoc();
148         map.put("tst1", "Test Message");
149         sbft.setMap(map);
150         pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
151         runMyTest("testCheckboxPropertybooleanFalseIndexedMapProperty", "");
152         }
153
154     public void testCheckboxPropertybooleanFalseIndexedEnumeration() throws Exception JavaDoc {
155         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Test Message");
156         pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE);
157         runMyTest("testCheckboxPropertybooleanFalseIndexedEnumeration", "");
158         }
159
160     public void testCheckboxPropertybooleanFalseIndexedEnumerationProperty() throws Exception JavaDoc {
161         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
162         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Test Message");
163         sbft.setEnumeration(st);
164         pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
165         runMyTest("testCheckboxPropertybooleanFalseIndexedEnumerationProperty", "");
166         }
167
168
169
170 }
171
Popular Tags