KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: TestRadioTag2.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.RadioTag</code> class.
36  *
37  */

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

45     public TestRadioTag2(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[] {TestRadioTag2.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(TestRadioTag2.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         pageContext.setAttribute(Constants.BEAN_KEY, new SimpleBeanForTesting("Test Value"), PageContext.REQUEST_SCOPE);
70         request.setAttribute("runTest", whichTest);
71         pageContext.forward("/test/org/apache/struts/taglib/html/TestRadioTag2.jsp");
72     }
73
74     /*
75      * Testing RadioTag.
76      */

77
78     public void testRadioPropertyStyle() throws Exception JavaDoc {
79         runMyTest("testRadioPropertyStyle", "");
80     }
81     public void testRadioPropertyErrorStyle() throws Exception JavaDoc {
82         runMyTest("testRadioPropertyErrorStyle", "");
83     }
84     public void testRadioPropertyStyleClass() throws Exception JavaDoc {
85         runMyTest("testRadioPropertyStyleClass", "");
86     }
87     public void testRadioPropertyErrorStyleClass() throws Exception JavaDoc {
88         runMyTest("testRadioPropertyErrorStyleClass", "");
89     }
90     public void testRadioPropertyStyleId() throws Exception JavaDoc {
91         runMyTest("testRadioPropertyStyleId", "");
92     }
93     public void testRadioPropertyErrorStyleId() throws Exception JavaDoc {
94         runMyTest("testRadioPropertyErrorStyleId", "");
95     }
96     public void testRadioPropertyTitle() throws Exception JavaDoc {
97         runMyTest("testRadioPropertyTitle", "");
98     }
99     public void testRadioPropertyTitleKey() throws Exception JavaDoc {
100         runMyTest("testRadioPropertyTitleKey", "");
101     }
102     public void testRadioPropertyTitleKey_fr() throws Exception JavaDoc {
103         runMyTest("testRadioPropertyTitleKey_fr", "fr");
104     }
105     public void testRadioPropertyValueMatch() throws Exception JavaDoc {
106         runMyTest("testRadioPropertyValueMatch", "");
107     }
108     public void testRadioPropertyValueNotMatch() throws Exception JavaDoc {
109         runMyTest("testRadioPropertyValueNotMatch", "");
110     }
111     public void testRadioPropertyIndexedArray() throws Exception JavaDoc {
112         ArrayList JavaDoc lst = new ArrayList JavaDoc();
113         lst.add("Test Message");
114         pageContext.setAttribute("lst", lst, PageContext.REQUEST_SCOPE);
115         runMyTest("testRadioPropertyIndexedArray", "");
116     }
117     public void testRadioPropertyIndexedArrayProperty() throws Exception JavaDoc {
118         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
119         ArrayList JavaDoc lst = new ArrayList JavaDoc();
120         lst.add("Test Message");
121         sbft.setList(lst);
122         pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
123         runMyTest("testRadioPropertyIndexedArrayProperty", "");
124     }
125     public void testRadioPropertyIndexedMap() throws Exception JavaDoc {
126         HashMap JavaDoc map = new HashMap JavaDoc();
127         map.put("tst1", "Test Message");
128         pageContext.setAttribute("lst", map, PageContext.REQUEST_SCOPE);
129         runMyTest("testRadioPropertyIndexedMap", "");
130     }
131     public void testRadioPropertyIndexedMapProperty() throws Exception JavaDoc {
132         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
133         HashMap JavaDoc map = new HashMap JavaDoc();
134         map.put("tst1", "Test Message");
135         sbft.setMap(map);
136         pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
137         runMyTest("testRadioPropertyIndexedMapProperty", "");
138     }
139     public void testRadioPropertyIndexedEnumeration() throws Exception JavaDoc {
140         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Test Message");
141         pageContext.setAttribute("lst", st, PageContext.REQUEST_SCOPE);
142         runMyTest("testRadioPropertyIndexedEnumeration", "");
143     }
144     public void testRadioPropertyIndexedEnumerationProperty() throws Exception JavaDoc {
145         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
146         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Test Message");
147         sbft.setEnumeration(st);
148         pageContext.setAttribute("lst", sbft, PageContext.REQUEST_SCOPE);
149         runMyTest("testRadioPropertyIndexedEnumerationProperty", "");
150     }
151
152 }
153
Popular Tags