Unit test with assertion for merged query params
Issue: SPR-17256
This commit is contained in:
parent
c06b9525ac
commit
28208310dc
|
|
@ -36,13 +36,15 @@ import static org.hamcrest.Matchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for {@link org.springframework.web.util.UriComponentsBuilder}.
|
* Unit tests for {@link UriComponentsBuilder}.
|
||||||
*
|
*
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
|
* @author Rossen Stoyanchev
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
* @author David Eckel
|
* @author Juergen Hoeller
|
||||||
* @author Sam Brannen
|
* @author Sam Brannen
|
||||||
|
* @author David Eckel
|
||||||
*/
|
*/
|
||||||
public class UriComponentsBuilderTests {
|
public class UriComponentsBuilderTests {
|
||||||
|
|
||||||
|
|
@ -917,16 +919,19 @@ public class UriComponentsBuilderTests {
|
||||||
public void uriComponentsNotEqualAfterNormalization() {
|
public void uriComponentsNotEqualAfterNormalization() {
|
||||||
UriComponents uri1 = UriComponentsBuilder.fromUriString("http://test.com").build().normalize();
|
UriComponents uri1 = UriComponentsBuilder.fromUriString("http://test.com").build().normalize();
|
||||||
UriComponents uri2 = UriComponentsBuilder.fromUriString("http://test.com/").build();
|
UriComponents uri2 = UriComponentsBuilder.fromUriString("http://test.com/").build();
|
||||||
|
|
||||||
assertTrue(uri1.getPathSegments().isEmpty());
|
assertTrue(uri1.getPathSegments().isEmpty());
|
||||||
assertTrue(uri2.getPathSegments().isEmpty());
|
assertTrue(uri2.getPathSegments().isEmpty());
|
||||||
assertNotEquals(uri1, uri2);
|
assertNotEquals(uri1, uri2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-17256
|
@Test // SPR-17256
|
||||||
public void uriComponentsWithQueryParamClone() {
|
public void uriComponentsWithMergedQueryParams() {
|
||||||
UriComponentsBuilder.fromUriString("http://localhost:8081")
|
String uri = UriComponentsBuilder.fromUriString("http://localhost:8081")
|
||||||
.uriComponents(UriComponentsBuilder.fromUriString("/{path}?sort={sort}").build())
|
.uriComponents(UriComponentsBuilder.fromUriString("/{path}?sort={sort}").build())
|
||||||
.queryParam("sort", "another_value").build();
|
.queryParam("sort", "another_value").build().toString();
|
||||||
|
|
||||||
|
assertEquals("http://localhost:8081/{path}?sort={sort}&sort=another_value", uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue