|
@@ -35,7 +35,7 @@ import java.security.PrivilegedExceptionAction;
|
|
|
import java.util.concurrent.Semaphore;
|
|
|
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
-
|
|
|
+import static junit.framework.Assert.assertTrue;
|
|
|
|
|
|
|
|
|
public class TestFileSystemCaching {
|
|
@@ -158,10 +158,27 @@ public class TestFileSystemCaching {
|
|
|
@Test
|
|
|
public void testUserFS() throws Exception {
|
|
|
final Configuration conf = new Configuration();
|
|
|
-
|
|
|
+ conf.set("fs.cachedfile.impl", conf.get("fs.file.impl"));
|
|
|
FileSystem fsU1 = FileSystem.get(new URI("cachedfile://a"), conf, "bar");
|
|
|
FileSystem fsU2 = FileSystem.get(new URI("cachedfile://a"), conf, "foo");
|
|
|
|
|
|
assertNotSame(fsU1, fsU2);
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testFsUniqueness() throws Exception {
|
|
|
+ final Configuration conf = new Configuration();
|
|
|
+ conf.set("fs.cachedfile.impl", conf.get("fs.file.impl"));
|
|
|
+ // multiple invocations of FileSystem.get return the same object.
|
|
|
+ FileSystem fs1 = FileSystem.get(conf);
|
|
|
+ FileSystem fs2 = FileSystem.get(conf);
|
|
|
+ assertTrue(fs1 == fs2);
|
|
|
+
|
|
|
+ // multiple invocations of FileSystem.newInstance return different objects
|
|
|
+ fs1 = FileSystem.newInstance(new URI("cachedfile://a"), conf, "bar");
|
|
|
+ fs2 = FileSystem.newInstance(new URI("cachedfile://a"), conf, "bar");
|
|
|
+ assertTrue(fs1 != fs2 && !fs1.equals(fs2));
|
|
|
+ fs1.close();
|
|
|
+ fs2.close();
|
|
|
+ }
|
|
|
}
|