SPR-6946 - RestTemplate should not encode fragments (#'s)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -99,6 +99,8 @@ public class UriUtilsTest {
|
||||
public void encodeUri() throws UnsupportedEncodingException {
|
||||
assertEquals("Invalid encoded URI", "http://www.ietf.org/rfc/rfc3986.txt",
|
||||
UriUtils.encodeUri("http://www.ietf.org/rfc/rfc3986.txt", ENC));
|
||||
assertEquals("Invalid encoded URI", "https://www.ietf.org/rfc/rfc3986.txt",
|
||||
UriUtils.encodeUri("https://www.ietf.org/rfc/rfc3986.txt", ENC));
|
||||
assertEquals("Invalid encoded URI", "http://www.google.com/?q=z%FCrich",
|
||||
UriUtils.encodeUri("http://www.google.com/?q=z\u00fcrich", ENC));
|
||||
assertEquals("Invalid encoded URI",
|
||||
@@ -117,8 +119,34 @@ public class UriUtilsTest {
|
||||
assertEquals("Invalid encoded URI", "../../../demo/jfc/SwingSet2/src/SwingSet2.java",
|
||||
UriUtils.encodeUri("../../../demo/jfc/SwingSet2/src/SwingSet2.java", ENC));
|
||||
assertEquals("Invalid encoded URI", "file:///~/calendar", UriUtils.encodeUri("file:///~/calendar", ENC));
|
||||
assertEquals("Invalid encoded URI", "http://example.com/query=foo@bar", UriUtils.encodeUri("http://example.com/query=foo@bar", ENC));
|
||||
assertEquals("Invalid encoded URI", "http://example.com/query=foo@bar",
|
||||
UriUtils.encodeUri("http://example.com/query=foo@bar", ENC));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encodeHttpUrl() throws UnsupportedEncodingException {
|
||||
assertEquals("Invalid encoded HTTP URL", "http://www.ietf.org/rfc/rfc3986.txt",
|
||||
UriUtils.encodeHttpUrl("http://www.ietf.org/rfc/rfc3986.txt", ENC));
|
||||
assertEquals("Invalid encoded URI", "https://www.ietf.org/rfc/rfc3986.txt",
|
||||
UriUtils.encodeHttpUrl("https://www.ietf.org/rfc/rfc3986.txt", ENC));
|
||||
assertEquals("Invalid encoded HTTP URL", "http://www.google.com/?q=z%FCrich",
|
||||
UriUtils.encodeHttpUrl("http://www.google.com/?q=z\u00fcrich", ENC));
|
||||
assertEquals("Invalid encoded HTTP URL",
|
||||
"http://arjen:foobar@java.sun.com:80/javase/6/docs/api/java/util/BitSet.html?foo=bar",
|
||||
UriUtils.encodeHttpUrl(
|
||||
"http://arjen:foobar@java.sun.com:80/javase/6/docs/api/java/util/BitSet.html?foo=bar", ENC));
|
||||
assertEquals("Invalid encoded HTTP URL", "http://search.twitter.com/search.atom?q=%23avatar",
|
||||
UriUtils.encodeHttpUrl("http://search.twitter.com/search.atom?q=#avatar", ENC));
|
||||
assertEquals("Invalid encoded HTTP URL", "http://java.sun.com/j2se/1.3/",
|
||||
UriUtils.encodeHttpUrl("http://java.sun.com/j2se/1.3/", ENC));
|
||||
assertEquals("Invalid encoded HTTP URL", "http://example.com/query=foo@bar",
|
||||
UriUtils.encodeHttpUrl("http://example.com/query=foo@bar", ENC));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void encodeHttpUrlMail() throws UnsupportedEncodingException {
|
||||
UriUtils.encodeHttpUrl("mailto:java-net@java.sun.com", ENC);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user