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"%>
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" %>
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"/>
22
<bean:define id="TEST_RESULTS" toScope="page">
27
<logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsNameProperty">
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);
37
<bean:define id="EXPECTED_RESULTS" toScope="page">
38
My Errors go here:<html:errors name="MY_ERRORS_KEY" property="someProperty"/>
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>
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"/>
49
<bean:define id="TEST_RESULTS" toScope="page">
54
<logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsNameProperty">
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);
64
<bean:define id="EXPECTED_RESULTS" toScope="page">
65
My Errors go here:<html:errors bundle="alternate" name="MY_ERRORS_KEY" property="someProperty"/>
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>
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"/>
76
<bean:define id="TEST_RESULTS" toScope="page">
81
<logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsNameProperty_fr">
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);
91
<bean:define id="EXPECTED_RESULTS" toScope="page">
92
My Errors go here:<html:errors name="MY_ERRORS_KEY" property="someProperty"/>
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>
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"/>
104
<bean:define id="TEST_RESULTS" toScope="page">
109
<logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsNameProperty_fr">
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);
119
<bean:define id="EXPECTED_RESULTS" toScope="page">
120
My Errors go here:<html:errors bundle="alternate" name="MY_ERRORS_KEY" property="someProperty"/>
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>
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"/>
141
<bean:define id="TEST_RESULTS" toScope="page">
146
<logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsLocaleNameProperty">
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);
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"/>
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>
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"/>
168
<bean:define id="TEST_RESULTS" toScope="page">
173
<logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsLocaleNameProperty">
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);
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"/>
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>
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"/>
195
<bean:define id="TEST_RESULTS" toScope="page">
200
<logic:equal name="runTest" value="testErrorsDefaultBundle2ErrorsLocaleNameProperty_fr">
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);
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"/>
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>
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"/>
223
<bean:define id="TEST_RESULTS" toScope="page">
228
<logic:equal name="runTest" value="testErrorsAlternateBundle2ErrorsLocaleNameProperty_fr">
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);
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"/>
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>
248
<logic:equal name="runTest" value="testErrorsCustomResources">
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);
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"/>
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
266
<logic:equal name="runTest" value="testErrorsCustomResourcesAltBundle">
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);
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"/>
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
287
String expected = "";
288
String compareTo = "";
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.");
293
expected=pageContext.getAttribute("TEST_RESULTS").toString();
295
if (pageContext.getAttribute("TEST_RESULTS") != null){
296
compareTo=pageContext.getAttribute("EXPECTED_RESULTS").toString();
299
Assert.assertEquals(expected, compareTo);