|
@@ -20,6 +20,7 @@ package org.apache.hadoop.hdfs.web;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.net.URI;
|
|
|
+import java.net.URISyntaxException;
|
|
|
import java.net.URL;
|
|
|
import java.util.Arrays;
|
|
|
|
|
@@ -55,6 +56,23 @@ public class TestWebHdfsUrl {
|
|
|
UserGroupInformation.setConfiguration(new Configuration());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Test(timeout=60000)
|
|
|
+ public void testEncodedPathUrl() throws IOException, URISyntaxException{
|
|
|
+ Configuration conf = new Configuration();
|
|
|
+
|
|
|
+ final WebHdfsFileSystem webhdfs = (WebHdfsFileSystem) FileSystem.get(
|
|
|
+ uri, conf);
|
|
|
+
|
|
|
+ // Construct a file path that contains percentage-encoded string
|
|
|
+ String pathName = "/hdtest010%2C60020%2C1371000602151.1371058984668";
|
|
|
+ Path fsPath = new Path(pathName);
|
|
|
+ URL encodedPathUrl = webhdfs.toUrl(PutOpParam.Op.CREATE, fsPath);
|
|
|
+ // We should get back the original file path after cycling back and decoding
|
|
|
+ Assert.assertEquals(WebHdfsFileSystem.PATH_PREFIX + pathName,
|
|
|
+ encodedPathUrl.toURI().getPath());
|
|
|
+ }
|
|
|
+
|
|
|
@Test(timeout=4000)
|
|
|
public void testSimpleAuthParamsInUrl() throws IOException {
|
|
|
Configuration conf = new Configuration();
|