KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: TestMultiboxTag1.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 public class TestMultiboxTag1 extends JspTestCase {
54
55     /**
56      * Defines the testcase name for JUnit.
57      *
58      * @param theName the testcase's name.
59      */

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

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

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

101     public void testMultiboxPropertyTrue() throws Exception JavaDoc {
102         runMyTest("testMultiboxPropertyTrue", "");
103         }
104     public void testMultiboxPropertyTrueAccesskey() throws Exception JavaDoc {
105         runMyTest("testMultiboxPropertyTrueAccesskey", "");
106         }
107     public void testMultiboxPropertyTrueAlt() throws Exception JavaDoc {
108         runMyTest("testMultiboxPropertyTrueAlt", "");
109         }
110     public void testMultiboxPropertyTrueAltKey1() throws Exception JavaDoc {
111         runMyTest("testMultiboxPropertyTrueAltKey1", "");
112         }
113     public void testMultiboxPropertyTrueAltKey2() throws Exception JavaDoc {
114         runMyTest("testMultiboxPropertyTrueAltKey2", "");
115         }
116     public void testMultiboxPropertyTrueAltKey3() throws Exception JavaDoc {
117         runMyTest("testMultiboxPropertyTrueAltKey3", "");
118     }
119     public void testMultiboxPropertyTrueAltKey_fr1() throws Exception JavaDoc {
120         runMyTest("testMultiboxPropertyTrueAltKey1_fr", "fr");
121         }
122     public void testMultiboxPropertyTrueAltKey_fr2() throws Exception JavaDoc {
123         runMyTest("testMultiboxPropertyTrueAltKey2_fr", "fr");
124         }
125     public void testMultiboxPropertyTrueDisabled_True() throws Exception JavaDoc {
126         runMyTest("testMultiboxPropertyTrueDisabled_True", "");
127         }
128     public void testMultiboxPropertyTrueDisabled_False1() throws Exception JavaDoc {
129         runMyTest("testMultiboxPropertyTrueDisabled_False1", "");
130         }
131     public void testMultiboxPropertyTrueDisabled_False2() throws Exception JavaDoc {
132         runMyTest("testMultiboxPropertyTrueDisabled_False2", "");
133         }
134     public void testMultiboxPropertyTrueOnblur() throws Exception JavaDoc {
135         runMyTest("testMultiboxPropertyTrueOnblur", "");
136         }
137
138     public void testMultiboxPropertyTrueOnchange() throws Exception JavaDoc {
139         runMyTest("testMultiboxPropertyTrueOnchange", "");
140         }
141
142     public void testMultiboxPropertyTrueOnclick() throws Exception JavaDoc {
143         runMyTest("testMultiboxPropertyTrueOnclick", "");
144         }
145
146     public void testMultiboxPropertyTrueOndblclick() throws Exception JavaDoc {
147         runMyTest("testMultiboxPropertyTrueOndblclick", "");
148         }
149
150     public void testMultiboxPropertyTrueOnfocus() throws Exception JavaDoc {
151         runMyTest("testMultiboxPropertyTrueOnfocus", "");
152         }
153
154     public void testMultiboxPropertyTrueOnkeydown() throws Exception JavaDoc {
155         runMyTest("testMultiboxPropertyTrueOnkeydown", "");
156         }
157
158     public void testMultiboxPropertyTrueOnkeypress() throws Exception JavaDoc {
159         runMyTest("testMultiboxPropertyTrueOnkeypress", "");
160         }
161
162     public void testMultiboxPropertyTrueOnkeyup() throws Exception JavaDoc {
163         runMyTest("testMultiboxPropertyTrueOnkeyup", "");
164         }
165
166     public void testMultiboxPropertyTrueOnmousedown() throws Exception JavaDoc {
167         runMyTest("testMultiboxPropertyTrueOnmousedown", "");
168         }
169
170     public void testMultiboxPropertyTrueOnmousemove() throws Exception JavaDoc {
171         runMyTest("testMultiboxPropertyTrueOnmousemove", "");
172         }
173
174     public void testMultiboxPropertyTrueOnmouseout() throws Exception JavaDoc {
175         runMyTest("testMultiboxPropertyTrueOnmouseout", "");
176         }
177
178     public void testMultiboxPropertyTrueOnmouseover() throws Exception JavaDoc {
179         runMyTest("testMultiboxPropertyTrueOnmouseover", "");
180         }
181
182     public void testMultiboxPropertyTrueOnmouseup() throws Exception JavaDoc {
183         runMyTest("testMultiboxPropertyTrueOnmouseup", "");
184         }
185
186 }
187
Popular Tags