@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 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 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()); }