SPR-5516: RestTemplate should encode the url variables

This commit is contained in:
Arjen Poutsma
2009-02-24 15:01:01 +00:00
parent 4c0edc2b9d
commit eb47a4b5be
2 changed files with 34 additions and 16 deletions

View File

@@ -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"));