Skip to content

Commit

Permalink
Reuse TestLFS from TestTrash
Browse files Browse the repository at this point in the history
Thanks Konstantin for the suggestion!
  • Loading branch information
Xing Lin committed Oct 13, 2021
1 parent e747b47 commit 207c4f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ public void tearDown() throws IOException {
}
}

static class TestLFS extends LocalFileSystem {
public static class TestLFS extends LocalFileSystem {
private URI uriName = null;
Path home;
TestLFS() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,40 +36,15 @@ public class TestViewFsTrash {
FileSystem fsTarget; // the target file system - the mount will point here
FileSystem fsView;
Configuration conf;
private static FileSystemTestHelper fileSystemTestHelper = new FileSystemTestHelper();

static class TestLFS extends LocalFileSystem {
Path home;
TestLFS() throws IOException {
this(new Path(fileSystemTestHelper.getTestRootDir()));
}
TestLFS(Path home) throws IOException {

super(new RawLocalFileSystem() {
@Override
protected Path getInitialWorkingDirectory() {
return makeQualified(home);
}

@Override
public Path getHomeDirectory() {
return makeQualified(home);
}
});
this.home = home;
}
@Override
public Path getHomeDirectory() {
return home;
}
}
private FileSystemTestHelper fileSystemTestHelper;

@Before
public void setUp() throws Exception {
Configuration targetFSConf = new Configuration();
targetFSConf.setClass("fs.file.impl", TestViewFsTrash.TestLFS.class, FileSystem.class);
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);
Expand All @@ -79,7 +54,7 @@ public void setUp() throws Exception {
* 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", TestViewFsTrash.TestLFS.class, FileSystem.class);
conf.setClass("fs.file.impl", TestTrash.TestLFS.class, FileSystem.class);

}

Expand Down

0 comments on commit 207c4f2

Please sign in to comment.