~ubuntu-branches/ubuntu/lucid/libstruts1.2-java/lucid

« back to all changes in this revision

Viewing changes to web/test/test/org/apache/struts/taglib/html/TestErrorsTag4.jsp

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2006-04-24 12:14:23 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060424121423-naev53qigqgks0sa
Tags: 1.2.9-1
New upstream  release Fixes  three security  problems: CVE-2006-1546,
CVE-2006-1547,  CVE-2006-1548  (closes:  #360551),  thanks  to  Moritz
Muehlenhoff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
 
2
<%@page import="junit.framework.Assert"%>
 
3
<%@page import="org.apache.struts.Globals"%>
 
4
<%@page import="org.apache.struts.action.ActionError"%>
 
5
<%@page import="org.apache.struts.action.ActionErrors"%>
 
6
 
 
7
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
 
8
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
 
9
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
 
10
 
 
11
 
 
12
 
 
13
 
 
14
 
 
15
 
 
16
<!-- Name -->
 
17
 
 
18
<logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsNameProperty">
 
19
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
20
                My Errors go here:<html:errors name="MY_ERRORS_KEY" property="someProperty"/>
 
21
        </bean:define>
 
22
        <bean:define id="TEST_RESULTS" toScope="page">
 
23
                My Errors go here:
 
24
        </bean:define>
 
25
</logic:equal>
 
26
 
 
27
<logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsNameProperty">
 
28
<%
 
29
//This should be done in your action.  I do it here to keep the tests simple.
 
30
        ActionErrors errors = new ActionErrors();
 
31
    errors.add("someProperty",
 
32
         new ActionError("default.testing.errors.tag"));
 
33
    errors.add("someProperty",
 
34
         new ActionError("default.testing.errors.tag2"));
 
35
    request.setAttribute("MY_ERRORS_KEY", errors);
 
36
%>
 
37
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
38
                My Errors go here:<html:errors name="MY_ERRORS_KEY" property="someProperty"/>
 
39
        </bean:define>
 
40
        <bean:define id="TEST_RESULTS" toScope="page">
 
41
                My Errors go here:<default_errors_header><default_errors_prefix>My Errors Text<default_errors_suffix><default_errors_prefix>My Errors Text 2<default_errors_suffix><default_errors_footer>
 
42
        </bean:define>
 
43
</logic:equal>
 
44
 
 
45
<logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsNameProperty">
 
46
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
47
                My Errors go here:<html:errors name="MY_ERRORS_KEY" property="someProperty"/>
 
48
        </bean:define>
 
49
        <bean:define id="TEST_RESULTS" toScope="page">
 
50
                My Errors go here:
 
51
        </bean:define>
 
52
</logic:equal>
 
53
 
 
54
<logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsNameProperty">
 
55
<%
 
56
//This should be done in your action.  I do it here to keep the tests simple.
 
57
        ActionErrors errors = new ActionErrors();
 
58
    errors.add("someProperty",
 
59
         new ActionError("alternate.testing.errors.tag"));
 
60
    errors.add("someProperty",
 
61
         new ActionError("alternate.testing.errors.tag2"));
 
62
    request.setAttribute("MY_ERRORS_KEY", errors);
 
63
%>
 
64
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
65
                My Errors go here:<html:errors bundle="alternate" name="MY_ERRORS_KEY" property="someProperty"/>
 
66
        </bean:define>
 
67
        <bean:define id="TEST_RESULTS" toScope="page">
 
68
                My Errors go here:<alternate_errors_header><alternate_errors_prefix>My Alternate Errors Text<alternate_errors_suffix><alternate_errors_prefix>My Alternate Errors Text 2<alternate_errors_suffix><alternate_errors_footer>
 
69
        </bean:define>
 
70
</logic:equal>
 
71
 
 
72
<logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsNameProperty_fr">
 
73
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
74
                My Errors go here:<html:errors name="MY_ERRORS_KEY" property="someProperty"/>
 
75
        </bean:define>
 
76
        <bean:define id="TEST_RESULTS" toScope="page">
 
77
                My Errors go here:
 
78
        </bean:define>
 
79
</logic:equal>
 
80
 
 
81
<logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsNameProperty_fr">
 
82
<%
 
83
//This should be done in your action.  I do it here to keep the tests simple.
 
84
        ActionErrors errors = new ActionErrors();
 
85
    errors.add("someProperty",
 
86
         new ActionError("default.testing.errors.tag"));
 
87
    errors.add("someProperty",
 
88
         new ActionError("default.testing.errors.tag2"));
 
89
    request.setAttribute("MY_ERRORS_KEY", errors);
 
90
%>
 
91
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
92
                My Errors go here:<html:errors name="MY_ERRORS_KEY" property="someProperty"/>
 
93
        </bean:define>
 
94
        <bean:define id="TEST_RESULTS" toScope="page">
 
95
                My Errors go here:<default_errors_header_fr><default_errors_prefix_fr>My Errors Text (fr)<default_errors_suffix_fr><default_errors_prefix_fr>My Errors Text 2 (fr)<default_errors_suffix_fr><default_errors_footer_fr>
 
96
        </bean:define>
 
97
</logic:equal>
 
98
 
 
99
 
 
100
<logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsNameProperty_fr">
 
101
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
102
                My Errors go here:<html:errors name="MY_ERRORS_KEY" property="someProperty"/>
 
103
        </bean:define>
 
104
        <bean:define id="TEST_RESULTS" toScope="page">
 
105
                My Errors go here:
 
106
        </bean:define>
 
107
</logic:equal>
 
108
 
 
109
<logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsNameProperty_fr">
 
110
<%
 
111
//This should be done in your action.  I do it here to keep the tests simple.
 
112
        ActionErrors errors = new ActionErrors();
 
113
    errors.add("someProperty",
 
114
         new ActionError("alternate.testing.errors.tag"));
 
115
    errors.add("someProperty",
 
116
         new ActionError("alternate.testing.errors.tag2"));
 
117
    request.setAttribute("MY_ERRORS_KEY", errors);
 
118
%>
 
119
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
120
                My Errors go here:<html:errors bundle="alternate" name="MY_ERRORS_KEY" property="someProperty"/>
 
121
        </bean:define>
 
122
        <bean:define id="TEST_RESULTS" toScope="page">
 
123
                My Errors go here:<alternate_errors_header_fr><alternate_errors_prefix_fr>My Alternate Errors Text (fr)<alternate_errors_suffix_fr><alternate_errors_prefix_fr>My Alternate Errors Text 2 (fr)<alternate_errors_suffix_fr><alternate_errors_footer_fr>
 
124
        </bean:define>
 
125
</logic:equal>
 
126
 
 
127
 
 
128
 
 
129
 
 
130
 
 
131
 
 
132
 
 
133
 
 
134
 
 
135
 
 
136
 
 
137
<logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsLocaleNameProperty">
 
138
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
139
                My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY" property="someProperty"/>
 
140
        </bean:define>
 
141
        <bean:define id="TEST_RESULTS" toScope="page">
 
142
                My Errors go here:
 
143
        </bean:define>
 
144
</logic:equal>
 
145
 
 
146
<logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsLocaleNameProperty">
 
147
<%
 
148
//This should be done in your action.  I do it here to keep the tests simple.
 
149
        ActionErrors errors = new ActionErrors();
 
150
    errors.add("someProperty",
 
151
         new ActionError("default.testing.errors.tag"));
 
152
    errors.add("someProperty",
 
153
         new ActionError("default.testing.errors.tag2"));
 
154
    request.setAttribute("MY_ERRORS_KEY", errors);
 
155
%>
 
156
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
157
                My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY" property="someProperty"/>
 
158
        </bean:define>
 
159
        <bean:define id="TEST_RESULTS" toScope="page">
 
160
                My Errors go here:<default_errors_header_fr><default_errors_prefix_fr>My Errors Text (fr)<default_errors_suffix_fr><default_errors_prefix_fr>My Errors Text 2 (fr)<default_errors_suffix_fr><default_errors_footer_fr>
 
161
        </bean:define>
 
162
</logic:equal>
 
163
 
 
164
<logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsLocaleNameProperty">
 
165
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
166
                My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY" property="someProperty"/>
 
167
        </bean:define>
 
168
        <bean:define id="TEST_RESULTS" toScope="page">
 
169
                My Errors go here:
 
170
        </bean:define>
 
171
</logic:equal>
 
172
 
 
173
<logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsLocaleNameProperty">
 
174
<%
 
175
//This should be done in your action.  I do it here to keep the tests simple.
 
176
        ActionErrors errors = new ActionErrors();
 
177
    errors.add("someProperty",
 
178
         new ActionError("alternate.testing.errors.tag"));
 
179
    errors.add("someProperty",
 
180
         new ActionError("alternate.testing.errors.tag2"));
 
181
    request.setAttribute("MY_ERRORS_KEY", errors);
 
182
%>
 
183
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
184
                My Errors go here:<html:errors locale="MY_LOCALE_KEY" bundle="alternate" name="MY_ERRORS_KEY" property="someProperty"/>
 
185
        </bean:define>
 
186
        <bean:define id="TEST_RESULTS" toScope="page">
 
187
                My Errors go here:<alternate_errors_header_fr><alternate_errors_prefix_fr>My Alternate Errors Text (fr)<alternate_errors_suffix_fr><alternate_errors_prefix_fr>My Alternate Errors Text 2 (fr)<alternate_errors_suffix_fr><alternate_errors_footer_fr>
 
188
        </bean:define>
 
189
</logic:equal>
 
190
 
 
191
<logic:equal name="runTest" value="testErrorsDefaultBundle0ErrorsLocaleNameProperty_fr">
 
192
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
193
                My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY" property="someProperty"/>
 
194
        </bean:define>
 
195
        <bean:define id="TEST_RESULTS" toScope="page">
 
196
                My Errors go here:
 
197
        </bean:define>
 
198
</logic:equal>
 
199
 
 
200
<logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsLocaleNameProperty_fr">
 
201
<%
 
202
//This should be done in your action.  I do it here to keep the tests simple.
 
203
        ActionErrors errors = new ActionErrors();
 
204
    errors.add("someProperty",
 
205
         new ActionError("default.testing.errors.tag"));
 
206
    errors.add("someProperty",
 
207
         new ActionError("default.testing.errors.tag2"));
 
208
    request.setAttribute("MY_ERRORS_KEY", errors);
 
209
%>
 
210
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
211
                My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY" property="someProperty"/>
 
212
        </bean:define>
 
213
        <bean:define id="TEST_RESULTS" toScope="page">
 
214
                My Errors go here:<default_errors_header_fr><default_errors_prefix_fr>My Errors Text (fr)<default_errors_suffix_fr><default_errors_prefix_fr>My Errors Text 2 (fr)<default_errors_suffix_fr><default_errors_footer_fr>
 
215
        </bean:define>
 
216
</logic:equal>
 
217
 
 
218
 
 
219
<logic:equal name="runTest" value="testErrorsAlternateBundle0ErrorsLocaleNameProperty_fr">
 
220
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
221
                My Errors go here:<html:errors locale="MY_LOCALE_KEY" name="MY_ERRORS_KEY" property="someProperty"/>
 
222
        </bean:define>
 
223
        <bean:define id="TEST_RESULTS" toScope="page">
 
224
                My Errors go here:
 
225
        </bean:define>
 
226
</logic:equal>
 
227
 
 
228
<logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsLocaleNameProperty_fr">
 
229
<%
 
230
//This should be done in your action.  I do it here to keep the tests simple.
 
231
        ActionErrors errors = new ActionErrors();
 
232
    errors.add("someProperty",
 
233
         new ActionError("alternate.testing.errors.tag"));
 
234
    errors.add("someProperty",
 
235
         new ActionError("alternate.testing.errors.tag2"));
 
236
    request.setAttribute("MY_ERRORS_KEY", errors);
 
237
%>
 
238
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
239
                My Errors go here:<html:errors locale="MY_LOCALE_KEY" bundle="alternate" name="MY_ERRORS_KEY" property="someProperty"/>
 
240
        </bean:define>
 
241
        <bean:define id="TEST_RESULTS" toScope="page">
 
242
                My Errors go here:<alternate_errors_header_fr><alternate_errors_prefix_fr>My Alternate Errors Text (fr)<alternate_errors_suffix_fr><alternate_errors_prefix_fr>My Alternate Errors Text 2 (fr)<alternate_errors_suffix_fr><alternate_errors_footer_fr>
 
243
        </bean:define>
 
244
</logic:equal>
 
245
 
 
246
 
 
247
 
 
248
<logic:equal name="runTest" value="testErrorsCustomResources">
 
249
<%
 
250
//This should be done in your action.  I do it here to keep the tests simple.
 
251
        ActionErrors errors = new ActionErrors();
 
252
    errors.add(ActionErrors.GLOBAL_ERROR,
 
253
         new ActionError("default.testing.errors.tag"));
 
254
    errors.add(ActionErrors.GLOBAL_ERROR,
 
255
         new ActionError("default.testing.errors.tag2"));
 
256
    request.setAttribute(Globals.ERROR_KEY, errors);
 
257
%>
 
258
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
259
                My Errors go here:<html:errors header="custom.errors.header" footer="custom.errors.footer" prefix="custom.errors.prefix" suffix="custom.errors.suffix"/>
 
260
        </bean:define>
 
261
        <bean:define id="TEST_RESULTS" toScope="page">
 
262
                My Errors go here:custom_error_header<custom_error_prefix>My Errors Text<custom_error_suffix><custom_error_prefix>My Errors Text 2<custom_error_suffix>custom_error_footer
 
263
        </bean:define>
 
264
</logic:equal>
 
265
 
 
266
<logic:equal name="runTest" value="testErrorsCustomResourcesAltBundle">
 
267
<%
 
268
//This should be done in your action.  I do it here to keep the tests simple.
 
269
        ActionErrors errors = new ActionErrors();
 
270
    errors.add(ActionErrors.GLOBAL_ERROR,
 
271
         new ActionError("alternate.testing.errors.tag"));
 
272
    errors.add(ActionErrors.GLOBAL_ERROR,
 
273
         new ActionError("alternate.testing.errors.tag2"));
 
274
    request.setAttribute(Globals.ERROR_KEY, errors);
 
275
%>
 
276
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
277
                My Errors go here:<html:errors bundle="alternate" header="custom.alternate.errors.header" footer="custom.alternate.errors.footer" prefix="custom.alternate.errors.prefix" suffix="custom.alternate.errors.suffix"/>
 
278
        </bean:define>
 
279
        <bean:define id="TEST_RESULTS" toScope="page">
 
280
                My Errors go here:custom_alternate_error_header<custom_alternate_error_prefix>My Alternate Errors Text<custom_alternate_error_suffix><custom_alternate_error_prefix>My Alternate Errors Text 2<custom_alternate_error_suffix>custom_alternate_error_footer
 
281
        </bean:define>
 
282
</logic:equal>
 
283
 
 
284
 
 
285
 
 
286
<% 
 
287
String expected = "";
 
288
String compareTo = "";
 
289
 
 
290
if (pageContext.getAttribute("EXPECTED_RESULTS") == null){
 
291
    throw new javax.servlet.jsp.JspException("No tests on this page were called.  Please verify that you've setup the tests correctly.");
 
292
}else{
 
293
        expected=pageContext.getAttribute("TEST_RESULTS").toString();
 
294
}
 
295
if (pageContext.getAttribute("TEST_RESULTS") != null){
 
296
        compareTo=pageContext.getAttribute("EXPECTED_RESULTS").toString();
 
297
}
 
298
 
 
299
Assert.assertEquals(expected, compareTo);
 
300
%>