1
1
/*
2
- * Copyright 2002-2017 the original author or authors.
2
+ * Copyright 2002-2018 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.
@@ -128,7 +128,7 @@ public void fromOpaqueUri() throws URISyntaxException {
128
128
assertEquals ("Invalid result URI" , uri , result .toUri ());
129
129
}
130
130
131
- @ Test // SPR-9317
131
+ @ Test // SPR-9317
132
132
public void fromUriEncodedQuery () throws URISyntaxException {
133
133
URI uri = new URI ("http://www.example.org/?param=aGVsbG9Xb3JsZA%3D%3D" );
134
134
String fromUri = UriComponentsBuilder .fromUri (uri ).build ().getQueryParams ().get ("param" ).get (0 );
@@ -184,7 +184,7 @@ public void fromUriString() {
184
184
assertEquals ("28" , result .getFragment ());
185
185
}
186
186
187
- @ Test // SPR-9832
187
+ @ Test // SPR-9832
188
188
public void fromUriStringQueryParamWithReservedCharInValue () throws URISyntaxException {
189
189
String uri = "http://www.google.com/ig/calculator?q=1USD=?EUR" ;
190
190
UriComponents result = UriComponentsBuilder .fromUriString (uri ).build ();
@@ -193,15 +193,15 @@ public void fromUriStringQueryParamWithReservedCharInValue() throws URISyntaxExc
193
193
assertEquals ("1USD=?EUR" , result .getQueryParams ().getFirst ("q" ));
194
194
}
195
195
196
- @ Test // SPR-14828
196
+ @ Test // SPR-14828
197
197
public void fromUriStringQueryParamEncodedAndContainingPlus () throws Exception {
198
198
String httpUrl = "http://localhost:8080/test/print?value=%EA%B0%80+%EB%82%98" ;
199
199
URI uri = UriComponentsBuilder .fromHttpUrl (httpUrl ).build (true ).toUri ();
200
200
201
201
assertEquals (httpUrl , uri .toString ());
202
202
}
203
203
204
- @ Test // SPR-10779
204
+ @ Test // SPR-10779
205
205
public void fromHttpUrlStringCaseInsesitiveScheme () {
206
206
assertEquals ("http" , UriComponentsBuilder .fromHttpUrl ("HTTP://www.google.com" ).build ().getScheme ());
207
207
assertEquals ("https" , UriComponentsBuilder .fromHttpUrl ("HTTPS://www.google.com" ).build ().getScheme ());
@@ -214,8 +214,8 @@ public void fromHttpUrlStringInvalidIPv6Host() throws URISyntaxException {
214
214
UriComponentsBuilder .fromHttpUrl ("http://[1abc:2abc:3abc::5ABC:6abc:8080/resource" ).build ().encode ();
215
215
}
216
216
217
- @ Test // SPR-10539
218
- public void fromUriStringIPv6Host () throws URISyntaxException {
217
+ @ Test // SPR-10539
218
+ public void fromUriStringIPv6Host () {
219
219
UriComponents result = UriComponentsBuilder
220
220
.fromUriString ("http://[1abc:2abc:3abc::5ABC:6abc]:8080/resource" ).build ().encode ();
221
221
assertEquals ("[1abc:2abc:3abc::5ABC:6abc]" , result .getHost ());
@@ -229,7 +229,7 @@ public void fromUriStringIPv6Host() throws URISyntaxException {
229
229
assertEquals ("[::192.168.1.1]" , resultIPv4compatible .getHost ());
230
230
}
231
231
232
- @ Test // SPR-11970
232
+ @ Test // SPR-11970
233
233
public void fromUriStringNoPathWithReservedCharInQuery () {
234
234
UriComponents result = UriComponentsBuilder .fromUriString ("http://example.com?foo=bar@baz" ).build ();
235
235
assertTrue (StringUtils .isEmpty (result .getUserInfo ()));
@@ -239,7 +239,7 @@ public void fromUriStringNoPathWithReservedCharInQuery() {
239
239
}
240
240
241
241
@ Test
242
- public void fromHttpRequest () throws URISyntaxException {
242
+ public void fromHttpRequest () {
243
243
MockHttpServletRequest request = new MockHttpServletRequest ();
244
244
request .setScheme ("http" );
245
245
request .setServerName ("localhost" );
@@ -255,7 +255,7 @@ public void fromHttpRequest() throws URISyntaxException {
255
255
assertEquals ("a=1" , result .getQuery ());
256
256
}
257
257
258
- @ Test // SPR-12771
258
+ @ Test // SPR-12771
259
259
public void fromHttpRequestResetsPortBeforeSettingIt () throws Exception {
260
260
MockHttpServletRequest request = new MockHttpServletRequest ();
261
261
request .addHeader ("X-Forwarded-Proto" , "https" );
@@ -275,7 +275,7 @@ public void fromHttpRequestResetsPortBeforeSettingIt() throws Exception {
275
275
assertEquals ("/rest/mobile/users/1" , result .getPath ());
276
276
}
277
277
278
- @ Test // SPR-14761
278
+ @ Test // SPR-14761
279
279
public void fromHttpRequestWithForwardedIPv4Host () {
280
280
MockHttpServletRequest request = new MockHttpServletRequest ();
281
281
request .setScheme ("http" );
@@ -290,7 +290,7 @@ public void fromHttpRequestWithForwardedIPv4Host() {
290
290
assertEquals ("http://192.168.0.1/mvc-showcase" , result .toString ());
291
291
}
292
292
293
- @ Test // SPR-14761
293
+ @ Test // SPR-14761
294
294
public void fromHttpRequestWithForwardedIPv6 () {
295
295
MockHttpServletRequest request = new MockHttpServletRequest ();
296
296
request .setScheme ("http" );
@@ -305,7 +305,7 @@ public void fromHttpRequestWithForwardedIPv6() {
305
305
assertEquals ("http://[1abc:2abc:3abc::5ABC:6abc]/mvc-showcase" , result .toString ());
306
306
}
307
307
308
- @ Test // SPR-14761
308
+ @ Test // SPR-14761
309
309
public void fromHttpRequestWithForwardedIPv6Host () {
310
310
MockHttpServletRequest request = new MockHttpServletRequest ();
311
311
request .setScheme ("http" );
@@ -320,7 +320,7 @@ public void fromHttpRequestWithForwardedIPv6Host() {
320
320
assertEquals ("http://[1abc:2abc:3abc::5ABC:6abc]/mvc-showcase" , result .toString ());
321
321
}
322
322
323
- @ Test // SPR-14761
323
+ @ Test // SPR-14761
324
324
public void fromHttpRequestWithForwardedIPv6HostAndPort () {
325
325
MockHttpServletRequest request = new MockHttpServletRequest ();
326
326
request .setScheme ("http" );
@@ -335,7 +335,6 @@ public void fromHttpRequestWithForwardedIPv6HostAndPort() {
335
335
assertEquals ("http://[1abc:2abc:3abc::5ABC:6abc]:8080/mvc-showcase" , result .toString ());
336
336
}
337
337
338
-
339
338
@ Test
340
339
public void fromHttpRequestWithForwardedHost () {
341
340
MockHttpServletRequest request = new MockHttpServletRequest ();
@@ -351,7 +350,7 @@ public void fromHttpRequestWithForwardedHost() {
351
350
assertEquals ("http://anotherHost/mvc-showcase" , result .toString ());
352
351
}
353
352
354
- @ Test // SPR-10701
353
+ @ Test // SPR-10701
355
354
public void fromHttpRequestWithForwardedHostIncludingPort () {
356
355
MockHttpServletRequest request = new MockHttpServletRequest ();
357
356
request .setScheme ("http" );
@@ -367,7 +366,7 @@ public void fromHttpRequestWithForwardedHostIncludingPort() {
367
366
assertEquals (443 , result .getPort ());
368
367
}
369
368
370
- @ Test // SPR-11140
369
+ @ Test // SPR-11140
371
370
public void fromHttpRequestWithForwardedHostMultiValuedHeader () {
372
371
MockHttpServletRequest request = new MockHttpServletRequest ();
373
372
request .setScheme ("http" );
@@ -382,7 +381,7 @@ public void fromHttpRequestWithForwardedHostMultiValuedHeader() {
382
381
assertEquals (-1 , result .getPort ());
383
382
}
384
383
385
- @ Test // SPR-11855
384
+ @ Test // SPR-11855
386
385
public void fromHttpRequestWithForwardedHostAndPort () {
387
386
MockHttpServletRequest request = new MockHttpServletRequest ();
388
387
request .setScheme ("http" );
@@ -398,7 +397,7 @@ public void fromHttpRequestWithForwardedHostAndPort() {
398
397
assertEquals (9090 , result .getPort ());
399
398
}
400
399
401
- @ Test // SPR-11872
400
+ @ Test // SPR-11872
402
401
public void fromHttpRequestWithForwardedHostWithDefaultPort () {
403
402
MockHttpServletRequest request = new MockHttpServletRequest ();
404
403
request .setScheme ("http" );
@@ -413,7 +412,7 @@ public void fromHttpRequestWithForwardedHostWithDefaultPort() {
413
412
assertEquals (-1 , result .getPort ());
414
413
}
415
414
416
- @ Test // SPR-16262
415
+ @ Test // SPR-16262
417
416
public void fromHttpRequestWithForwardedProtoWithDefaultPort () {
418
417
MockHttpServletRequest request = new MockHttpServletRequest ();
419
418
request .setScheme ("http" );
@@ -447,7 +446,7 @@ public void fromHttpRequestWithForwardedHostWithForwardedScheme() {
447
446
assertEquals (-1 , result .getPort ());
448
447
}
449
448
450
- @ Test // SPR-12771
449
+ @ Test // SPR-12771
451
450
public void fromHttpRequestWithForwardedProtoAndDefaultPort () {
452
451
MockHttpServletRequest request = new MockHttpServletRequest ();
453
452
request .setScheme ("http" );
@@ -464,7 +463,7 @@ public void fromHttpRequestWithForwardedProtoAndDefaultPort() {
464
463
assertEquals ("https://84.198.58.199/mvc-showcase" , result .toString ());
465
464
}
466
465
467
- @ Test // SPR-12813
466
+ @ Test // SPR-12813
468
467
public void fromHttpRequestWithForwardedPortMultiValueHeader () {
469
468
MockHttpServletRequest request = new MockHttpServletRequest ();
470
469
request .setScheme ("http" );
@@ -480,7 +479,7 @@ public void fromHttpRequestWithForwardedPortMultiValueHeader() {
480
479
assertEquals ("http://a.example.org/mvc-showcase" , result .toString ());
481
480
}
482
481
483
- @ Test // SPR-12816
482
+ @ Test // SPR-12816
484
483
public void fromHttpRequestWithForwardedProtoMultiValueHeader () {
485
484
MockHttpServletRequest request = new MockHttpServletRequest ();
486
485
request .setScheme ("http" );
@@ -497,7 +496,7 @@ public void fromHttpRequestWithForwardedProtoMultiValueHeader() {
497
496
assertEquals ("https://a.example.org/mvc-showcase" , result .toString ());
498
497
}
499
498
500
- @ Test // SPR-12742
499
+ @ Test // SPR-12742
501
500
public void fromHttpRequestWithTrailingSlash () throws Exception {
502
501
UriComponents before = UriComponentsBuilder .fromPath ("/foo/" ).build ();
503
502
UriComponents after = UriComponentsBuilder .newInstance ().uriComponents (before ).build ();
@@ -567,7 +566,7 @@ public void pathSegmentsSomeEmpty() {
567
566
assertEquals (Arrays .asList ("foo" , "bar" ), result .getPathSegments ());
568
567
}
569
568
570
- @ Test // SPR-12398
569
+ @ Test // SPR-12398
571
570
public void pathWithDuplicateSlashes () throws URISyntaxException {
572
571
UriComponents uriComponents = UriComponentsBuilder .fromPath ("/foo/////////bar" ).build ();
573
572
assertEquals ("/foo/bar" , uriComponents .getPath ());
@@ -761,7 +760,7 @@ public void testClone() throws URISyntaxException {
761
760
assertEquals ("f2" , result2 .getFragment ());
762
761
}
763
762
764
- @ Test // SPR-11856
763
+ @ Test // SPR-11856
765
764
public void fromHttpRequestForwardedHeader () throws Exception {
766
765
MockHttpServletRequest request = new MockHttpServletRequest ();
767
766
request .addHeader ("Forwarded" , "proto=https; host=84.198.58.199" );
@@ -900,4 +899,14 @@ public void fromHttpRequestForwardedHeaderWithProtoAndServerPort() throws Except
900
899
assertEquals (-1 , result .getPort ());
901
900
assertEquals ("https://example.com/rest/mobile/users/1" , result .toUriString ());
902
901
}
902
+
903
+ @ Test // SPR-16364
904
+ public void uriComponentsNotEqualAfterNormalization () {
905
+ UriComponents uri1 = UriComponentsBuilder .fromUriString ("http://test.com" ).build ().normalize ();
906
+ UriComponents uri2 = UriComponentsBuilder .fromUriString ("http://test.com/" ).build ();
907
+ assertTrue (uri1 .getPathSegments ().isEmpty ());
908
+ assertTrue (uri2 .getPathSegments ().isEmpty ());
909
+ assertNotEquals (uri1 , uri2 );
910
+ }
911
+
903
912
}
0 commit comments