diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsUrl.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsUrl.java index 02a68ea0245..6733555b15e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsUrl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsUrl.java @@ -469,4 +469,18 @@ public class TestWebHdfsUrl { } } + @Test + public void testWebHdfsUrlEncoding() throws Exception { + final WebHdfsFileSystem fs = + (WebHdfsFileSystem) FileSystem.get(uri, WebHdfsTestUtil.createConf()); + + // characters which should not be urlencoded. + final String unreserved = "_-!.~'()*"; + final String punct = ",:$&="; + String path = "/testWebHdfsUrlEncoding" + unreserved + punct; + URL url = + WebHdfsTestUtil.toUrl(fs, GetOpParam.Op.LISTSTATUS, new Path(path)); + WebHdfsTestUtil.LOG.info(url.getPath()); + assertEquals(WebHdfsFileSystem.PATH_PREFIX + path, url.getPath()); + } }