Polish
Issue: SPR-10539
This commit is contained in:
@@ -173,8 +173,7 @@ public class UriComponentsBuilderTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void fromHttpUrlStringInvalidIPv6Host() throws URISyntaxException {
|
||||
UriComponents result = UriComponentsBuilder
|
||||
.fromHttpUrl("http://[1abc:2abc:3abc::5ABC:6abc:8080/resource").build().encode();
|
||||
UriComponentsBuilder.fromHttpUrl("http://[1abc:2abc:3abc::5ABC:6abc:8080/resource").build().encode();
|
||||
}
|
||||
|
||||
// SPR-10539
|
||||
@@ -183,15 +182,15 @@ public class UriComponentsBuilderTests {
|
||||
public void fromUriStringIPv6Host() throws URISyntaxException {
|
||||
UriComponents result = UriComponentsBuilder
|
||||
.fromUriString("http://[1abc:2abc:3abc::5ABC:6abc]:8080/resource").build().encode();
|
||||
assertEquals("[1abc:2abc:3abc::5ABC:6abc]",result.getHost());
|
||||
assertEquals("[1abc:2abc:3abc::5ABC:6abc]", result.getHost());
|
||||
|
||||
UriComponents resultWithScopeId = UriComponentsBuilder
|
||||
.fromUriString("http://[1abc:2abc:3abc::5ABC:6abc%eth0]:8080/resource").build().encode();
|
||||
assertEquals("[1abc:2abc:3abc::5ABC:6abc%25eth0]",resultWithScopeId.getHost());
|
||||
assertEquals("[1abc:2abc:3abc::5ABC:6abc%25eth0]", resultWithScopeId.getHost());
|
||||
|
||||
UriComponents resultIPv4compatible = UriComponentsBuilder
|
||||
.fromUriString("http://[::192.168.1.1]:8080/resource").build().encode();
|
||||
assertEquals("[::192.168.1.1]",resultIPv4compatible.getHost());
|
||||
assertEquals("[::192.168.1.1]", resultIPv4compatible.getHost());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -25,9 +25,7 @@ import java.net.URISyntaxException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
@@ -45,20 +43,38 @@ public class UriComponentsTests {
|
||||
|
||||
@Test
|
||||
public void toUriEncoded() throws URISyntaxException {
|
||||
UriComponents uriComponents = UriComponentsBuilder.fromUriString("http://example.com/hotel list/Z\u00fcrich").build();
|
||||
UriComponents uriComponents = UriComponentsBuilder.fromUriString(
|
||||
"http://example.com/hotel list/Z\u00fcrich").build();
|
||||
assertEquals(new URI("http://example.com/hotel%20list/Z%C3%BCrich"), uriComponents.encode().toUri());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toUriNotEncoded() throws URISyntaxException {
|
||||
UriComponents uriComponents = UriComponentsBuilder.fromUriString(
|
||||
"http://example.com/hotel list/Z\u00fcrich").build();
|
||||
assertEquals(new URI("http://example.com/hotel%20list/Z\u00fcrich"), uriComponents.toUri());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toUriAlreadyEncoded() throws URISyntaxException {
|
||||
UriComponents uriComponents = UriComponentsBuilder.fromUriString(
|
||||
"http://example.com/hotel%20list/Z%C3%BCrich").build(true);
|
||||
UriComponents encoded = uriComponents.encode();
|
||||
assertEquals(new URI("http://example.com/hotel%20list/Z%C3%BCrich"), encoded.toUri());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toUriNotEncoded() throws URISyntaxException {
|
||||
UriComponents uriComponents = UriComponentsBuilder.fromUriString("http://example.com/hotel list/Z\u00fcrich").build();
|
||||
assertEquals(new URI("http://example.com/hotel%20list/Z\u00fcrich"), uriComponents.toUri());
|
||||
public void toUriWithIpv6HostAlreadyEncoded() throws URISyntaxException {
|
||||
UriComponents uriComponents = UriComponentsBuilder.fromUriString(
|
||||
"http://[1abc:2abc:3abc::5ABC:6abc]:8080/hotel%20list/Z%C3%BCrich").build(true);
|
||||
UriComponents encoded = uriComponents.encode();
|
||||
assertEquals(new URI("http://[1abc:2abc:3abc::5ABC:6abc]:8080/hotel%20list/Z%C3%BCrich"), encoded.toUri());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void expand() {
|
||||
UriComponents uriComponents = UriComponentsBuilder.fromUriString("http://example.com").path("/{foo} {bar}").build();
|
||||
UriComponents uriComponents = UriComponentsBuilder.fromUriString(
|
||||
"http://example.com").path("/{foo} {bar}").build();
|
||||
uriComponents = uriComponents.expand("1 2", "3 4");
|
||||
assertEquals("/1 2 3 4", uriComponents.getPath());
|
||||
assertEquals("http://example.com/1 2 3 4", uriComponents.toUriString());
|
||||
|
||||
Reference in New Issue
Block a user