SPR-5516: RestTemplate should encode the url variables

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@681 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Arjen Poutsma
2009-02-24 15:01:01 +00:00
parent 514f7871e8
commit 7b9343ac4f
2 changed files with 34 additions and 16 deletions
@@ -86,6 +86,16 @@ public class UriTemplateTests {
template.expand(uriVariables);
}
@Test
public void expandEncoded() throws Exception {
template = new UriTemplate("http://example.com/hotel list/{hotel}");
URI result = template.expand(Collections.singletonMap("hotel", "foo bar \u20AC"));
assertEquals("Invalid expanded template", new URI("http", "//example.com/hotel list/foo bar \u20AC", null),
result);
assertEquals("Invalid expanded template", "http://example.com/hotel%20list/foo%20bar%20%E2%82%AC",
result.toASCIIString());
}
@Test
public void matches() throws Exception {
assertTrue("UriTemplate does not match", template.matches("http://example.com/hotels/1/bookings/42"));