26
26
import javax .servlet .http .HttpServletResponse ;
27
27
28
28
import org .assertj .core .api .ObjectAssert ;
29
- import org .junit .Before ;
30
29
import org .junit .Test ;
31
30
32
31
import org .springframework .mock .web .test .MockHttpServletRequest ;
36
35
37
36
import static org .assertj .core .api .Assertions .assertThat ;
38
37
39
-
40
38
/**
41
39
* Test fixture for testing {@link AbstractFlashMapManager} methods.
42
40
*
43
41
* @author Rossen Stoyanchev
42
+ * @author Sam Brannen
44
43
*/
45
44
public class FlashMapManagerTests {
46
45
47
- private TestFlashMapManager flashMapManager ;
48
-
49
- private MockHttpServletRequest request ;
46
+ private final TestFlashMapManager flashMapManager = new TestFlashMapManager ();
50
47
51
- private MockHttpServletResponse response ;
48
+ private final MockHttpServletRequest request = new MockHttpServletRequest () ;
52
49
53
-
54
- @ Before
55
- public void setup () {
56
- this .flashMapManager = new TestFlashMapManager ();
57
- this .request = new MockHttpServletRequest ();
58
- this .response = new MockHttpServletResponse ();
59
- }
50
+ private final MockHttpServletResponse response = new MockHttpServletResponse ();
60
51
61
52
62
53
@ Test
@@ -73,9 +64,7 @@ public void retrieveAndUpdateMatchByPath() {
73
64
assertThatFlashMap (inputFlashMap ).isEqualTo (flashMap );
74
65
}
75
66
76
- // SPR-8779
77
-
78
- @ Test
67
+ @ Test // SPR-8779
79
68
public void retrieveAndUpdateMatchByOriginatingPath () {
80
69
FlashMap flashMap = new FlashMap ();
81
70
flashMap .put ("key" , "value" );
@@ -133,9 +122,7 @@ public void retrieveAndUpdateMatchByParams() {
133
122
assertThat (this .flashMapManager .getFlashMaps ().size ()).as ("Input FlashMap should have been removed" ).isEqualTo (0 );
134
123
}
135
124
136
- // SPR-8798
137
-
138
- @ Test
125
+ @ Test // SPR-8798
139
126
public void retrieveAndUpdateMatchWithMultiValueParam () {
140
127
FlashMap flashMap = new FlashMap ();
141
128
flashMap .put ("name" , "value" );
@@ -180,7 +167,7 @@ public void retrieveAndUpdateSortMultipleMatches() {
180
167
}
181
168
182
169
@ Test
183
- public void retrieveAndUpdateRemoveExpired () throws InterruptedException {
170
+ public void retrieveAndUpdateRemoveExpired () {
184
171
List <FlashMap > flashMaps = new ArrayList <>();
185
172
for (int i = 0 ; i < 5 ; i ++) {
186
173
FlashMap expiredFlashMap = new FlashMap ();
@@ -194,7 +181,7 @@ public void retrieveAndUpdateRemoveExpired() throws InterruptedException {
194
181
}
195
182
196
183
@ Test
197
- public void saveOutputFlashMapEmpty () throws InterruptedException {
184
+ public void saveOutputFlashMapEmpty () {
198
185
FlashMap flashMap = new FlashMap ();
199
186
200
187
this .flashMapManager .saveOutputFlashMap (flashMap , this .request , this .response );
@@ -204,7 +191,7 @@ public void saveOutputFlashMapEmpty() throws InterruptedException {
204
191
}
205
192
206
193
@ Test
207
- public void saveOutputFlashMap () throws InterruptedException {
194
+ public void saveOutputFlashMap () {
208
195
FlashMap flashMap = new FlashMap ();
209
196
flashMap .put ("name" , "value" );
210
197
@@ -218,7 +205,7 @@ public void saveOutputFlashMap() throws InterruptedException {
218
205
}
219
206
220
207
@ Test
221
- public void saveOutputFlashMapDecodeTargetPath () throws InterruptedException {
208
+ public void saveOutputFlashMapDecodeTargetPath () {
222
209
FlashMap flashMap = new FlashMap ();
223
210
flashMap .put ("key" , "value" );
224
211
@@ -229,7 +216,7 @@ public void saveOutputFlashMapDecodeTargetPath() throws InterruptedException {
229
216
}
230
217
231
218
@ Test
232
- public void saveOutputFlashMapNormalizeTargetPath () throws InterruptedException {
219
+ public void saveOutputFlashMapNormalizeTargetPath () {
233
220
FlashMap flashMap = new FlashMap ();
234
221
flashMap .put ("key" , "value" );
235
222
@@ -264,11 +251,19 @@ public void saveOutputFlashMapNormalizeTargetPath() throws InterruptedException
264
251
assertThat (flashMap .getTargetRequestPath ()).isEqualTo ("/once/only" );
265
252
}
266
253
267
- // SPR-9657, SPR-11504
254
+ @ Test // gh-23240
255
+ public void saveOutputFlashMapAndNormalizeEmptyTargetPath () {
256
+ FlashMap flashMap = new FlashMap ();
257
+ flashMap .put ("key" , "value" );
268
258
269
- @ Test
270
- public void saveOutputFlashMapDecodeParameters () throws Exception {
259
+ flashMap .setTargetRequestPath ("" );
260
+ this .flashMapManager .saveOutputFlashMap (flashMap , this .request , this .response );
261
+
262
+ assertThat (flashMap .getTargetRequestPath ()).isEqualTo ("" );
263
+ }
271
264
265
+ @ Test // SPR-9657, SPR-11504
266
+ public void saveOutputFlashMapDecodeParameters () throws Exception {
272
267
FlashMap flashMap = new FlashMap ();
273
268
flashMap .put ("key" , "value" );
274
269
flashMap .setTargetRequestPath ("/path" );
@@ -294,11 +289,8 @@ public void saveOutputFlashMapDecodeParameters() throws Exception {
294
289
assertThat (flashMap .get ("key" )).isEqualTo ("value" );
295
290
}
296
291
297
- // SPR-12569
298
-
299
- @ Test
292
+ @ Test // SPR-12569
300
293
public void flashAttributesWithQueryParamsWithSpace () throws Exception {
301
-
302
294
String encodedValue = URLEncoder .encode ("1 2" , "UTF-8" );
303
295
304
296
FlashMap flashMap = new FlashMap ();
0 commit comments