1
1
/*
2
- * Copyright 2002-2019 the original author or authors.
2
+ * Copyright 2002-2020 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
16
16
17
17
package org .springframework .web .util ;
18
18
19
- import java .io .UnsupportedEncodingException ;
20
-
21
19
import org .junit .jupiter .api .Disabled ;
22
20
import org .junit .jupiter .api .Test ;
23
21
@@ -46,7 +44,7 @@ public void getPathWithinApplication() {
46
44
request .setContextPath ("/petclinic" );
47
45
request .setRequestURI ("/petclinic/welcome.html" );
48
46
49
- assertThat (helper .getPathWithinApplication (request )).as ( "Incorrect path returned" ). isEqualTo ("/welcome.html" );
47
+ assertThat (helper .getPathWithinApplication (request )).isEqualTo ("/welcome.html" );
50
48
}
51
49
52
50
@ Test
@@ -62,7 +60,7 @@ public void getPathWithinApplicationForSlashContextPath() {
62
60
request .setContextPath ("/" );
63
61
request .setRequestURI ("/welcome.html" );
64
62
65
- assertThat (helper .getPathWithinApplication (request )).as ( "Incorrect path returned" ). isEqualTo ("/welcome.html" );
63
+ assertThat (helper .getPathWithinApplication (request )).isEqualTo ("/welcome.html" );
66
64
}
67
65
68
66
@ Test
@@ -71,7 +69,7 @@ public void getPathWithinServlet() {
71
69
request .setServletPath ("/main" );
72
70
request .setRequestURI ("/petclinic/main/welcome.html" );
73
71
74
- assertThat (helper .getPathWithinServletMapping (request )).as ( "Incorrect path returned" ). isEqualTo ("/welcome.html" );
72
+ assertThat (helper .getPathWithinServletMapping (request )).isEqualTo ("/welcome.html" );
75
73
}
76
74
77
75
@ Test
@@ -81,12 +79,10 @@ public void alwaysUseFullPath() {
81
79
request .setServletPath ("/main" );
82
80
request .setRequestURI ("/petclinic/main/welcome.html" );
83
81
84
- assertThat (helper .getLookupPathForRequest (request )).as ( "Incorrect path returned" ). isEqualTo ("/main/welcome.html" );
82
+ assertThat (helper .getLookupPathForRequest (request )).isEqualTo ("/main/welcome.html" );
85
83
}
86
84
87
- // SPR-11101
88
-
89
- @ Test
85
+ @ Test // SPR-11101
90
86
public void getPathWithinServletWithoutUrlDecoding () {
91
87
request .setContextPath ("/SPR-11101" );
92
88
request .setServletPath ("/test_url_decoding/a/b" );
@@ -101,32 +97,29 @@ public void getPathWithinServletWithoutUrlDecoding() {
101
97
@ Test
102
98
public void getRequestUri () {
103
99
request .setRequestURI ("/welcome.html" );
104
- assertThat (helper .getRequestUri (request )).as ( "Incorrect path returned" ). isEqualTo ("/welcome.html" );
100
+ assertThat (helper .getRequestUri (request )).isEqualTo ("/welcome.html" );
105
101
106
102
request .setRequestURI ("/foo%20bar" );
107
- assertThat (helper .getRequestUri (request )).as ( "Incorrect path returned" ). isEqualTo ("/foo bar" );
103
+ assertThat (helper .getRequestUri (request )).isEqualTo ("/foo bar" );
108
104
109
105
request .setRequestURI ("/foo+bar" );
110
- assertThat (helper .getRequestUri (request )).as ( "Incorrect path returned" ). isEqualTo ("/foo+bar" );
106
+ assertThat (helper .getRequestUri (request )).isEqualTo ("/foo+bar" );
111
107
}
112
108
113
109
@ Test
114
- public void getRequestRemoveSemicolonContent () throws UnsupportedEncodingException {
110
+ public void getRequestRemoveSemicolonContent () {
115
111
helper .setRemoveSemicolonContent (true );
116
-
117
112
request .setRequestURI ("/foo;f=F;o=O;o=O/bar;b=B;a=A;r=R" );
118
113
assertThat (helper .getRequestUri (request )).isEqualTo ("/foo/bar" );
119
114
120
115
// SPR-13455
121
-
122
- request .setServletPath ("/foo/1" );
123
116
request .setRequestURI ("/foo/;test/1" );
124
-
117
+ request . setServletPath ( "/foo/1" );
125
118
assertThat (helper .getRequestUri (request )).isEqualTo ("/foo/1" );
126
119
}
127
120
128
121
@ Test
129
- public void getRequestKeepSemicolonContent () throws UnsupportedEncodingException {
122
+ public void getRequestKeepSemicolonContent () {
130
123
helper .setRemoveSemicolonContent (false );
131
124
132
125
request .setRequestURI ("/foo;a=b;c=d" );
@@ -139,7 +132,6 @@ public void getRequestKeepSemicolonContent() throws UnsupportedEncodingException
139
132
assertThat (helper .getRequestUri (request )).as ("jsessionid should always be removed" ).isEqualTo ("/foo;a=b;c=d" );
140
133
141
134
// SPR-10398
142
-
143
135
request .setRequestURI ("/foo;a=b;JSESSIONID=c0o7fszeb1;c=d" );
144
136
assertThat (helper .getRequestUri (request )).as ("JSESSIONID should always be removed" ).isEqualTo ("/foo;a=b;c=d" );
145
137
}
@@ -178,37 +170,36 @@ public void getLookupPathWithSemicolonContentAndNullPathInfo() {
178
170
//
179
171
180
172
@ Test
181
- public void tomcatDefaultServletRoot () throws Exception {
173
+ public void tomcatDefaultServletRoot () {
182
174
request .setContextPath ("/test" );
183
- request .setPathInfo (null );
184
175
request .setServletPath ("/" );
176
+ request .setPathInfo (null );
185
177
request .setRequestURI ("/test/" );
186
178
assertThat (helper .getLookupPathForRequest (request )).isEqualTo ("/" );
187
179
}
188
180
189
181
@ Test
190
- public void tomcatDefaultServletFile () throws Exception {
182
+ public void tomcatDefaultServletFile () {
191
183
request .setContextPath ("/test" );
192
- request .setPathInfo (null );
193
184
request .setServletPath ("/foo" );
185
+ request .setPathInfo (null );
194
186
request .setRequestURI ("/test/foo" );
195
187
196
188
assertThat (helper .getLookupPathForRequest (request )).isEqualTo ("/foo" );
197
189
}
198
190
199
191
@ Test
200
- public void tomcatDefaultServletFolder () throws Exception {
192
+ public void tomcatDefaultServletFolder () {
201
193
request .setContextPath ("/test" );
202
- request .setPathInfo (null );
203
194
request .setServletPath ("/foo/" );
195
+ request .setPathInfo (null );
204
196
request .setRequestURI ("/test/foo/" );
205
197
206
198
assertThat (helper .getLookupPathForRequest (request )).isEqualTo ("/foo/" );
207
199
}
208
200
209
- //SPR-12372 & SPR-13455
210
- @ Test
211
- public void removeDuplicateSlashesInPath () throws Exception {
201
+ @ Test //SPR-12372, SPR-13455
202
+ public void removeDuplicateSlashesInPath () {
212
203
request .setContextPath ("/SPR-12372" );
213
204
request .setPathInfo (null );
214
205
request .setServletPath ("/foo/bar/" );
@@ -229,7 +220,7 @@ public void removeDuplicateSlashesInPath() throws Exception {
229
220
}
230
221
231
222
@ Test
232
- public void wasDefaultServletRoot () throws Exception {
223
+ public void wasDefaultServletRoot () {
233
224
request .setContextPath ("/test" );
234
225
request .setPathInfo ("/" );
235
226
request .setServletPath ("" );
@@ -240,13 +231,13 @@ public void wasDefaultServletRoot() throws Exception {
240
231
}
241
232
242
233
@ Test
243
- public void wasDefaultServletRootWithCompliantSetting () throws Exception {
234
+ public void wasDefaultServletRootWithCompliantSetting () {
244
235
request .setAttribute (WEBSPHERE_URI_ATTRIBUTE , "/test/" );
245
236
tomcatDefaultServletRoot ();
246
237
}
247
238
248
239
@ Test
249
- public void wasDefaultServletFile () throws Exception {
240
+ public void wasDefaultServletFile () {
250
241
request .setContextPath ("/test" );
251
242
request .setPathInfo ("/foo" );
252
243
request .setServletPath ("" );
@@ -257,13 +248,13 @@ public void wasDefaultServletFile() throws Exception {
257
248
}
258
249
259
250
@ Test
260
- public void wasDefaultServletFileWithCompliantSetting () throws Exception {
251
+ public void wasDefaultServletFileWithCompliantSetting () {
261
252
request .setAttribute (WEBSPHERE_URI_ATTRIBUTE , "/test/foo" );
262
253
tomcatDefaultServletFile ();
263
254
}
264
255
265
256
@ Test
266
- public void wasDefaultServletFolder () throws Exception {
257
+ public void wasDefaultServletFolder () {
267
258
request .setContextPath ("/test" );
268
259
request .setPathInfo ("/foo/" );
269
260
request .setServletPath ("" );
@@ -274,7 +265,7 @@ public void wasDefaultServletFolder() throws Exception {
274
265
}
275
266
276
267
@ Test
277
- public void wasDefaultServletFolderWithCompliantSetting () throws Exception {
268
+ public void wasDefaultServletFolderWithCompliantSetting () {
278
269
UrlPathHelper .websphereComplianceFlag = true ;
279
270
try {
280
271
request .setAttribute (WEBSPHERE_URI_ATTRIBUTE , "/test/foo/" );
@@ -291,7 +282,7 @@ public void wasDefaultServletFolderWithCompliantSetting() throws Exception {
291
282
//
292
283
293
284
@ Test
294
- public void tomcatCasualServletRoot () throws Exception {
285
+ public void tomcatCasualServletRoot () {
295
286
request .setContextPath ("/test" );
296
287
request .setPathInfo ("/" );
297
288
request .setServletPath ("/foo" );
@@ -303,7 +294,7 @@ public void tomcatCasualServletRoot() throws Exception {
303
294
@ Disabled
304
295
// test the root mapping for /foo/* w/o a trailing slash - <host>/<context>/foo
305
296
@ Test
306
- public void tomcatCasualServletRootWithMissingSlash () throws Exception {
297
+ public void tomcatCasualServletRootWithMissingSlash () {
307
298
request .setContextPath ("/test" );
308
299
request .setPathInfo (null );
309
300
request .setServletPath ("/foo" );
@@ -313,7 +304,7 @@ public void tomcatCasualServletRootWithMissingSlash() throws Exception {
313
304
}
314
305
315
306
@ Test
316
- public void tomcatCasualServletFile () throws Exception {
307
+ public void tomcatCasualServletFile () {
317
308
request .setContextPath ("/test" );
318
309
request .setPathInfo ("/foo" );
319
310
request .setServletPath ("/foo" );
@@ -323,7 +314,7 @@ public void tomcatCasualServletFile() throws Exception {
323
314
}
324
315
325
316
@ Test
326
- public void tomcatCasualServletFolder () throws Exception {
317
+ public void tomcatCasualServletFolder () {
327
318
request .setContextPath ("/test" );
328
319
request .setPathInfo ("/foo/" );
329
320
request .setServletPath ("/foo" );
@@ -333,7 +324,7 @@ public void tomcatCasualServletFolder() throws Exception {
333
324
}
334
325
335
326
@ Test
336
- public void wasCasualServletRoot () throws Exception {
327
+ public void wasCasualServletRoot () {
337
328
request .setContextPath ("/test" );
338
329
request .setPathInfo (null );
339
330
request .setServletPath ("/foo/" );
@@ -344,15 +335,15 @@ public void wasCasualServletRoot() throws Exception {
344
335
}
345
336
346
337
@ Test
347
- public void wasCasualServletRootWithCompliantSetting () throws Exception {
338
+ public void wasCasualServletRootWithCompliantSetting () {
348
339
request .setAttribute (WEBSPHERE_URI_ATTRIBUTE , "/test/foo/" );
349
340
tomcatCasualServletRoot ();
350
341
}
351
342
352
343
@ Disabled
353
344
// test the root mapping for /foo/* w/o a trailing slash - <host>/<context>/foo
354
345
@ Test
355
- public void wasCasualServletRootWithMissingSlash () throws Exception {
346
+ public void wasCasualServletRootWithMissingSlash () {
356
347
request .setContextPath ("/test" );
357
348
request .setPathInfo (null );
358
349
request .setServletPath ("/foo" );
@@ -364,13 +355,13 @@ public void wasCasualServletRootWithMissingSlash() throws Exception {
364
355
365
356
@ Disabled
366
357
@ Test
367
- public void wasCasualServletRootWithMissingSlashWithCompliantSetting () throws Exception {
358
+ public void wasCasualServletRootWithMissingSlashWithCompliantSetting () {
368
359
request .setAttribute (WEBSPHERE_URI_ATTRIBUTE , "/test/foo" );
369
360
tomcatCasualServletRootWithMissingSlash ();
370
361
}
371
362
372
363
@ Test
373
- public void wasCasualServletFile () throws Exception {
364
+ public void wasCasualServletFile () {
374
365
request .setContextPath ("/test" );
375
366
request .setPathInfo ("/foo" );
376
367
request .setServletPath ("/foo" );
@@ -381,13 +372,13 @@ public void wasCasualServletFile() throws Exception {
381
372
}
382
373
383
374
@ Test
384
- public void wasCasualServletFileWithCompliantSetting () throws Exception {
375
+ public void wasCasualServletFileWithCompliantSetting () {
385
376
request .setAttribute (WEBSPHERE_URI_ATTRIBUTE , "/test/foo/foo" );
386
377
tomcatCasualServletFile ();
387
378
}
388
379
389
380
@ Test
390
- public void wasCasualServletFolder () throws Exception {
381
+ public void wasCasualServletFolder () {
391
382
request .setContextPath ("/test" );
392
383
request .setPathInfo ("/foo/" );
393
384
request .setServletPath ("/foo" );
@@ -398,7 +389,7 @@ public void wasCasualServletFolder() throws Exception {
398
389
}
399
390
400
391
@ Test
401
- public void wasCasualServletFolderWithCompliantSetting () throws Exception {
392
+ public void wasCasualServletFolderWithCompliantSetting () {
402
393
request .setAttribute (WEBSPHERE_URI_ATTRIBUTE , "/test/foo/foo/" );
403
394
tomcatCasualServletFolder ();
404
395
}
0 commit comments