1
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
2
<%@page import="junit.framework.Assert"%>
3
<%@page import="org.apache.struts.util.RequestUtils"%>
4
<%@page import="java.util.HashMap"%>
5
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
6
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
7
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
10
<!-- --------Testing attributes using forward------ -->
11
<logic:equal name="runTest" value="testLinkAction">
12
<bean:define id="EXPECTED_RESULTS" toScope="page">
13
<html:link action="simpleAction">Test Link</html:link>
15
<bean:define id="TEST_RESULTS" toScope="page">
16
<a href="<%=org.apache.struts.taglib.TagUtils.getInstance().computeURL(pageContext, null, null, null, "simpleAction", null, null, null, false)%>">Test Link</a>
20
<logic:equal name="runTest" value="testLinkActionAccesskey">
21
<bean:define id="EXPECTED_RESULTS" toScope="page">
22
<html:link action="simpleAction" accesskey="XXX">Test Link</html:link>
24
<bean:define id="TEST_RESULTS" toScope="page">
25
<a href="<%=org.apache.struts.taglib.TagUtils.getInstance().computeURL(pageContext, null, null, null, "simpleAction", null, null, null, false)%>" accesskey="XXX">Test Link</a>
30
<logic:equal name="runTest" value="testLinkActionAnchor">
31
<bean:define id="EXPECTED_RESULTS" toScope="page">
32
<html:link action="simpleAction" anchor="XXX">Test Link</html:link>
34
<bean:define id="TEST_RESULTS" toScope="page">
35
<a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do#XXX")%>">Test Link</a>
40
<logic:equal name="runTest" value="testLinkActionIndexedArray">
41
<bean:define id="EXPECTED_RESULTS" toScope="page">
42
<logic:iterate id="indivItem" name="lst">
43
<html:link action="simpleAction" indexed="true">Test Link</html:link>
46
<bean:define id="TEST_RESULTS" toScope="page">
48
<a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?index=0")%>">Test Link</a>
53
<logic:equal name="runTest" value="testLinkActionIndexedArrayProperty">
54
<bean:define id="EXPECTED_RESULTS" toScope="page">
55
<logic:iterate id="indivItem" name="lst" property="list">
56
<html:link action="simpleAction" indexed="true">Test Link</html:link>
59
<bean:define id="TEST_RESULTS" toScope="page">
61
<a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?index=0")%>">Test Link</a>
66
<logic:equal name="runTest" value="testLinkActionIndexedMap">
67
<bean:define id="EXPECTED_RESULTS" toScope="page">
68
<logic:iterate id="indivItem" name="lst">
69
<html:link action="simpleAction" indexed="true">Test Link</html:link>
72
<bean:define id="TEST_RESULTS" toScope="page">
74
<a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?index=0")%>">Test Link</a>
79
<logic:equal name="runTest" value="testLinkActionIndexedMapProperty">
80
<bean:define id="EXPECTED_RESULTS" toScope="page">
81
<logic:iterate id="indivItem" name="lst" property="map">
82
<html:link action="simpleAction" indexed="true">Test Link</html:link>
85
<bean:define id="TEST_RESULTS" toScope="page">
87
<a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?index=0")%>">Test Link</a>
92
<logic:equal name="runTest" value="testLinkActionIndexedEnumeration">
93
<bean:define id="EXPECTED_RESULTS" toScope="page">
94
<logic:iterate id="indivItem" name="lst">
95
<html:link action="simpleAction" indexed="true">Test Link</html:link>
98
<bean:define id="TEST_RESULTS" toScope="page">
100
<a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?index=0")%>">Test Link</a>
102
<a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?index=1")%>">Test Link</a>
107
<logic:equal name="runTest" value="testLinkActionIndexedEnumerationProperty">
108
<bean:define id="EXPECTED_RESULTS" toScope="page">
109
<logic:iterate id="indivItem" name="lst" property="enumeration">
110
<html:link action="simpleAction" indexed="true">Test Link</html:link>
113
<bean:define id="TEST_RESULTS" toScope="page">
115
<a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?index=0")%>">Test Link</a>
117
<a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?index=1")%>">Test Link</a>
128
<logic:equal name="runTest" value="testLinkActionIndexedAlternateIdArray">
129
<bean:define id="EXPECTED_RESULTS" toScope="page">
130
<logic:iterate id="indivItem" name="lst">
131
<html:link action="simpleAction" indexed="true" indexId="alternateId">Test Link</html:link>
134
<bean:define id="TEST_RESULTS" toScope="page">
136
<a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?alternateId=0")%>">Test Link</a>
141
<logic:equal name="runTest" value="testLinkActionIndexedAlternateIdArrayProperty">
142
<bean:define id="EXPECTED_RESULTS" toScope="page">
143
<logic:iterate id="indivItem" name="lst" property="list">
144
<html:link action="simpleAction" indexed="true" indexId="alternateId">Test Link</html:link>
147
<bean:define id="TEST_RESULTS" toScope="page">
149
<a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?alternateId=0")%>">Test Link</a>
154
<logic:equal name="runTest" value="testLinkActionIndexedAlternateIdMap">
155
<bean:define id="EXPECTED_RESULTS" toScope="page">
156
<logic:iterate id="indivItem" name="lst">
157
<html:link action="simpleAction" indexed="true" indexId="alternateId">Test Link</html:link>
160
<bean:define id="TEST_RESULTS" toScope="page">
162
<a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?alternateId=0")%>">Test Link</a>
167
<logic:equal name="runTest" value="testLinkActionIndexedAlternateIdMapProperty">
168
<bean:define id="EXPECTED_RESULTS" toScope="page">
169
<logic:iterate id="indivItem" name="lst" property="map">
170
<html:link action="simpleAction" indexed="true" indexId="alternateId">Test Link</html:link>
173
<bean:define id="TEST_RESULTS" toScope="page">
175
<a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?alternateId=0")%>">Test Link</a>
180
<logic:equal name="runTest" value="testLinkActionIndexedAlternateIdEnumeration">
181
<bean:define id="EXPECTED_RESULTS" toScope="page">
182
<logic:iterate id="indivItem" name="lst">
183
<html:link action="simpleAction" indexed="true" indexId="alternateId">Test Link</html:link>
186
<bean:define id="TEST_RESULTS" toScope="page">
188
<a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?alternateId=0")%>">Test Link</a>
190
<a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?alternateId=1")%>">Test Link</a>
195
<logic:equal name="runTest" value="testLinkActionIndexedAlternateIdEnumerationProperty">
196
<bean:define id="EXPECTED_RESULTS" toScope="page">
197
<logic:iterate id="indivItem" name="lst" property="enumeration">
198
<html:link action="simpleAction" indexed="true" indexId="alternateId">Test Link</html:link>
201
<bean:define id="TEST_RESULTS" toScope="page">
203
<a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?alternateId=0")%>">Test Link</a>
205
<a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?alternateId=1")%>">Test Link</a>
210
<logic:equal name="runTest" value="testLinkActionLinkName">
211
<bean:define id="EXPECTED_RESULTS" toScope="page">
212
<html:link linkName="linkName">Test Link</html:link>
214
<bean:define id="TEST_RESULTS" toScope="page">
215
<a name="linkName">Test Link</a>
223
<logic:equal name="runTest" value="testLinkActionNameNoScope">
224
<bean:define id="EXPECTED_RESULTS" toScope="page">
225
<html:link action="simpleAction" name="paramMap">Test Link</html:link>
227
<bean:define id="thisMap" name="paramMap" type="java.util.Map"/>
228
<bean:define id="TEST_RESULTS" toScope="page">
229
<a href="<%=org.apache.struts.taglib.TagUtils.getInstance().computeURL(pageContext, null, null, null, "simpleAction", null, thisMap, null, false)%>">Test Link</a>
233
<logic:equal name="runTest" value="testLinkActionNamePropertyNoScope">
234
<bean:define id="EXPECTED_RESULTS" toScope="page">
235
<html:link action="simpleAction" name="paramPropertyMap" property="map">Test Link</html:link>
237
<bean:define id="thisMap" name="paramPropertyMap" property="map" type="java.util.Map"/>
238
<bean:define id="TEST_RESULTS" toScope="page">
239
<a href="<%=org.apache.struts.taglib.TagUtils.getInstance().computeURL(pageContext, null, null, null, "simpleAction", null, thisMap, null, false)%>">Test Link</a>
243
<logic:equal name="runTest" value="testLinkActionNameApplicationScope">
244
<bean:define id="EXPECTED_RESULTS" toScope="page">
245
<html:link action="simpleAction" name="paramMap" scope="application">Test Link</html:link>
247
<bean:define id="thisMap" name="paramMap" type="java.util.Map"/>
248
<bean:define id="TEST_RESULTS" toScope="page">
249
<a href="<%=org.apache.struts.taglib.TagUtils.getInstance().computeURL(pageContext, null, null, null, "simpleAction", null, thisMap, null, false)%>">Test Link</a>
253
<logic:equal name="runTest" value="testLinkActionNamePropertyApplicationScope">
254
<bean:define id="EXPECTED_RESULTS" toScope="page">
255
<html:link action="simpleAction" name="paramPropertyMap" property="map" scope="application">Test Link</html:link>
257
<bean:define id="thisMap" name="paramPropertyMap" property="map" type="java.util.Map"/>
258
<bean:define id="TEST_RESULTS" toScope="page">
259
<a href="<%=org.apache.struts.taglib.TagUtils.getInstance().computeURL(pageContext, null, null, null, "simpleAction", null, thisMap, null, false)%>">Test Link</a>
263
<logic:equal name="runTest" value="testLinkActionNameSessionScope">
264
<bean:define id="EXPECTED_RESULTS" toScope="page">
265
<html:link action="simpleAction" name="paramMap" scope="session">Test Link</html:link>
267
<bean:define id="thisMap" name="paramMap" type="java.util.Map"/>
268
<bean:define id="TEST_RESULTS" toScope="page">
269
<a href="<%=org.apache.struts.taglib.TagUtils.getInstance().computeURL(pageContext, null, null, null, "simpleAction", null, thisMap, null, false)%>">Test Link</a>
273
<logic:equal name="runTest" value="testLinkActionNamePropertySessionScope">
274
<bean:define id="EXPECTED_RESULTS" toScope="page">
275
<html:link action="simpleAction" name="paramPropertyMap" property="map" scope="session">Test Link</html:link>
277
<bean:define id="thisMap" name="paramPropertyMap" property="map" type="java.util.Map"/>
278
<bean:define id="TEST_RESULTS" toScope="page">
279
<a href="<%=org.apache.struts.taglib.TagUtils.getInstance().computeURL(pageContext, null, null, null, "simpleAction", null, thisMap, null, false)%>">Test Link</a>
283
<logic:equal name="runTest" value="testLinkActionNameRequestScope">
284
<bean:define id="EXPECTED_RESULTS" toScope="page">
285
<html:link action="simpleAction" name="paramMap" scope="request">Test Link</html:link>
287
<bean:define id="thisMap" name="paramMap" type="java.util.Map"/>
288
<bean:define id="TEST_RESULTS" toScope="page">
289
<a href="<%=org.apache.struts.taglib.TagUtils.getInstance().computeURL(pageContext, null, null, null, "simpleAction", null, thisMap, null, false)%>">Test Link</a>
293
<logic:equal name="runTest" value="testLinkActionNamePropertyRequestScope">
294
<bean:define id="EXPECTED_RESULTS" toScope="page">
295
<html:link action="simpleAction" name="paramPropertyMap" property="map" scope="request">Test Link</html:link>
297
<bean:define id="thisMap" name="paramPropertyMap" property="map" type="java.util.Map"/>
298
<bean:define id="TEST_RESULTS" toScope="page">
299
<a href="<%=org.apache.struts.taglib.TagUtils.getInstance().computeURL(pageContext, null, null, null, "simpleAction", null, thisMap, null, false)%>">Test Link</a>
305
String expected = (String) pageContext.getAttribute("EXPECTED_RESULTS");
306
String compareTo = (String) pageContext.getAttribute("TEST_RESULTS");
308
if ((expected == null) || (compareTo == null)){
309
Assert.fail("An invalid (or mispelled) test on this page was called. Please verify that you've setup the tests (and spellings) correctly.");
312
Assert.assertEquals(expected, compareTo);
b'\\ No newline at end of file'