|
@@ -17,14 +17,10 @@
|
|
|
*/
|
|
|
package org.apache.hadoop.fs.viewfs;
|
|
|
|
|
|
-
|
|
|
-import java.io.IOException;
|
|
|
-
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
|
import org.apache.hadoop.fs.FileSystemTestHelper;
|
|
|
import org.apache.hadoop.fs.FsConstants;
|
|
|
-import org.apache.hadoop.fs.LocalFileSystem;
|
|
|
import org.apache.hadoop.fs.Path;
|
|
|
import org.apache.hadoop.fs.TestTrash;
|
|
|
import org.junit.After;
|
|
@@ -35,31 +31,26 @@ public class TestViewFsTrash {
|
|
|
FileSystem fsTarget; // the target file system - the mount will point here
|
|
|
FileSystem fsView;
|
|
|
Configuration conf;
|
|
|
- FileSystemTestHelper fileSystemTestHelper = new FileSystemTestHelper();
|
|
|
-
|
|
|
- class TestLFS extends LocalFileSystem {
|
|
|
- Path home;
|
|
|
- TestLFS() throws IOException {
|
|
|
- this(new Path(fileSystemTestHelper.getTestRootDir()));
|
|
|
- }
|
|
|
- TestLFS(Path home) throws IOException {
|
|
|
- super();
|
|
|
- this.home = home;
|
|
|
- }
|
|
|
- @Override
|
|
|
- public Path getHomeDirectory() {
|
|
|
- return home;
|
|
|
- }
|
|
|
- }
|
|
|
+ private FileSystemTestHelper fileSystemTestHelper;
|
|
|
|
|
|
@Before
|
|
|
public void setUp() throws Exception {
|
|
|
- fsTarget = FileSystem.getLocal(new Configuration());
|
|
|
- fsTarget.mkdirs(new Path(fileSystemTestHelper.
|
|
|
- getTestRootPath(fsTarget), "dir1"));
|
|
|
+ Configuration targetFSConf = new Configuration();
|
|
|
+ targetFSConf.setClass("fs.file.impl", TestTrash.TestLFS.class, FileSystem.class);
|
|
|
+
|
|
|
+ fsTarget = FileSystem.getLocal(targetFSConf);
|
|
|
+ fileSystemTestHelper = new FileSystemTestHelper(fsTarget.getHomeDirectory().toUri().getPath());
|
|
|
+
|
|
|
conf = ViewFileSystemTestSetup.createConfig();
|
|
|
fsView = ViewFileSystemTestSetup.setupForViewFileSystem(conf, fileSystemTestHelper, fsTarget);
|
|
|
conf.set("fs.defaultFS", FsConstants.VIEWFS_URI.toString());
|
|
|
+
|
|
|
+ /*
|
|
|
+ * Need to set the fs.file.impl to TestViewFsTrash.TestLFS. Otherwise, it will load
|
|
|
+ * LocalFileSystem implementation which uses System.getProperty("user.home") for homeDirectory.
|
|
|
+ */
|
|
|
+ conf.setClass("fs.file.impl", TestTrash.TestLFS.class, FileSystem.class);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@After
|
|
@@ -70,9 +61,9 @@ public class TestViewFsTrash {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void testTrash() throws IOException {
|
|
|
+ public void testTrash() throws Exception {
|
|
|
TestTrash.trashShell(conf, fileSystemTestHelper.getTestRootPath(fsView),
|
|
|
- fsTarget, new Path(fsTarget.getHomeDirectory(), ".Trash/Current"));
|
|
|
+ fsView, new Path(fileSystemTestHelper.getTestRootPath(fsView), ".Trash/Current"));
|
|
|
}
|
|
|
|
|
|
}
|