Minor fixes: UriComponentsBuilder, UriComponents, docs

After the latest changes, two small fixes in the clone method to copy
the encode flag, and in the encodeUriTemplate method to account for
possible null query params.

Improvements in the URI encoding section.

Issue: SPR-17039, SPR-17027
This commit is contained in:
Rossen Stoyanchev
2018-07-19 09:11:57 -04:00
parent 51c7ceb95d
commit 28cd6978b5
4 changed files with 81 additions and 33 deletions

View File

@@ -753,10 +753,10 @@ public class UriComponentsBuilderTests {
@Test
public void testClone() {
UriComponentsBuilder builder1 = UriComponentsBuilder.newInstance();
builder1.scheme("http").host("e1.com").path("/p1").pathSegment("ps1").queryParam("q1").fragment("f1");
builder1.scheme("http").host("e1.com").path("/p1").pathSegment("ps1").queryParam("q1").fragment("f1").encode();
UriComponentsBuilder builder2 = (UriComponentsBuilder) builder1.clone();
builder2.scheme("https").host("e2.com").path("p2").pathSegment("ps2").queryParam("q2").fragment("f2");
builder2.scheme("https").host("e2.com").path("p2").pathSegment("{ps2}").queryParam("q2").fragment("f2");
UriComponents result1 = builder1.build();
assertEquals("http", result1.getScheme());
@@ -765,10 +765,10 @@ public class UriComponentsBuilderTests {
assertEquals("q1", result1.getQuery());
assertEquals("f1", result1.getFragment());
UriComponents result2 = builder2.build();
UriComponents result2 = builder2.buildAndExpand("ps2;a");
assertEquals("https", result2.getScheme());
assertEquals("e2.com", result2.getHost());
assertEquals("/p1/ps1/p2/ps2", result2.getPath());
assertEquals("/p1/ps1/p2/ps2%3Ba", result2.getPath());
assertEquals("q1&q2", result2.getQuery());
assertEquals("f2", result2.getFragment());
}