KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: TestMultiboxTag5.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  *
37  */

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

45     public TestMultiboxTag5(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[] {TestMultiboxTag5.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(TestMultiboxTag5.class);
65     }
66
67     private void runMyTest(String JavaDoc whichTest, String JavaDoc locale) throws Exception JavaDoc {
68         pageContext.setAttribute(Globals.LOCALE_KEY,
69                         new Locale JavaDoc(locale, locale),
70                         PageContext.SESSION_SCOPE);
71
72                 String JavaDoc[] s = new String JavaDoc[7];
73                 for(int i = 1; i < 7; i++){
74                         s[i] = "value" + i;
75                 }
76                 SimpleBeanForTesting sbft = new SimpleBeanForTesting(s);
77
78         pageContext.setAttribute(Constants.BEAN_KEY, sbft, PageContext.REQUEST_SCOPE);
79         request.setAttribute("runTest", whichTest);
80         pageContext.forward("/test/org/apache/struts/taglib/html/TestMultiboxTag5.jsp");
81     }
82
83     /*
84      * Testing MultiboxTag.
85      */

86     public void testMultiboxPropertyStyle() throws Exception JavaDoc {
87         runMyTest("testMultiboxPropertyStyle", "");
88     }
89     public void testMultiboxPropertyErrorStyle() throws Exception JavaDoc {
90         runMyTest("testMultiboxPropertyErrorStyle", "");
91     }
92     public void testMultiboxPropertyStyleClass() throws Exception JavaDoc {
93         runMyTest("testMultiboxPropertyStyleClass", "");
94     }
95     public void testMultiboxPropertyErrorStyleClass() throws Exception JavaDoc {
96         runMyTest("testMultiboxPropertyErrorStyleClass", "");
97     }
98     public void testMultiboxPropertyStyleId() throws Exception JavaDoc {
99         runMyTest("testMultiboxPropertyStyleId", "");
100     }
101     public void testMultiboxPropertyErrorStyleId() throws Exception JavaDoc {
102         runMyTest("testMultiboxPropertyErrorStyleId", "");
103     }
104
105 }
106
Popular Tags