UriComponentsBuilder copies query params through MultiValueMap.addAll

Issue: SPR-17256
This commit is contained in:
Juergen Hoeller
2018-09-11 15:15:15 +02:00
parent 658bd7a686
commit 1d58fac54d
3 changed files with 23 additions and 5 deletions

View File

@@ -36,13 +36,15 @@ import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
/**
* Unit tests for {@link org.springframework.web.util.UriComponentsBuilder}.
* Unit tests for {@link UriComponentsBuilder}.
*
* @author Arjen Poutsma
* @author Rossen Stoyanchev
* @author Phillip Webb
* @author Oliver Gierke
* @author David Eckel
* @author Juergen Hoeller
* @author Sam Brannen
* @author David Eckel
*/
public class UriComponentsBuilderTests {
@@ -902,9 +904,19 @@ public class UriComponentsBuilderTests {
public void uriComponentsNotEqualAfterNormalization() {
UriComponents uri1 = UriComponentsBuilder.fromUriString("http://test.com").build().normalize();
UriComponents uri2 = UriComponentsBuilder.fromUriString("http://test.com/").build();
assertTrue(uri1.getPathSegments().isEmpty());
assertTrue(uri2.getPathSegments().isEmpty());
assertNotEquals(uri1, uri2);
}
@Test // SPR-17256
public void uriComponentsWithMergedQueryParams() {
String uri = UriComponentsBuilder.fromUriString("http://localhost:8081")
.uriComponents(UriComponentsBuilder.fromUriString("/{path}?sort={sort}").build())
.queryParam("sort", "another_value").build().toString();
assertEquals("http://localhost:8081/{path}?sort={sort}&sort=another_value", uri);
}
}