Search in sources :

Example 51 with URI

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));
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) URI(java.net.URI)

Example 52 with URI

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);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) URI(java.net.URI) Test(org.junit.Test)

Example 53 with URI

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());
}
Also used : URI(java.net.URI) Test(org.junit.Test)

Example 54 with URI

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)));
}
Also used : URI(java.net.URI) Test(org.junit.Test)

Example 55 with URI

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);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) FileSystem(org.apache.hadoop.fs.FileSystem) URI(java.net.URI) Test(org.junit.Test)

Aggregations

URI (java.net.URI)5680 Test (org.junit.Test)1852 URISyntaxException (java.net.URISyntaxException)1016 IOException (java.io.IOException)749 File (java.io.File)531 HashMap (java.util.HashMap)458 ArrayList (java.util.ArrayList)452 Test (org.testng.annotations.Test)394 Configuration (org.apache.hadoop.conf.Configuration)321 Path (org.apache.hadoop.fs.Path)267 URL (java.net.URL)266 Map (java.util.Map)262 Response (javax.ws.rs.core.Response)218 List (java.util.List)184 InputStream (java.io.InputStream)154 HashSet (java.util.HashSet)136 FileSystem (org.apache.hadoop.fs.FileSystem)135 RequestContext (com.linkedin.r2.message.RequestContext)129 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)128 RestRequest (com.linkedin.r2.message.rest.RestRequest)112