~ubuntu-branches/ubuntu/trusty/libstruts1.2-java/trusty-proposed

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2004-11-19 15:35:25 UTC
  • Revision ID: james.westby@ubuntu.com-20041119153525-mdu08a76z4zo67xt
Tags: upstream-1.2.4
ImportĀ upstreamĀ versionĀ 1.2.4

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.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" %>
 
8
 
 
9
 
 
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>
 
14
    </bean:define>
 
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>
 
17
    </bean:define>
 
18
</logic:equal>
 
19
 
 
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>
 
23
    </bean:define>
 
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>
 
26
    </bean:define>
 
27
</logic:equal>
 
28
 
 
29
 
 
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>
 
33
    </bean:define>
 
34
    <bean:define id="TEST_RESULTS" toScope="page">
 
35
        <a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do#XXX")%>">Test Link</a>
 
36
    </bean:define>
 
37
</logic:equal>
 
38
 
 
39
 
 
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>
 
44
          </logic:iterate>
 
45
        </bean:define>
 
46
        <bean:define id="TEST_RESULTS" toScope="page">
 
47
        
 
48
                <a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?index=0")%>">Test Link</a>
 
49
                
 
50
        </bean:define>
 
51
</logic:equal>
 
52
 
 
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>
 
57
          </logic:iterate>
 
58
        </bean:define>
 
59
        <bean:define id="TEST_RESULTS" toScope="page">
 
60
        
 
61
                <a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?index=0")%>">Test Link</a>
 
62
                
 
63
        </bean:define>
 
64
</logic:equal>
 
65
 
 
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>
 
70
          </logic:iterate>
 
71
        </bean:define>
 
72
        <bean:define id="TEST_RESULTS" toScope="page">
 
73
        
 
74
                <a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?index=0")%>">Test Link</a>
 
75
                
 
76
        </bean:define>
 
77
</logic:equal>
 
78
 
 
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>
 
83
          </logic:iterate>
 
84
        </bean:define>
 
85
        <bean:define id="TEST_RESULTS" toScope="page">
 
86
        
 
87
                <a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?index=0")%>">Test Link</a>
 
88
                
 
89
        </bean:define>
 
90
</logic:equal>
 
91
 
 
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>
 
96
        </logic:iterate>
 
97
        </bean:define>
 
98
        <bean:define id="TEST_RESULTS" toScope="page">
 
99
        
 
100
                <a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?index=0")%>">Test Link</a>
 
101
        
 
102
                <a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?index=1")%>">Test Link</a>
 
103
        
 
104
        </bean:define>
 
105
</logic:equal>
 
106
 
 
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>
 
111
        </logic:iterate>
 
112
        </bean:define>
 
113
        <bean:define id="TEST_RESULTS" toScope="page">
 
114
        
 
115
                <a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?index=0")%>">Test Link</a>
 
116
        
 
117
                <a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?index=1")%>">Test Link</a>
 
118
        
 
119
        </bean:define>
 
120
</logic:equal>
 
121
 
 
122
 
 
123
 
 
124
 
 
125
 
 
126
 
 
127
 
 
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>
 
132
          </logic:iterate>
 
133
        </bean:define>
 
134
        <bean:define id="TEST_RESULTS" toScope="page">
 
135
        
 
136
                <a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?alternateId=0")%>">Test Link</a>
 
137
                
 
138
        </bean:define>
 
139
</logic:equal>
 
140
 
 
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>
 
145
          </logic:iterate>
 
146
        </bean:define>
 
147
        <bean:define id="TEST_RESULTS" toScope="page">
 
148
        
 
149
                <a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?alternateId=0")%>">Test Link</a>
 
150
                
 
151
        </bean:define>
 
152
</logic:equal>
 
153
 
 
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>
 
158
          </logic:iterate>
 
159
        </bean:define>
 
160
        <bean:define id="TEST_RESULTS" toScope="page">
 
161
        
 
162
                <a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?alternateId=0")%>">Test Link</a>
 
163
                
 
164
        </bean:define>
 
165
</logic:equal>
 
166
 
 
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>
 
171
          </logic:iterate>
 
172
        </bean:define>
 
173
        <bean:define id="TEST_RESULTS" toScope="page">
 
174
        
 
175
                <a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?alternateId=0")%>">Test Link</a>
 
176
                
 
177
        </bean:define>
 
178
</logic:equal>
 
179
 
 
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>
 
184
        </logic:iterate>
 
185
        </bean:define>
 
186
        <bean:define id="TEST_RESULTS" toScope="page">
 
187
        
 
188
                <a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?alternateId=0")%>">Test Link</a>
 
189
        
 
190
                <a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?alternateId=1")%>">Test Link</a>
 
191
        
 
192
        </bean:define>
 
193
</logic:equal>
 
194
 
 
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>
 
199
        </logic:iterate>
 
200
        </bean:define>
 
201
        <bean:define id="TEST_RESULTS" toScope="page">
 
202
        
 
203
                <a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?alternateId=0")%>">Test Link</a>
 
204
        
 
205
                <a href="<%=response.encodeURL( request.getContextPath() + "/simpleAction.do?alternateId=1")%>">Test Link</a>
 
206
        
 
207
        </bean:define>
 
208
</logic:equal>
 
209
 
 
210
<logic:equal name="runTest" value="testLinkActionLinkName">
 
211
    <bean:define id="EXPECTED_RESULTS" toScope="page">
 
212
        <html:link linkName="linkName">Test Link</html:link>
 
213
    </bean:define>
 
214
    <bean:define id="TEST_RESULTS" toScope="page">
 
215
        <a name="linkName">Test Link</a>
 
216
    </bean:define>
 
217
</logic:equal>
 
218
 
 
219
 
 
220
 
 
221
 
 
222
 
 
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>
 
226
    </bean:define>
 
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>
 
230
    </bean:define>
 
231
</logic:equal>
 
232
 
 
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>
 
236
   </bean:define>
 
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>
 
240
    </bean:define>
 
241
</logic:equal>
 
242
 
 
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>
 
246
    </bean:define>
 
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>
 
250
    </bean:define>
 
251
</logic:equal>
 
252
 
 
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>
 
256
    </bean:define>
 
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>
 
260
    </bean:define>
 
261
</logic:equal>
 
262
 
 
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>
 
266
    </bean:define>
 
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>
 
270
    </bean:define>
 
271
</logic:equal>
 
272
 
 
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>
 
276
    </bean:define>
 
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>
 
280
    </bean:define>
 
281
</logic:equal>
 
282
 
 
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>
 
286
    </bean:define>
 
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>
 
290
    </bean:define>
 
291
</logic:equal>
 
292
 
 
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>
 
296
    </bean:define>
 
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>
 
300
    </bean:define>
 
301
</logic:equal>
 
302
 
 
303
 
 
304
<% 
 
305
String expected  = (String) pageContext.getAttribute("EXPECTED_RESULTS");
 
306
String compareTo = (String) pageContext.getAttribute("TEST_RESULTS");
 
307
 
 
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.");
 
310
}
 
311
        
 
312
Assert.assertEquals(expected, compareTo);
 
313
%>
 
 
b'\\ No newline at end of file'