KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: TestMultiboxTag2.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.Locale JavaDoc;
21
22 import javax.servlet.jsp.PageContext JavaDoc;
23 import junit.framework.Test;
24 import junit.framework.TestSuite;
25
26 import org.apache.cactus.JspTestCase;
27 import org.apache.struts.Globals;
28 import org.apache.struts.taglib.SimpleBeanForTesting;
29
30 /**
31  * Suite of unit tests for the
32  * <code>org.apache.struts.taglib.html.MultiboxTag</code> class.
33  * NOTE - These tests were separated into 4 files each because of the
34  * size of the jsp. (not playing well with Tomcat 3.3
35  *
36  * These tests are numbered as such:
37  *
38  * 1 thru 4 test a single checkbox
39  * TestMultiboxTag1 - These test validate true (a value was in the array) on our form.
40  * TestMultiboxTag2 - Same as 1, but using BodyContent instead of value attribute
41  *
42  * TestMultiboxTag3 - These test validate true (a value was in the array) on our form.
43  * TestMultiboxTag4 - Same as 3, but using BodyContent instead of value attribute
44  *
45  * 5 thru 8 test multiple checkboxes
46  * TestMultiboxTag5 - These test validate true (a value was in the array) on our form.
47  * TestMultiboxTag6 - Same as 5, but using BodyContent instead of value attribute
48  *
49  * TestMultiboxTag7 - These test validate true (a value was in the array) on our form.
50  * TestMultiboxTag8 - Same as 7, but using BodyContent instead of value attribute
51  *
52  *
53  */

