KickJava   Java API By Example, From Geeks To Geeks.

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


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

60     public TestOptionTag1(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[] {TestOptionTag1.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(TestOptionTag1.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                 SimpleBeanForTesting sbft = new SimpleBeanForTesting("SelectMe");
88
89         pageContext.setAttribute(Constants.BEAN_KEY, sbft, PageContext.REQUEST_SCOPE);
90         request.setAttribute("runTest", whichTest);
91         pageContext.forward("/test/org/apache/struts/taglib/html/TestOptionTag1.jsp");
92     }
93
94     /*
95      * Testing MultiboxTag.
96      */

97     public void testOptionBodySelected() throws Exception JavaDoc {
98         runMyTest("testOptionBodySelected", "");
99         }
100
101     public void testOptionBodyNotSelected() throws Exception JavaDoc {
102         runMyTest("testOptionBodyNotSelected", "");
103         }
104
105     public void testOptionBodySelectedDisabled_true() throws Exception JavaDoc {
106         runMyTest("testOptionBodySelectedDisabled_true", "");
107         }
108
109     public void testOptionBodyNotSelectedDisabled_true() throws Exception JavaDoc {
110         runMyTest("testOptionBodyNotSelectedDisabled_true", "");
111         }
112
113     public void testOptionBodySelectedDisabled_false() throws Exception JavaDoc {
114         runMyTest("testOptionBodySelectedDisabled_false", "");
115         }
116
117     public void testOptionBodyNotSelectedDisabled_false() throws Exception JavaDoc {
118         runMyTest("testOptionBodyNotSelectedDisabled_false", "");
119         }
120
121     public void testOptionBodySelectedDisabled_other() throws Exception JavaDoc {
122         runMyTest("testOptionBodySelectedDisabled_other", "");
123         }
124
125     public void testOptionBodyNotSelectedDisabled_other() throws Exception JavaDoc {
126         runMyTest("testOptionBodyNotSelectedDisabled_other", "");
127         }
128
129     public void testOptionKeySelected() throws Exception JavaDoc {
130         runMyTest("testOptionKeySelected", "");
131         }
132
133     public void testOptionKeyNotSelected() throws Exception JavaDoc {
134         runMyTest("testOptionKeyNotSelected", "");
135         }
136
137     public void testOptionKeySelectedAlternateBundle() throws Exception JavaDoc {
138         runMyTest("testOptionKeySelectedAlternateBundle", "");
139         }
140
141     public void testOptionKeyNotSelectedAlternateBundle() throws Exception JavaDoc {
142         runMyTest("testOptionKeyNotSelectedAlternateBundle", "");
143         }
144
145     public void testOptionKeySelectedLocale_fr() throws Exception JavaDoc {
146         runMyTest("testOptionKeySelectedLocale_fr", "fr");
147         }
148
149     public void testOptionKeyNotSelectedLocale_fr() throws Exception JavaDoc {
150         runMyTest("testOptionKeyNotSelectedLocale_fr", "fr");
151         }
152
153     public void testOptionKeySelectedAlternateBundleLocale_fr() throws Exception JavaDoc {
154         runMyTest("testOptionKeySelectedAlternateBundleLocale_fr", "fr");
155         }
156
157     public void testOptionKeyNotSelectedAlternateBundleLocale_fr() throws Exception JavaDoc {
158         runMyTest("testOptionKeyNotSelectedAlternateBundleLocale_fr", "fr");
159         }
160
161 }
162
Popular Tags