@Test public void toUriEncoded() throws URISyntaxException { 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 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 encode() { UriComponents uriComponents = UriComponentsBuilder.fromPath("/hotel list").build(); UriComponents encoded = uriComponents.encode(); assertEquals("/hotel%20list", encoded.getPath()); }