KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: TestMessageTag_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 response, then
40   * checked here in endXXX method.
41   *
42   */

43 public class TestMessageTag_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";
47
48     public TestMessageTag_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[] {TestMessageTag_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(TestMessageTag_fr.class);
68     }
69
70     private void runMyTest(String JavaDoc whichTest, Locale JavaDoc locale) throws Exception JavaDoc {
71         pageContext.setAttribute(Globals.LOCALE_KEY, locale, PageContext.SESSION_SCOPE);
72         request.setAttribute("runTest", whichTest);
73         pageContext.forward("/test/org/apache/struts/taglib/bean/TestMessageTag.jsp");
74     }
75
76         private void formatAndTest(String JavaDoc compare, String JavaDoc output) {
77                 //fix for introduced carriage return / line feeds
78
output = replace(output,"\r","");
79                 output = replace(output,"\n","");
80                 output = output.trim();
81                 //System.out.println("Testing [" + compare + "] == [" + output + "]");
82
assertEquals(compare, output);
83         }
84
85     /*
86      * ===========================================================
87      * Testing MessageTag (these comments serve as a divider of
88      * functionality being tested)
89      *
90      * Section: NoArg
91      * Locale: (default)
92      * ===========================================================
93      */

94     public void testMessageTagNoArgKeyNoScopeDefaultBundle_fr() throws Exception JavaDoc {
95      runMyTest("testMessageTagNoArgKeyNoScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
96         }
97         public void endMessageTagNoArgKeyNoScopeDefaultBundle(WebResponse response){
98                 formatAndTest(TEST_VAL_FR, response.getText());
99         }
100
101     public void testMessageTagNoArgKeyApplicationScopeDefaultBundle_fr() throws Exception JavaDoc {
102      runMyTest("testMessageTagNoArgKeyApplicationScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
103         }
104         public void endMessageTagNoArgKeyApplicationScopeDefaultBundle(WebResponse response){
105                 formatAndTest(TEST_VAL_FR, response.getText());
106         }
107
108     public void testMessageTagNoArgKeySessionScopeDefaultBundle_fr() throws Exception JavaDoc {
109      runMyTest("testMessageTagNoArgKeySessionScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
110         }
111         public void endMessageTagNoArgKeySessionScopeDefaultBundle(WebResponse response){
112                 formatAndTest(TEST_VAL_FR, response.getText());
113         }
114
115     public void testMessageTagNoArgKeyRequestScopeDefaultBundle_fr() throws Exception JavaDoc {
116      runMyTest("testMessageTagNoArgKeyRequestScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
117         }
118         public void endMessageTagNoArgKeyRequestScopeDefaultBundle(WebResponse response){
119                 formatAndTest(TEST_VAL_FR, response.getText());
120         }
121
122
123     public void testMessageTagNoArgKeyNoScopeAlternateBundle_fr() throws Exception JavaDoc {
124      runMyTest("testMessageTagNoArgKeyNoScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
125         }
126         public void endMessageTagNoArgKeyNoScopeAlternateBundle(WebResponse response){
127                 formatAndTest(TEST_VAL_FR, response.getText());
128         }
129
130     public void testMessageTagNoArgKeyApplicationScopeAlternateBundle_fr() throws Exception JavaDoc {
131      runMyTest("testMessageTagNoArgKeyApplicationScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
132         }
133         public void endMessageTagNoArgKeyApplicationScopeAlternateBundle(WebResponse response){
134                 formatAndTest(TEST_VAL_FR, response.getText());
135         }
136
137     public void testMessageTagNoArgKeySessionScopeAlternateBundle_fr() throws Exception JavaDoc {
138      runMyTest("testMessageTagNoArgKeySessionScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
139         }
140         public void endMessageTagNoArgKeySessionScopeAlternateBundle(WebResponse response){
141                 formatAndTest(TEST_VAL_FR, response.getText());
142         }
143
144     public void testMessageTagNoArgKeyRequestScopeAlternateBundle_fr() throws Exception JavaDoc {
145      runMyTest("testMessageTagNoArgKeyRequestScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
146         }
147         public void endMessageTagNoArgKeyRequestScopeAlternateBundle(WebResponse response){
148                 formatAndTest(TEST_VAL_FR, response.getText());
149         }
150
151
152
153     public void testMessageTagNoArgNameNoScopeDefaultBundle_fr() throws Exception JavaDoc {
154      runMyTest("testMessageTagNoArgNameNoScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
155         }
156         public void endMessageTagNoArgNameNoScopeDefaultBundle(WebResponse response){
157                 formatAndTest(TEST_VAL_FR, response.getText());
158         }
159
160     public void testMessageTagNoArgNameApplicationScopeDefaultBundle_fr() throws Exception JavaDoc {
161      runMyTest("testMessageTagNoArgNameApplicationScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
162         }
163         public void endMessageTagNoArgNameApplicationScopeDefaultBundle(WebResponse response){
164                 formatAndTest(TEST_VAL_FR, response.getText());
165         }
166
167     public void testMessageTagNoArgNameSessionScopeDefaultBundle_fr() throws Exception JavaDoc {
168      runMyTest("testMessageTagNoArgNameSessionScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
169         }
170         public void endMessageTagNoArgNameSessionScopeDefaultBundle(WebResponse response){
171                 formatAndTest(TEST_VAL_FR, response.getText());
172         }
173
174     public void testMessageTagNoArgNameRequestScopeDefaultBundle_fr() throws Exception JavaDoc {
175      runMyTest("testMessageTagNoArgNameRequestScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
176         }
177         public void endMessageTagNoArgNameRequestScopeDefaultBundle(WebResponse response){
178                 formatAndTest(TEST_VAL_FR, response.getText());
179         }
180
181
182     public void testMessageTagNoArgNameNoScopeAlternateBundle_fr() throws Exception JavaDoc {
183      runMyTest("testMessageTagNoArgNameNoScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
184         }
185         public void endMessageTagNoArgNameNoScopeAlternateBundle(WebResponse response){
186                 formatAndTest(TEST_VAL_FR, response.getText());
187         }
188
189     public void testMessageTagNoArgNameApplicationScopeAlternateBundle_fr() throws Exception JavaDoc {
190      runMyTest("testMessageTagNoArgNameApplicationScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
191         }
192         public void endMessageTagNoArgNameApplicationScopeAlternateBundle(WebResponse response){
193                 formatAndTest(TEST_VAL_FR, response.getText());
194         }
195
196     public void testMessageTagNoArgNameSessionScopeAlternateBundle_fr() throws Exception JavaDoc {
197      runMyTest("testMessageTagNoArgNameSessionScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
198         }
199         public void endMessageTagNoArgNameSessionScopeAlternateBundle(WebResponse response){
200                 formatAndTest(TEST_VAL_FR, response.getText());
201         }
202
203     public void testMessageTagNoArgNameRequestScopeAlternateBundle_fr() throws Exception JavaDoc {
204      runMyTest("testMessageTagNoArgNameRequestScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
205         }
206         public void endMessageTagNoArgNameRequestScopeAlternateBundle(WebResponse response){
207                 formatAndTest(TEST_VAL_FR, response.getText());
208         }
209
210
211
212
213     public void testMessageTagNoArgNamePropertyNoScopeDefaultBundle_fr() throws Exception JavaDoc {
214         pageContext.setAttribute("key", new SimpleBeanForTesting("default.bundle.message"), PageContext.REQUEST_SCOPE);
215      runMyTest("testMessageTagNoArgNamePropertyNoScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
216         }
217         public void endMessageTagNoArgNamePropertyNoScopeDefaultBundle(WebResponse response){
218                 formatAndTest(TEST_VAL_FR, response.getText());
219         }
220
221     public void testMessageTagNoArgNamePropertyApplicationScopeDefaultBundle_fr() throws Exception JavaDoc {
222         pageContext.setAttribute("key", new SimpleBeanForTesting("default.bundle.message"), PageContext.APPLICATION_SCOPE);
223      runMyTest("testMessageTagNoArgNamePropertyApplicationScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
224         }
225         public void endMessageTagNoArgNamePropertyApplicationScopeDefaultBundle(WebResponse response){
226                 formatAndTest(TEST_VAL_FR, response.getText());
227         }
228
229     public void testMessageTagNoArgNamePropertySessionScopeDefaultBundle_fr() throws Exception JavaDoc {
230         pageContext.setAttribute("key", new SimpleBeanForTesting("default.bundle.message"), PageContext.SESSION_SCOPE);
231      runMyTest("testMessageTagNoArgNamePropertySessionScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
232         }
233         public void endMessageTagNoArgNamePropertySessionScopeDefaultBundle(WebResponse response){
234                 formatAndTest(TEST_VAL_FR, response.getText());
235         }
236
237     public void testMessageTagNoArgNamePropertyRequestScopeDefaultBundle_fr() throws Exception JavaDoc {
238         pageContext.setAttribute("key", new SimpleBeanForTesting("default.bundle.message"), PageContext.REQUEST_SCOPE);
239      runMyTest("testMessageTagNoArgNamePropertyRequestScopeDefaultBundle", new Locale JavaDoc("fr","fr"));
240         }
241         public void endMessageTagNoArgNamePropertyRequestScopeDefaultBundle(WebResponse response){
242                 formatAndTest(TEST_VAL_FR, response.getText());
243         }
244
245
246     public void testMessageTagNoArgNamePropertyNoScopeAlternateBundle_fr() throws Exception JavaDoc {
247         pageContext.setAttribute("key", new SimpleBeanForTesting("alternate.bundle.message"), PageContext.REQUEST_SCOPE);
248      runMyTest("testMessageTagNoArgNamePropertyNoScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
249         }
250         public void endMessageTagNoArgNamePropertyNoScopeAlternateBundle(WebResponse response){
251                 formatAndTest(TEST_VAL_FR, response.getText());
252         }
253
254     public void testMessageTagNoArgNamePropertyApplicationScopeAlternateBundle_fr() throws Exception JavaDoc {
255         pageContext.setAttribute("key", new SimpleBeanForTesting("alternate.bundle.message"), PageContext.APPLICATION_SCOPE);
256      runMyTest("testMessageTagNoArgNamePropertyApplicationScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
257         }
258         public void endMessageTagNoArgNamePropertyApplicationScopeAlternateBundle(WebResponse response){
259                 formatAndTest(TEST_VAL_FR, response.getText());
260         }
261
262     public void testMessageTagNoArgNamePropertySessionScopeAlternateBundle_fr() throws Exception JavaDoc {
263         pageContext.setAttribute("key", new SimpleBeanForTesting("alternate.bundle.message"), PageContext.SESSION_SCOPE);
264      runMyTest("testMessageTagNoArgNamePropertySessionScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
265         }
266         public void endMessageTagNoArgNamePropertySessionScopeAlternateBundle(WebResponse response){
267                 formatAndTest(TEST_VAL_FR, response.getText());
268         }
269
270     public void testMessageTagNoArgNamePropertyRequestScopeAlternateBundle_fr() throws Exception JavaDoc {
271         pageContext.setAttribute("key", new SimpleBeanForTesting("alternate.bundle.message"), PageContext.REQUEST_SCOPE);
272      runMyTest("testMessageTagNoArgNamePropertyRequestScopeAlternateBundle", new Locale JavaDoc("fr","fr"));
273         }
274         public void endMessageTagNoArgNamePropertyRequestScopeAlternateBundle(WebResponse response){
275                 formatAndTest(TEST_VAL_FR, response.getText());
276         }
277
278
279
280
281
282
283
284
285 }
286
Popular Tags