use of java.net.URI in project hadoop by apache.
the class TestFilterFileSystem method checkInit.
private void checkInit(FilterFileSystem fs, boolean expectInit) throws Exception {
URI uri = URI.create("filter:/");
fs.initialize(uri, conf);
FileSystem embedFs = fs.getRawFileSystem();
if (expectInit) {
verify(embedFs, times(1)).initialize(eq(uri), eq(conf));
} else {
verify(embedFs, times(0)).initialize(any(URI.class), any(Configuration.class));
}
}
use of java.net.URI in project hadoop by apache.
the class TestLocalFileSystem method testStripFragmentFromPath.
@Test
public void testStripFragmentFromPath() throws Exception {
FileSystem fs = FileSystem.getLocal(new Configuration());
Path pathQualified = TEST_PATH.makeQualified(fs.getUri(), fs.getWorkingDirectory());
Path pathWithFragment = new Path(new URI(pathQualified.toString() + "#glacier"));
// Create test file with fragment
FileSystemTestHelper.createFile(fs, pathWithFragment);
Path resolved = fs.resolvePath(pathWithFragment);
assertEquals("resolvePath did not strip fragment from Path", pathQualified, resolved);
}
use of java.net.URI in project hadoop by apache.
the class TestPath method testReservedCharacters.
/** Test reserved characters in URIs (and therefore Paths) */
@Test(timeout = 30000)
public void testReservedCharacters() throws URISyntaxException, IOException {
// URI encodes the path
assertEquals("/foo%20bar", new URI(null, null, "/foo bar", null, null).getRawPath());
// URI#getPath decodes the path
assertEquals("/foo bar", new URI(null, null, "/foo bar", null, null).getPath());
// URI#toString returns an encoded path
assertEquals("/foo%20bar", new URI(null, null, "/foo bar", null, null).toString());
assertEquals("/foo%20bar", new Path("/foo bar").toUri().toString());
// Reserved chars are not encoded
assertEquals("/foo;bar", new URI("/foo;bar").getPath());
assertEquals("/foo;bar", new URI("/foo;bar").getRawPath());
assertEquals("/foo+bar", new URI("/foo+bar").getPath());
assertEquals("/foo+bar", new URI("/foo+bar").getRawPath());
// URI#getPath decodes the path part (and URL#getPath does not decode)
assertEquals("/foo bar", new Path("http://localhost/foo bar").toUri().getPath());
assertEquals("/foo%20bar", new Path("http://localhost/foo bar").toUri().toURL().getPath());
assertEquals("/foo?bar", new URI("http", "localhost", "/foo?bar", null, null).getPath());
assertEquals("/foo%3Fbar", new URI("http", "localhost", "/foo?bar", null, null).toURL().getPath());
}
use of java.net.URI in project hadoop by apache.
the class TestPath method testMakeQualified.
@Test(timeout = 30000)
public void testMakeQualified() throws URISyntaxException {
URI defaultUri = new URI("hdfs://host1/dir1");
URI wd = new URI("hdfs://host2/dir2");
// The scheme from defaultUri is used but the path part is not
assertEquals(new Path("hdfs://host1/dir/file"), new Path("file").makeQualified(defaultUri, new Path("/dir")));
// The defaultUri is only used if the path + wd has no scheme
assertEquals(new Path("hdfs://host2/dir2/file"), new Path("file").makeQualified(defaultUri, new Path(wd)));
}
use of java.net.URI in project hadoop by apache.
the class TestFileSystemCaching method testCacheDisabled.
@Test
public void testCacheDisabled() throws Exception {
Configuration conf = new Configuration();
conf.set("fs.uncachedfile.impl", FileSystem.getFileSystemClass("file", null).getName());
conf.setBoolean("fs.uncachedfile.impl.disable.cache", true);
FileSystem fs1 = FileSystem.get(new URI("uncachedfile://a"), conf);
FileSystem fs2 = FileSystem.get(new URI("uncachedfile://a"), conf);
assertNotSame(fs1, fs2);
}
Aggregations