KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: TestSubmitTag2.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 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.ArrayList JavaDoc;
21 import java.util.HashMap JavaDoc;
22 import java.util.Locale JavaDoc;
23 import java.util.StringTokenizer JavaDoc;
24
25 import javax.servlet.jsp.PageContext JavaDoc;
26 import junit.framework.Test;
27 import junit.framework.TestSuite;
28
29 import org.apache.cactus.JspTestCase;
30 import org.apache.struts.Globals;
31 import org.apache.struts.taglib.SimpleBeanForTesting;
32
33 /**
34  * Suite of unit tests for the
35  * <code>org.apache.struts.taglib.html.SubmitTag</code> class.
36  *
37  */

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

45     public TestSubmitTag2(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[] {TestSubmitTag2.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(TestSubmitTag2.class);
65     }
66
67     private void runMyTest(String JavaDoc whichTest, String JavaDoc locale) throws Exception JavaDoc {
68         pageContext.setAttribute(Globals.LOCALE_KEY, new Locale JavaDoc(locale, locale), PageContext.SESSION_SCOPE);
69         request.setAttribute("runTest", whichTest);
70         pageContext.forward("/test/org/apache/struts/taglib/html/TestSubmitTag2.jsp");
71     }
72
73     /*
74      * Testing SubmitTag.
75      */

76
77     public void testSubmitPropertyStyle() throws Exception JavaDoc {
78         runMyTest("testSubmitPropertyStyle", "");
79     }
80     public void testSubmitPropertyStyleClass() throws Exception JavaDoc {
81         runMyTest("testSubmitPropertyStyleClass", "");
82     }
83     public void testSubmitPropertyStyleId() throws Exception JavaDoc {
84         runMyTest("testSubmitPropertyStyleId", "");
85     }
86     public void testSubmitPropertyTabindex() throws Exception JavaDoc {
87         runMyTest("testSubmitPropertyTabindex", "");
88     }
89     public void testSubmitPropertyTitle() throws Exception JavaDoc {
90         runMyTest("testSubmitPropertyTitle", "");
91     }
92     public void testSubmitPropertyTitleKey() throws Exception JavaDoc {
93         runMyTest("testSubmitPropertyTitleKey", "");
94     }
95     public void testSubmitPropertyTitleKey_fr() throws Exception JavaDoc {
96         runMyTest("testSubmitPropertyTitleKey_fr", "fr");
97     }
98     public void testSubmitPropertyValue() throws Exception JavaDoc {
99         runMyTest("testSubmitPropertyValue", "");
100     }
101     public void testSubmitPropertyBodyContent() throws Exception JavaDoc {
102         runMyTest("testSubmitPropertyBodyContent", "");
103     }
104     public void testSubmitPropertyBodyContentMessageKey() throws Exception JavaDoc {
105         runMyTest("testSubmitPropertyBodyContentMessageKey", "");
106     }
107     public void testSubmitPropertyBodyContentMessageKey_fr() throws Exception JavaDoc {
108         runMyTest("testSubmitPropertyBodyContentMessageKey_fr", "fr");
109     }
110     public void testSubmitPropertyIndexedArray() throws Exception JavaDoc {
111         ArrayList JavaDoc lst = new ArrayList JavaDoc();
112         lst.add("Test Message");
113         pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE);
114         runMyTest("testSubmitPropertyIndexedArray", "");
115     }
116     public void testSubmitPropertyIndexedArrayProperty() throws Exception JavaDoc {
117         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
118         ArrayList JavaDoc lst = new ArrayList JavaDoc();
119         lst.add("Test Message");
120         sbft.setList(lst);
121         pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
122         runMyTest("testSubmitPropertyIndexedArrayProperty", "");
123     }
124     public void testSubmitPropertyIndexedMap() throws Exception JavaDoc {
125         HashMap JavaDoc map = new HashMap JavaDoc();
126         map.put("tst1", "Test Message");
127         pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE);
128         runMyTest("testSubmitPropertyIndexedMap", "");
129     }
130     public void testSubmitPropertyIndexedMapProperty() throws Exception JavaDoc {
131         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
132         HashMap JavaDoc map = new HashMap JavaDoc();
133         map.put("tst1", "Test Message");
134         sbft.setMap(map);
135         pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
136         runMyTest("testSubmitPropertyIndexedMapProperty", "");
137     }
138     public void testSubmitPropertyIndexedEnumeration() throws Exception JavaDoc {
139         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Test Message");
140         pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE);
141         runMyTest("testSubmitPropertyIndexedEnumeration", "");
142     }
143     public void testSubmitPropertyIndexedEnumerationProperty() throws Exception JavaDoc {
144         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
145         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Test Message");
146         sbft.setEnumeration(st);
147         pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
148         runMyTest("testSubmitPropertyIndexedEnumerationProperty", "");
149     }
150
151 }
152
Popular Tags