KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > taglib > bean > TestMessageTag1_fr


1 /*
2  * $Id: TestMessageTag1_fr.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.bean;
19
20 import java.util.Locale JavaDoc;
21
22 import javax.servlet.jsp.PageContext JavaDoc;
23
24 import junit.framework.Test;
25 import junit.framework.TestSuite;
26
27 import org.apache.cactus.WebResponse;
28 import org.apache.struts.Globals;
29 import org.apache.struts.taglib.SimpleBeanForTesting;
30 import org.apache.struts.taglib.TaglibTestBase;
31
32 /**
33   * These tests attempt to cover every single possible configuration of the
34   * org.apache.struts.taglib.bean.MessageTag
35   *
36   * I've tried to describe what I'm testing as best as possible by the method names.
37   * To see how I'm testing, refer to the jsp file that these tests forward to.
38   *
39   * All of these tests depend on a value being correctly written on the repose, then
40   * checked here in endXXX method.
41   *
42   */

43 public class TestMessageTag1_fr extends TaglibTestBase {
44
45     protected final static String JavaDoc TEST_KEY = "BeanKey";
46     protected final static String JavaDoc TEST_VAL_FR = "Message D'Essai 1";
47
48     public TestMessageTag1_fr(String JavaDoc theName) {
49         super(theName);
50     }
51
52     /**
53      * Start the tests.
54      *
55      * @param theArgs the arguments. Not used
56      */

57     public static void main(String JavaDoc[] theArgs) {
58         junit.awtui.TestRunner.main(new String JavaDoc[] {TestMessageTag1_fr.class.getName()});
59     }
60
61     /**
62      * @return a test suite (<code>TestSuite</code>) that includes all methods
63      * starting with "test"
64      */

65     public static Test suite() {
66         // All methods starting with "test" will be executed in the test suite.
67
return new TestSuite(TestMessageTag1_fr.class);
68     }
69     private void runMyTest(String JavaDoc whichTest, Locale JavaDoc locale) throws Exception JavaDoc {
70         pageContext.setAttribute(Globals.LOCALE_KEY, locale, PageContext.SESSION_SCOPE);
71         request.setAttribute("runTest", whichTest);
72         pageContext.forward("/test/org/apache/struts/taglib/bean/TestMessageTag1.jsp");
73     }
74
75         private void formatAndTest(String JavaDoc compare, String JavaDoc output) {
76                 //fix for introduced carriage return / line feeds
77
output = replace(output,"\r","");
78                 output = replace(output,"\n","");
79                 output = output.trim();
80                 //System.out.println("Testing [" + compare + "] == [" + output + "]");
81
assertEquals(compare, output);
82         }
83
84     /*
85      * ===========================================================
86      * Testing MessageTag (these comments serve as a divider of
87      * functionality being tested)
88      *
89      * Section: 1 Arg
90      * Locale: (default)
91      * ===========================================================
92      */

93
94
95     public void testMessageTag1ArgKeyNoScopeDefaultBundle_fr() throws Exception JavaDoc {
96      runMyTest("testMessageTag1ArgKeyNoScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
97         }
98         public void endMessageTag1ArgKeyNoScopeDefaultBundle(WebResponse response){
99                 formatAndTest(TEST_VAL_FR, response.getText());
100         }
101
102     public void testMessageTag1ArgKeyApplicationScopeDefaultBundle_fr() throws Exception JavaDoc {
103      runMyTest("testMessageTag1ArgKeyApplicationScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
104         }
105         public void endMessageTag1ArgKeyApplicationScopeDefaultBundle(WebResponse response){
106                 formatAndTest(TEST_VAL_FR, response.getText());
107         }
108
109     public void testMessageTag1ArgKeySessionScopeDefaultBundle_fr() throws Exception JavaDoc {
110      runMyTest("testMessageTag1ArgKeySessionScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
111         }
112         public void endMessageTag1ArgKeySessionScopeDefaultBundle(WebResponse response){
113                 formatAndTest(TEST_VAL_FR, response.getText());
114         }
115
116     public void testMessageTag1ArgKeyRequestScopeDefaultBundle_fr() throws Exception JavaDoc {
117      runMyTest("testMessageTag1ArgKeyRequestScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
118         }
119         public void endMessageTag1ArgKeyRequestScopeDefaultBundle(WebResponse response){
120                 formatAndTest(TEST_VAL_FR, response.getText());
121         }
122
123
124     public void testMessageTag1ArgKeyNoScopeAlternateBundle_fr() throws Exception JavaDoc {
125      runMyTest("testMessageTag1ArgKeyNoScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
126         }
127         public void endMessageTag1ArgKeyNoScopeAlternateBundle(WebResponse response){
128                 formatAndTest(TEST_VAL_FR, response.getText());
129         }
130
131     public void testMessageTag1ArgKeyApplicationScopeAlternateBundle_fr() throws Exception JavaDoc {
132      runMyTest("testMessageTag1ArgKeyApplicationScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
133         }
134         public void endMessageTag1ArgKeyApplicationScopeAlternateBundle(WebResponse response){
135                 formatAndTest(TEST_VAL_FR, response.getText());
136         }
137
138     public void testMessageTag1ArgKeySessionScopeAlternateBundle_fr() throws Exception JavaDoc {
139      runMyTest("testMessageTag1ArgKeySessionScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
140         }
141         public void endMessageTag1ArgKeySessionScopeAlternateBundle(WebResponse response){
142                 formatAndTest(TEST_VAL_FR, response.getText());
143         }
144
145     public void testMessageTag1ArgKeyRequestScopeAlternateBundle_fr() throws Exception JavaDoc {
146      runMyTest("testMessageTag1ArgKeyRequestScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
147         }
148         public void endMessageTag1ArgKeyRequestScopeAlternateBundle(WebResponse response){
149                 formatAndTest(TEST_VAL_FR, response.getText());
150         }
151
152
153
154     public void testMessageTag1ArgNameNoScopeDefaultBundle_fr() throws Exception JavaDoc {
155      runMyTest("testMessageTag1ArgNameNoScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
156         }
157         public void endMessageTag1ArgNameNoScopeDefaultBundle(WebResponse response){
158                 formatAndTest(TEST_VAL_FR, response.getText());
159         }
160
161     public void testMessageTag1ArgNameApplicationScopeDefaultBundle_fr() throws Exception JavaDoc {
162      runMyTest("testMessageTag1ArgNameApplicationScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
163         }
164         public void endMessageTag1ArgNameApplicationScopeDefaultBundle(WebResponse response){
165                 formatAndTest(TEST_VAL_FR, response.getText());
166         }
167
168     public void testMessageTag1ArgNameSessionScopeDefaultBundle_fr() throws Exception JavaDoc {
169      runMyTest("testMessageTag1ArgNameSessionScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
170         }
171         public void endMessageTag1ArgNameSessionScopeDefaultBundle(WebResponse response){
172                 formatAndTest(TEST_VAL_FR, response.getText());
173         }
174
175     public void testMessageTag1ArgNameRequestScopeDefaultBundle_fr() throws Exception JavaDoc {
176      runMyTest("testMessageTag1ArgNameRequestScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
177         }
178         public void endMessageTag1ArgNameRequestScopeDefaultBundle(WebResponse response){
179                 formatAndTest(TEST_VAL_FR, response.getText());
180         }
181
182
183     public void testMessageTag1ArgNameNoScopeAlternateBundle_fr() throws Exception JavaDoc {
184      runMyTest("testMessageTag1ArgNameNoScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
185         }
186         public void endMessageTag1ArgNameNoScopeAlternateBundle(WebResponse response){
187                 formatAndTest(TEST_VAL_FR, response.getText());
188         }
189
190     public void testMessageTag1ArgNameApplicationScopeAlternateBundle_fr() throws Exception JavaDoc {
191      runMyTest("testMessageTag1ArgNameApplicationScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
192         }
193         public void endMessageTag1ArgNameApplicationScopeAlternateBundle(WebResponse response){
194                 formatAndTest(TEST_VAL_FR, response.getText());
195         }
196
197     public void testMessageTag1ArgNameSessionScopeAlternateBundle_fr() throws Exception JavaDoc {
198      runMyTest("testMessageTag1ArgNameSessionScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
199         }
200         public void endMessageTag1ArgNameSessionScopeAlternateBundle(WebResponse response){
201                 formatAndTest(TEST_VAL_FR, response.getText());
202         }
203
204     public void testMessageTag1ArgNameRequestScopeAlternateBundle_fr() throws Exception JavaDoc {
205      runMyTest("testMessageTag1ArgNameRequestScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
206         }
207         public void endMessageTag1ArgNameRequestScopeAlternateBundle(WebResponse response){
208                 formatAndTest(TEST_VAL_FR, response.getText());
209         }
210
211
212
213
214     public void testMessageTag1ArgNamePropertyNoScopeDefaultBundle_fr() throws Exception JavaDoc {
215         pageContext.setAttribute("key", new SimpleBeanForTesting("default.bundle.message.1"), PageContext.REQUEST_SCOPE);
216      runMyTest("testMessageTag1ArgNamePropertyNoScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
217         }
218         public void endMessageTag1ArgNamePropertyNoScopeDefaultBundle(WebResponse response){
219                 formatAndTest(TEST_VAL_FR, response.getText());
220         }
221
222     public void testMessageTag1ArgNamePropertyApplicationScopeDefaultBundle_fr() throws Exception JavaDoc {
223         pageContext.setAttribute("key", new SimpleBeanForTesting("default.bundle.message.1"), PageContext.APPLICATION_SCOPE);
224      runMyTest("testMessageTag1ArgNamePropertyApplicationScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
225         }
226         public void endMessageTag1ArgNamePropertyApplicationScopeDefaultBundle(WebResponse response){
227                 formatAndTest(TEST_VAL_FR, response.getText());
228         }
229
230     public void testMessageTag1ArgNamePropertySessionScopeDefaultBundle_fr() throws Exception JavaDoc {
231         pageContext.setAttribute("key", new SimpleBeanForTesting("default.bundle.message.1"), PageContext.SESSION_SCOPE);
232      runMyTest("testMessageTag1ArgNamePropertySessionScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
233         }
234         public void endMessageTag1ArgNamePropertySessionScopeDefaultBundle(WebResponse response){
235                 formatAndTest(TEST_VAL_FR, response.getText());
236         }
237
238     public void testMessageTag1ArgNamePropertyRequestScopeDefaultBundle_fr() throws Exception JavaDoc {
239         pageContext.setAttribute("key", new SimpleBeanForTesting("default.bundle.message.1"), PageContext.REQUEST_SCOPE);
240      runMyTest("testMessageTag1ArgNamePropertyRequestScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
241         }
242         public void endMessageTag1ArgNamePropertyRequestScopeDefaultBundle(WebResponse response){
243                 formatAndTest(TEST_VAL_FR, response.getText());
244         }
245
246
247     public void testMessageTag1ArgNamePropertyNoScopeAlternateBundle_fr() throws Exception JavaDoc {
248         pageContext.setAttribute("key", new SimpleBeanForTesting("alternate.bundle.message.1"), PageContext.REQUEST_SCOPE);
249      runMyTest("testMessageTag1ArgNamePropertyNoScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
250         }
251         public void endMessageTag1ArgNamePropertyNoScopeAlternateBundle(WebResponse response){
252                 formatAndTest(TEST_VAL_FR, response.getText());
253         }
254
255     public void testMessageTag1ArgNamePropertyApplicationScopeAlternateBundle_fr() throws Exception JavaDoc {
256         pageContext.setAttribute("key", new SimpleBeanForTesting("alternate.bundle.message.1"), PageContext.APPLICATION_SCOPE);
257      runMyTest("testMessageTag1ArgNamePropertyApplicationScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
258         }
259         public void endMessageTag1ArgNamePropertyApplicationScopeAlternateBundle(WebResponse response){
260                 formatAndTest(TEST_VAL_FR, response.getText());
261         }
262
263     public void testMessageTag1ArgNamePropertySessionScopeAlternateBundle_fr() throws Exception JavaDoc {
264         pageContext.setAttribute("key", new SimpleBeanForTesting("alternate.bundle.message.1"), PageContext.SESSION_SCOPE);
265      runMyTest("testMessageTag1ArgNamePropertySessionScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
266         }
267         public void endMessageTag1ArgNamePropertySessionScopeAlternateBundle(WebResponse response){
268                 formatAndTest(TEST_VAL_FR, response.getText());
269         }
270
271     public void testMessageTag1ArgNamePropertyRequestScopeAlternateBundle_fr() throws Exception JavaDoc {
272         pageContext.setAttribute("key", new SimpleBeanForTesting("alternate.bundle.message.1"), PageContext.REQUEST_SCOPE);
273      runMyTest("testMessageTag1ArgNamePropertyRequestScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
274         }
275         public void endMessageTag1ArgNamePropertyRequestScopeAlternateBundle(WebResponse response){
276                 formatAndTest(TEST_VAL_FR, response.getText());
277         }
278
279
280 }
281
Popular Tags