54 public class TestMultiboxTag2 extends JspTestCase {
55
56     /**
57      * Defines the testcase name for JUnit.
58      *
59      * @param theName the testcase's name.
60      */

61     public TestMultiboxTag2(String JavaDoc theName) {
62         super(theName);
63     }
64
65     /**
66      * Start the tests.
67      *
68      * @param theArgs the arguments. Not used
69      */

70     public static void main(String JavaDoc[] theArgs) {
71         junit.awtui.TestRunner.main(new String JavaDoc[] {TestMultiboxTag2.class.getName()});
72     }
73
74     /**
75      * @return a test suite (<code>TestSuite</code>) that includes all methods
76      * starting with "test"
77      */

78     public static Test suite() {
79         // All methods starting with "test" will be executed in the test suite.
80
return new TestSuite(TestMultiboxTag2.class);
81     }
82
83     private void runMyTest(String JavaDoc whichTest, String JavaDoc locale) throws Exception JavaDoc {
84         pageContext.setAttribute(Globals.LOCALE_KEY,
85                         new Locale JavaDoc(locale, locale),
86                         PageContext.SESSION_SCOPE);
87
88                 String JavaDoc[] s = new String JavaDoc[7];
89                 for(int i = 1; i < 7; i++){
90                         s[i] = "value" + i;
91                 }
92                 SimpleBeanForTesting sbft = new SimpleBeanForTesting(s);
93
94         pageContext.setAttribute(Constants.BEAN_KEY, sbft, PageContext.REQUEST_SCOPE);
95         request.setAttribute("runTest", whichTest);
96         pageContext.forward("/test/org/apache/struts/taglib/html/TestMultiboxTag2.jsp");
97     }
98
99     /*
100      * Testing MultiboxTag.
101      */

102     public void testMultiboxBodyPropertyTrue() throws Exception JavaDoc {
103         runMyTest("testMultiboxBodyPropertyTrue", "");
104         }
105     public void testMultiboxBodyPropertyTrueAccesskey() throws Exception JavaDoc {
106         runMyTest("testMultiboxBodyPropertyTrueAccesskey", "");
107         }
108     public void testMultiboxBodyPropertyTrueAlt() throws Exception JavaDoc {
109         runMyTest("testMultiboxBodyPropertyTrueAlt", "");
110         }
111     public void testMultiboxBodyPropertyTrueAltKey1() throws Exception JavaDoc {
112         runMyTest("testMultiboxBodyPropertyTrueAltKey1", "");
113         }
114     public void testMultiboxBodyPropertyTrueAltKey2() throws Exception JavaDoc {
115         runMyTest("testMultiboxBodyPropertyTrueAltKey2", "");
116         }
117     public void testMultiboxBodyPropertyTrueAltKey_fr1() throws Exception JavaDoc {
118         runMyTest("testMultiboxBodyPropertyTrueAltKey1_fr", "fr");
119         }
120     public void testMultiboxBodyPropertyTrueAltKey_fr2() throws Exception JavaDoc {
121         runMyTest("testMultiboxBodyPropertyTrueAltKey2_fr", "fr");
122         }
123     public void testMultiboxBodyPropertyTrueDisabled_True() throws Exception JavaDoc {
124         runMyTest("testMultiboxBodyPropertyTrueDisabled_True", "");
125         }
126     public void testMultiboxBodyPropertyTrueDisabled_False1() throws Exception JavaDoc {
127         runMyTest("testMultiboxBodyPropertyTrueDisabled_False1", "");
128         }
129     public void testMultiboxBodyPropertyTrueDisabled_False2() throws Exception JavaDoc {
130         runMyTest("testMultiboxBodyPropertyTrueDisabled_False2", "");
131         }
132     public void testMultiboxBodyPropertyTrueOnblur() throws Exception JavaDoc {
133         runMyTest("testMultiboxBodyPropertyTrueOnblur", "");
134         }
135
136     public void testMultiboxBodyPropertyTrueOnchange() throws Exception JavaDoc {
137         runMyTest("testMultiboxBodyPropertyTrueOnchange", "");
138         }
139
140     public void testMultiboxBodyPropertyTrueOnclick() throws Exception JavaDoc {
141         runMyTest("testMultiboxBodyPropertyTrueOnclick", "");
142         }
143
144     public void testMultiboxBodyPropertyTrueOndblclick() throws Exception JavaDoc {
145         runMyTest("testMultiboxBodyPropertyTrueOndblclick", "");
146         }
147
148     public void testMultiboxBodyPropertyTrueOnfocus() throws Exception JavaDoc {
149         runMyTest("testMultiboxBodyPropertyTrueOnfocus", "");
150         }
151
152     public void testMultiboxBodyPropertyTrueOnkeydown() throws Exception JavaDoc {
153         runMyTest("testMultiboxBodyPropertyTrueOnkeydown", "");
154         }
155
156     public void testMultiboxBodyPropertyTrueOnkeypress() throws Exception JavaDoc {
157         runMyTest("testMultiboxBodyPropertyTrueOnkeypress", "");
158         }
159
160     public void testMultiboxBodyPropertyTrueOnkeyup() throws Exception JavaDoc {
161         runMyTest("testMultiboxBodyPropertyTrueOnkeyup", "");
162         }
163
164     public void testMultiboxBodyPropertyTrueOnmousedown() throws Exception JavaDoc {
165         runMyTest("testMultiboxBodyPropertyTrueOnmousedown", "");
166         }
167
168     public void testMultiboxBodyPropertyTrueOnmousemove() throws Exception JavaDoc {
169         runMyTest("testMultiboxBodyPropertyTrueOnmousemove", "");
170         }
171
172     public void testMultiboxBodyPropertyTrueOnmouseout() throws Exception JavaDoc {
173         runMyTest("testMultiboxBodyPropertyTrueOnmouseout", "");
174         }
175
176     public void testMultiboxBodyPropertyTrueOnmouseover() throws Exception JavaDoc {
177         runMyTest("testMultiboxBodyPropertyTrueOnmouseover", "");
178         }
179
180     public void testMultiboxBodyPropertyTrueOnmouseup() throws Exception JavaDoc {
181         runMyTest("testMultiboxBodyPropertyTrueOnmouseup", "");
182         }
183
184 }
185
Popular Tags