KickJava   Java API By Example, From Geeks To Geeks.

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


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

60     public TestMultiboxTag3(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[] {TestMultiboxTag3.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(TestMultiboxTag3.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     }
96
97     /*
98      * Testing MultiboxTag.
99      */

100     public void testMultiboxPropertyFalse() throws Exception JavaDoc {
101         runMyTest("testMultiboxPropertyFalse", "");
102         }
103     public void testMultiboxPropertyFalseAccesskey() throws Exception JavaDoc {
104         runMyTest("testMultiboxPropertyFalseAccesskey", "");
105         }
106     public void testMultiboxPropertyFalseAlt() throws Exception JavaDoc {
107         runMyTest("testMultiboxPropertyFalseAlt", "");
108         }
109     public void testMultiboxPropertyFalseAltKey1() throws Exception JavaDoc {
110         runMyTest("testMultiboxPropertyFalseAltKey1", "");
111         }
112     public void testMultiboxPropertyFalseAltKey2() throws Exception JavaDoc {
113         runMyTest("testMultiboxPropertyFalseAltKey2", "");
114         }
115     public void testMultiboxPropertyFalseAltKey_fr1() throws Exception JavaDoc {
116         runMyTest("testMultiboxPropertyFalseAltKey1_fr", "fr");
117         }
118     public void testMultiboxPropertyFalseAltKey_fr2() throws Exception JavaDoc {
119         runMyTest("testMultiboxPropertyFalseAltKey2_fr", "fr");
120         }
121     public void testMultiboxPropertyFalseDisabled_True() throws Exception JavaDoc {
122         runMyTest("testMultiboxPropertyFalseDisabled_True", "");
123         }
124     public void testMultiboxPropertyFalseDisabled_False1() throws Exception JavaDoc {
125         runMyTest("testMultiboxPropertyFalseDisabled_False1", "");
126         }
127     public void testMultiboxPropertyFalseDisabled_False2() throws Exception JavaDoc {
128         runMyTest("testMultiboxPropertyFalseDisabled_False2", "");
129         }
130     public void testMultiboxPropertyFalseOnblur() throws Exception JavaDoc {
131         runMyTest("testMultiboxPropertyFalseOnblur", "");
132         }
133
134     public void testMultiboxPropertyFalseOnchange() throws Exception JavaDoc {
135         runMyTest("testMultiboxPropertyFalseOnchange", "");
136         }
137
138     public void testMultiboxPropertyFalseOnclick() throws Exception JavaDoc {
139         runMyTest("testMultiboxPropertyFalseOnclick", "");
140         }
141
142     public void testMultiboxPropertyFalseOndblclick() throws Exception JavaDoc {
143         runMyTest("testMultiboxPropertyFalseOndblclick", "");
144         }
145
146     public void testMultiboxPropertyFalseOnfocus() throws Exception JavaDoc {
147         runMyTest("testMultiboxPropertyFalseOnfocus", "");
148         }
149
150     public void testMultiboxPropertyFalseOnkeydown() throws Exception JavaDoc {
151         runMyTest("testMultiboxPropertyFalseOnkeydown", "");
152         }
153
154     public void testMultiboxPropertyFalseOnkeypress() throws Exception JavaDoc {
155         runMyTest("testMultiboxPropertyFalseOnkeypress", "");
156         }
157
158     public void testMultiboxPropertyFalseOnkeyup() throws Exception JavaDoc {
159         runMyTest("testMultiboxPropertyFalseOnkeyup", "");
160         }
161
162     public void testMultiboxPropertyFalseOnmousedown() throws Exception JavaDoc {
163         runMyTest("testMultiboxPropertyFalseOnmousedown", "");
164         }
165
166     public void testMultiboxPropertyFalseOnmousemove() throws Exception JavaDoc {
167         runMyTest("testMultiboxPropertyFalseOnmousemove", "");
168         }
169
170     public void testMultiboxPropertyFalseOnmouseout() throws Exception JavaDoc {
171         runMyTest("testMultiboxPropertyFalseOnmouseout", "");
172         }
173
174     public void testMultiboxPropertyFalseOnmouseover() throws Exception JavaDoc {
175         runMyTest("testMultiboxPropertyFalseOnmouseover", "");
176         }
177
178     public void testMultiboxPropertyFalseOnmouseup() throws Exception JavaDoc {
179         runMyTest("testMultiboxPropertyFalseOnmouseup", "");
180         }
181
182 }
183
Popular Tags