|
@@ -23,6 +23,12 @@ import java.net.URI;
|
|
import java.util.EnumSet;
|
|
import java.util.EnumSet;
|
|
|
|
|
|
import static org.apache.hadoop.fs.FileContextTestHelper.*;
|
|
import static org.apache.hadoop.fs.FileContextTestHelper.*;
|
|
|
|
+import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
|
+import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
|
+import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
|
|
+import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
|
|
+import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
|
+import static org.junit.jupiter.api.Assertions.fail;
|
|
|
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.fs.AbstractFileSystem;
|
|
import org.apache.hadoop.fs.AbstractFileSystem;
|
|
@@ -33,10 +39,10 @@ import org.apache.hadoop.fs.FileStatus;
|
|
import org.apache.hadoop.fs.FsConstants;
|
|
import org.apache.hadoop.fs.FsConstants;
|
|
import org.apache.hadoop.fs.Path;
|
|
import org.apache.hadoop.fs.Path;
|
|
import org.apache.hadoop.fs.viewfs.ChRootedFs;
|
|
import org.apache.hadoop.fs.viewfs.ChRootedFs;
|
|
-import org.junit.After;
|
|
|
|
-import org.junit.Assert;
|
|
|
|
-import org.junit.Before;
|
|
|
|
-import org.junit.Test;
|
|
|
|
|
|
+import org.junit.jupiter.api.AfterEach;
|
|
|
|
+import org.junit.jupiter.api.BeforeEach;
|
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
|
+import org.junit.jupiter.api.Timeout;
|
|
import org.mockito.Mockito;
|
|
import org.mockito.Mockito;
|
|
|
|
|
|
public class TestChRootedFs {
|
|
public class TestChRootedFs {
|
|
@@ -45,7 +51,7 @@ public class TestChRootedFs {
|
|
FileContext fcTarget; //
|
|
FileContext fcTarget; //
|
|
Path chrootedTo;
|
|
Path chrootedTo;
|
|
|
|
|
|
- @Before
|
|
|
|
|
|
+ @BeforeEach
|
|
public void setUp() throws Exception {
|
|
public void setUp() throws Exception {
|
|
// create the test root on local_fs
|
|
// create the test root on local_fs
|
|
fcTarget = FileContext.getLocalFSFileContext();
|
|
fcTarget = FileContext.getLocalFSFileContext();
|
|
@@ -62,7 +68,7 @@ public class TestChRootedFs {
|
|
new ChRootedFs(fcTarget.getDefaultFileSystem(), chrootedTo), conf);
|
|
new ChRootedFs(fcTarget.getDefaultFileSystem(), chrootedTo), conf);
|
|
}
|
|
}
|
|
|
|
|
|
- @After
|
|
|
|
|
|
+ @AfterEach
|
|
public void tearDown() throws Exception {
|
|
public void tearDown() throws Exception {
|
|
fcTarget.delete(chrootedTo, true);
|
|
fcTarget.delete(chrootedTo, true);
|
|
}
|
|
}
|
|
@@ -71,11 +77,11 @@ public class TestChRootedFs {
|
|
@Test
|
|
@Test
|
|
public void testBasicPaths() {
|
|
public void testBasicPaths() {
|
|
URI uri = fc.getDefaultFileSystem().getUri();
|
|
URI uri = fc.getDefaultFileSystem().getUri();
|
|
- Assert.assertEquals(chrootedTo.toUri(), uri);
|
|
|
|
- Assert.assertEquals(fc.makeQualified(
|
|
|
|
|
|
+ assertEquals(chrootedTo.toUri(), uri);
|
|
|
|
+ assertEquals(fc.makeQualified(
|
|
new Path(System.getProperty("user.home"))),
|
|
new Path(System.getProperty("user.home"))),
|
|
fc.getWorkingDirectory());
|
|
fc.getWorkingDirectory());
|
|
- Assert.assertEquals(fc.makeQualified(
|
|
|
|
|
|
+ assertEquals(fc.makeQualified(
|
|
new Path(System.getProperty("user.home"))),
|
|
new Path(System.getProperty("user.home"))),
|
|
fc.getHomeDirectory());
|
|
fc.getHomeDirectory());
|
|
/*
|
|
/*
|
|
@@ -85,13 +91,13 @@ public class TestChRootedFs {
|
|
* But if we were to fix Path#makeQualified() then the next test should
|
|
* But if we were to fix Path#makeQualified() then the next test should
|
|
* have been:
|
|
* have been:
|
|
|
|
|
|
- Assert.assertEquals(
|
|
|
|
|
|
+ assertEquals(
|
|
new Path(chrootedTo + "/foo/bar").makeQualified(
|
|
new Path(chrootedTo + "/foo/bar").makeQualified(
|
|
FsConstants.LOCAL_FS_URI, null),
|
|
FsConstants.LOCAL_FS_URI, null),
|
|
fc.makeQualified(new Path( "/foo/bar")));
|
|
fc.makeQualified(new Path( "/foo/bar")));
|
|
*/
|
|
*/
|
|
|
|
|
|
- Assert.assertEquals(
|
|
|
|
|
|
+ assertEquals(
|
|
new Path("/foo/bar").makeQualified(FsConstants.LOCAL_FS_URI, null),
|
|
new Path("/foo/bar").makeQualified(FsConstants.LOCAL_FS_URI, null),
|
|
fc.makeQualified(new Path("/foo/bar")));
|
|
fc.makeQualified(new Path("/foo/bar")));
|
|
}
|
|
}
|
|
@@ -109,50 +115,50 @@ public class TestChRootedFs {
|
|
|
|
|
|
// Create file
|
|
// Create file
|
|
fileContextTestHelper.createFileNonRecursive(fc, "/foo");
|
|
fileContextTestHelper.createFileNonRecursive(fc, "/foo");
|
|
- Assert.assertTrue(isFile(fc, new Path("/foo")));
|
|
|
|
- Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo, "foo")));
|
|
|
|
|
|
+ assertTrue(isFile(fc, new Path("/foo")));
|
|
|
|
+ assertTrue(isFile(fcTarget, new Path(chrootedTo, "foo")));
|
|
|
|
|
|
// Create file with recursive dir
|
|
// Create file with recursive dir
|
|
fileContextTestHelper.createFile(fc, "/newDir/foo");
|
|
fileContextTestHelper.createFile(fc, "/newDir/foo");
|
|
- Assert.assertTrue(isFile(fc, new Path("/newDir/foo")));
|
|
|
|
- Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo,"newDir/foo")));
|
|
|
|
|
|
+ assertTrue(isFile(fc, new Path("/newDir/foo")));
|
|
|
|
+ assertTrue(isFile(fcTarget, new Path(chrootedTo, "newDir/foo")));
|
|
|
|
|
|
// Delete the created file
|
|
// Delete the created file
|
|
- Assert.assertTrue(fc.delete(new Path("/newDir/foo"), false));
|
|
|
|
- Assert.assertFalse(exists(fc, new Path("/newDir/foo")));
|
|
|
|
- Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"newDir/foo")));
|
|
|
|
|
|
+ assertTrue(fc.delete(new Path("/newDir/foo"), false));
|
|
|
|
+ assertFalse(exists(fc, new Path("/newDir/foo")));
|
|
|
|
+ assertFalse(exists(fcTarget, new Path(chrootedTo, "newDir/foo")));
|
|
|
|
|
|
// Create file with a 2 component dirs recursively
|
|
// Create file with a 2 component dirs recursively
|
|
fileContextTestHelper.createFile(fc, "/newDir/newDir2/foo");
|
|
fileContextTestHelper.createFile(fc, "/newDir/newDir2/foo");
|
|
- Assert.assertTrue(isFile(fc, new Path("/newDir/newDir2/foo")));
|
|
|
|
- Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo,"newDir/newDir2/foo")));
|
|
|
|
|
|
+ assertTrue(isFile(fc, new Path("/newDir/newDir2/foo")));
|
|
|
|
+ assertTrue(isFile(fcTarget, new Path(chrootedTo, "newDir/newDir2/foo")));
|
|
|
|
|
|
// Delete the created file
|
|
// Delete the created file
|
|
- Assert.assertTrue(fc.delete(new Path("/newDir/newDir2/foo"), false));
|
|
|
|
- Assert.assertFalse(exists(fc, new Path("/newDir/newDir2/foo")));
|
|
|
|
- Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"newDir/newDir2/foo")));
|
|
|
|
|
|
+ assertTrue(fc.delete(new Path("/newDir/newDir2/foo"), false));
|
|
|
|
+ assertFalse(exists(fc, new Path("/newDir/newDir2/foo")));
|
|
|
|
+ assertFalse(exists(fcTarget, new Path(chrootedTo, "newDir/newDir2/foo")));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testMkdirDelete() throws IOException {
|
|
public void testMkdirDelete() throws IOException {
|
|
fc.mkdir(fileContextTestHelper.getTestRootPath(fc, "/dirX"), FileContext.DEFAULT_PERM, false);
|
|
fc.mkdir(fileContextTestHelper.getTestRootPath(fc, "/dirX"), FileContext.DEFAULT_PERM, false);
|
|
- Assert.assertTrue(isDir(fc, new Path("/dirX")));
|
|
|
|
- Assert.assertTrue(isDir(fcTarget, new Path(chrootedTo,"dirX")));
|
|
|
|
|
|
+ assertTrue(isDir(fc, new Path("/dirX")));
|
|
|
|
+ assertTrue(isDir(fcTarget, new Path(chrootedTo, "dirX")));
|
|
|
|
|
|
fc.mkdir(fileContextTestHelper.getTestRootPath(fc, "/dirX/dirY"), FileContext.DEFAULT_PERM, false);
|
|
fc.mkdir(fileContextTestHelper.getTestRootPath(fc, "/dirX/dirY"), FileContext.DEFAULT_PERM, false);
|
|
- Assert.assertTrue(isDir(fc, new Path("/dirX/dirY")));
|
|
|
|
- Assert.assertTrue(isDir(fcTarget, new Path(chrootedTo,"dirX/dirY")));
|
|
|
|
|
|
+ assertTrue(isDir(fc, new Path("/dirX/dirY")));
|
|
|
|
+ assertTrue(isDir(fcTarget, new Path(chrootedTo, "dirX/dirY")));
|
|
|
|
|
|
|
|
|
|
// Delete the created dir
|
|
// Delete the created dir
|
|
- Assert.assertTrue(fc.delete(new Path("/dirX/dirY"), false));
|
|
|
|
- Assert.assertFalse(exists(fc, new Path("/dirX/dirY")));
|
|
|
|
- Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"dirX/dirY")));
|
|
|
|
|
|
+ assertTrue(fc.delete(new Path("/dirX/dirY"), false));
|
|
|
|
+ assertFalse(exists(fc, new Path("/dirX/dirY")));
|
|
|
|
+ assertFalse(exists(fcTarget, new Path(chrootedTo, "dirX/dirY")));
|
|
|
|
|
|
- Assert.assertTrue(fc.delete(new Path("/dirX"), false));
|
|
|
|
- Assert.assertFalse(exists(fc, new Path("/dirX")));
|
|
|
|
- Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"dirX")));
|
|
|
|
|
|
+ assertTrue(fc.delete(new Path("/dirX"), false));
|
|
|
|
+ assertFalse(exists(fc, new Path("/dirX")));
|
|
|
|
+ assertFalse(exists(fcTarget, new Path(chrootedTo, "dirX")));
|
|
|
|
|
|
}
|
|
}
|
|
@Test
|
|
@Test
|
|
@@ -160,23 +166,23 @@ public class TestChRootedFs {
|
|
// Rename a file
|
|
// Rename a file
|
|
fileContextTestHelper.createFile(fc, "/newDir/foo");
|
|
fileContextTestHelper.createFile(fc, "/newDir/foo");
|
|
fc.rename(new Path("/newDir/foo"), new Path("/newDir/fooBar"));
|
|
fc.rename(new Path("/newDir/foo"), new Path("/newDir/fooBar"));
|
|
- Assert.assertFalse(exists(fc, new Path("/newDir/foo")));
|
|
|
|
- Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"newDir/foo")));
|
|
|
|
- Assert.assertTrue(isFile(fc, fileContextTestHelper.getTestRootPath(fc,"/newDir/fooBar")));
|
|
|
|
- Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo,"newDir/fooBar")));
|
|
|
|
|
|
+ assertFalse(exists(fc, new Path("/newDir/foo")));
|
|
|
|
+ assertFalse(exists(fcTarget, new Path(chrootedTo, "newDir/foo")));
|
|
|
|
+ assertTrue(isFile(fc, fileContextTestHelper.getTestRootPath(fc, "/newDir/fooBar")));
|
|
|
|
+ assertTrue(isFile(fcTarget, new Path(chrootedTo, "newDir/fooBar")));
|
|
|
|
|
|
|
|
|
|
// Rename a dir
|
|
// Rename a dir
|
|
fc.mkdir(new Path("/newDir/dirFoo"), FileContext.DEFAULT_PERM, false);
|
|
fc.mkdir(new Path("/newDir/dirFoo"), FileContext.DEFAULT_PERM, false);
|
|
fc.rename(new Path("/newDir/dirFoo"), new Path("/newDir/dirFooBar"));
|
|
fc.rename(new Path("/newDir/dirFoo"), new Path("/newDir/dirFooBar"));
|
|
- Assert.assertFalse(exists(fc, new Path("/newDir/dirFoo")));
|
|
|
|
- Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"newDir/dirFoo")));
|
|
|
|
- Assert.assertTrue(isDir(fc, fileContextTestHelper.getTestRootPath(fc,"/newDir/dirFooBar")));
|
|
|
|
- Assert.assertTrue(isDir(fcTarget, new Path(chrootedTo,"newDir/dirFooBar")));
|
|
|
|
|
|
+ assertFalse(exists(fc, new Path("/newDir/dirFoo")));
|
|
|
|
+ assertFalse(exists(fcTarget, new Path(chrootedTo, "newDir/dirFoo")));
|
|
|
|
+ assertTrue(isDir(fc, fileContextTestHelper.getTestRootPath(fc, "/newDir/dirFooBar")));
|
|
|
|
+ assertTrue(isDir(fcTarget, new Path(chrootedTo, "newDir/dirFooBar")));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
|
+ /*
|
|
* We would have liked renames across file system to fail but
|
|
* We would have liked renames across file system to fail but
|
|
* Unfortunately there is not way to distinguish the two file systems
|
|
* Unfortunately there is not way to distinguish the two file systems
|
|
* @throws IOException
|
|
* @throws IOException
|
|
@@ -193,15 +199,15 @@ public class TestChRootedFs {
|
|
public void testList() throws IOException {
|
|
public void testList() throws IOException {
|
|
|
|
|
|
FileStatus fs = fc.getFileStatus(new Path("/"));
|
|
FileStatus fs = fc.getFileStatus(new Path("/"));
|
|
- Assert.assertTrue(fs.isDirectory());
|
|
|
|
|
|
+ assertTrue(fs.isDirectory());
|
|
// should return the full path not the chrooted path
|
|
// should return the full path not the chrooted path
|
|
- Assert.assertEquals(fs.getPath(), chrootedTo);
|
|
|
|
|
|
+ assertEquals(fs.getPath(), chrootedTo);
|
|
|
|
|
|
// list on Slash
|
|
// list on Slash
|
|
|
|
|
|
FileStatus[] dirPaths = fc.util().listStatus(new Path("/"));
|
|
FileStatus[] dirPaths = fc.util().listStatus(new Path("/"));
|
|
|
|
|
|
- Assert.assertEquals(0, dirPaths.length);
|
|
|
|
|
|
+ assertEquals(0, dirPaths.length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -213,21 +219,21 @@ public class TestChRootedFs {
|
|
fc.mkdir(new Path("/dirX/dirXX"), FileContext.DEFAULT_PERM, false);
|
|
fc.mkdir(new Path("/dirX/dirXX"), FileContext.DEFAULT_PERM, false);
|
|
|
|
|
|
dirPaths = fc.util().listStatus(new Path("/"));
|
|
dirPaths = fc.util().listStatus(new Path("/"));
|
|
- Assert.assertEquals(4, dirPaths.length);
|
|
|
|
|
|
+ assertEquals(4, dirPaths.length);
|
|
|
|
|
|
// Note the the file status paths are the full paths on target
|
|
// Note the the file status paths are the full paths on target
|
|
fs = fileContextTestHelper.containsPath(fcTarget, "foo", dirPaths);
|
|
fs = fileContextTestHelper.containsPath(fcTarget, "foo", dirPaths);
|
|
- Assert.assertNotNull(fs);
|
|
|
|
- Assert.assertTrue(fs.isFile());
|
|
|
|
|
|
+ assertNotNull(fs);
|
|
|
|
+ assertTrue(fs.isFile());
|
|
fs = fileContextTestHelper.containsPath(fcTarget, "bar", dirPaths);
|
|
fs = fileContextTestHelper.containsPath(fcTarget, "bar", dirPaths);
|
|
- Assert.assertNotNull(fs);
|
|
|
|
- Assert.assertTrue(fs.isFile());
|
|
|
|
|
|
+ assertNotNull(fs);
|
|
|
|
+ assertTrue(fs.isFile());
|
|
fs = fileContextTestHelper.containsPath(fcTarget, "dirX", dirPaths);
|
|
fs = fileContextTestHelper.containsPath(fcTarget, "dirX", dirPaths);
|
|
- Assert.assertNotNull(fs);
|
|
|
|
- Assert.assertTrue(fs.isDirectory());
|
|
|
|
|
|
+ assertNotNull(fs);
|
|
|
|
+ assertTrue(fs.isDirectory());
|
|
fs = fileContextTestHelper.containsPath(fcTarget, "dirY", dirPaths);
|
|
fs = fileContextTestHelper.containsPath(fcTarget, "dirY", dirPaths);
|
|
- Assert.assertNotNull(fs);
|
|
|
|
- Assert.assertTrue(fs.isDirectory());
|
|
|
|
|
|
+ assertNotNull(fs);
|
|
|
|
+ assertTrue(fs.isDirectory());
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -238,13 +244,13 @@ public class TestChRootedFs {
|
|
Path workDir = new Path("/testWd");
|
|
Path workDir = new Path("/testWd");
|
|
Path fqWd = fc.makeQualified(workDir);
|
|
Path fqWd = fc.makeQualified(workDir);
|
|
fc.setWorkingDirectory(workDir);
|
|
fc.setWorkingDirectory(workDir);
|
|
- Assert.assertEquals(fqWd, fc.getWorkingDirectory());
|
|
|
|
|
|
+ assertEquals(fqWd, fc.getWorkingDirectory());
|
|
|
|
|
|
fc.setWorkingDirectory(new Path("."));
|
|
fc.setWorkingDirectory(new Path("."));
|
|
- Assert.assertEquals(fqWd, fc.getWorkingDirectory());
|
|
|
|
|
|
+ assertEquals(fqWd, fc.getWorkingDirectory());
|
|
|
|
|
|
fc.setWorkingDirectory(new Path(".."));
|
|
fc.setWorkingDirectory(new Path(".."));
|
|
- Assert.assertEquals(fqWd.getParent(), fc.getWorkingDirectory());
|
|
|
|
|
|
+ assertEquals(fqWd.getParent(), fc.getWorkingDirectory());
|
|
|
|
|
|
// cd using a relative path
|
|
// cd using a relative path
|
|
|
|
|
|
@@ -252,20 +258,20 @@ public class TestChRootedFs {
|
|
workDir = new Path("/testWd");
|
|
workDir = new Path("/testWd");
|
|
fqWd = fc.makeQualified(workDir);
|
|
fqWd = fc.makeQualified(workDir);
|
|
fc.setWorkingDirectory(workDir);
|
|
fc.setWorkingDirectory(workDir);
|
|
- Assert.assertEquals(fqWd, fc.getWorkingDirectory());
|
|
|
|
|
|
+ assertEquals(fqWd, fc.getWorkingDirectory());
|
|
|
|
|
|
Path relativeDir = new Path("existingDir1");
|
|
Path relativeDir = new Path("existingDir1");
|
|
Path absoluteDir = new Path(workDir,"existingDir1");
|
|
Path absoluteDir = new Path(workDir,"existingDir1");
|
|
fc.mkdir(absoluteDir, FileContext.DEFAULT_PERM, true);
|
|
fc.mkdir(absoluteDir, FileContext.DEFAULT_PERM, true);
|
|
Path fqAbsoluteDir = fc.makeQualified(absoluteDir);
|
|
Path fqAbsoluteDir = fc.makeQualified(absoluteDir);
|
|
fc.setWorkingDirectory(relativeDir);
|
|
fc.setWorkingDirectory(relativeDir);
|
|
- Assert.assertEquals(fqAbsoluteDir, fc.getWorkingDirectory());
|
|
|
|
|
|
+ assertEquals(fqAbsoluteDir, fc.getWorkingDirectory());
|
|
// cd using a absolute path
|
|
// cd using a absolute path
|
|
absoluteDir = new Path("/test/existingDir2");
|
|
absoluteDir = new Path("/test/existingDir2");
|
|
fqAbsoluteDir = fc.makeQualified(absoluteDir);
|
|
fqAbsoluteDir = fc.makeQualified(absoluteDir);
|
|
fc.mkdir(absoluteDir, FileContext.DEFAULT_PERM, true);
|
|
fc.mkdir(absoluteDir, FileContext.DEFAULT_PERM, true);
|
|
fc.setWorkingDirectory(absoluteDir);
|
|
fc.setWorkingDirectory(absoluteDir);
|
|
- Assert.assertEquals(fqAbsoluteDir, fc.getWorkingDirectory());
|
|
|
|
|
|
+ assertEquals(fqAbsoluteDir, fc.getWorkingDirectory());
|
|
|
|
|
|
// Now open a file relative to the wd we just set above.
|
|
// Now open a file relative to the wd we just set above.
|
|
Path absolutePath = new Path(absoluteDir, "foo");
|
|
Path absolutePath = new Path(absoluteDir, "foo");
|
|
@@ -274,12 +280,12 @@ public class TestChRootedFs {
|
|
|
|
|
|
// Now mkdir relative to the dir we cd'ed to
|
|
// Now mkdir relative to the dir we cd'ed to
|
|
fc.mkdir(new Path("newDir"), FileContext.DEFAULT_PERM, true);
|
|
fc.mkdir(new Path("newDir"), FileContext.DEFAULT_PERM, true);
|
|
- Assert.assertTrue(isDir(fc, new Path(absoluteDir, "newDir")));
|
|
|
|
|
|
+ assertTrue(isDir(fc, new Path(absoluteDir, "newDir")));
|
|
|
|
|
|
absoluteDir = fileContextTestHelper.getTestRootPath(fc, "nonexistingPath");
|
|
absoluteDir = fileContextTestHelper.getTestRootPath(fc, "nonexistingPath");
|
|
try {
|
|
try {
|
|
fc.setWorkingDirectory(absoluteDir);
|
|
fc.setWorkingDirectory(absoluteDir);
|
|
- Assert.fail("cd to non existing dir should have failed");
|
|
|
|
|
|
+ fail("cd to non existing dir should have failed");
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
// Exception as expected
|
|
// Exception as expected
|
|
}
|
|
}
|
|
@@ -289,7 +295,7 @@ public class TestChRootedFs {
|
|
absoluteDir = new Path(LOCAL_FS_ROOT_URI + "/existingDir");
|
|
absoluteDir = new Path(LOCAL_FS_ROOT_URI + "/existingDir");
|
|
fc.mkdir(absoluteDir, FileContext.DEFAULT_PERM, true);
|
|
fc.mkdir(absoluteDir, FileContext.DEFAULT_PERM, true);
|
|
fc.setWorkingDirectory(absoluteDir);
|
|
fc.setWorkingDirectory(absoluteDir);
|
|
- Assert.assertEquals(absoluteDir, fc.getWorkingDirectory());
|
|
|
|
|
|
+ assertEquals(absoluteDir, fc.getWorkingDirectory());
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -299,15 +305,17 @@ public class TestChRootedFs {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testResolvePath() throws IOException {
|
|
public void testResolvePath() throws IOException {
|
|
- Assert.assertEquals(chrootedTo, fc.getDefaultFileSystem().resolvePath(new Path("/")));
|
|
|
|
|
|
+ assertEquals(chrootedTo, fc.getDefaultFileSystem().resolvePath(new Path("/")));
|
|
fileContextTestHelper.createFile(fc, "/foo");
|
|
fileContextTestHelper.createFile(fc, "/foo");
|
|
- Assert.assertEquals(new Path(chrootedTo, "foo"),
|
|
|
|
|
|
+ assertEquals(new Path(chrootedTo, "foo"),
|
|
fc.getDefaultFileSystem().resolvePath(new Path("/foo")));
|
|
fc.getDefaultFileSystem().resolvePath(new Path("/foo")));
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(expected=FileNotFoundException.class)
|
|
|
|
|
|
+ @Test
|
|
public void testResolvePathNonExisting() throws IOException {
|
|
public void testResolvePathNonExisting() throws IOException {
|
|
|
|
+ assertThrows(FileNotFoundException.class, () -> {
|
|
fc.getDefaultFileSystem().resolvePath(new Path("/nonExisting"));
|
|
fc.getDefaultFileSystem().resolvePath(new Path("/nonExisting"));
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -315,7 +323,7 @@ public class TestChRootedFs {
|
|
AbstractFileSystem baseFs = Mockito.spy(fc.getDefaultFileSystem());
|
|
AbstractFileSystem baseFs = Mockito.spy(fc.getDefaultFileSystem());
|
|
ChRootedFs chRootedFs = new ChRootedFs(baseFs, new Path("/chroot"));
|
|
ChRootedFs chRootedFs = new ChRootedFs(baseFs, new Path("/chroot"));
|
|
Mockito.doReturn(true).when(baseFs).isValidName(Mockito.anyString());
|
|
Mockito.doReturn(true).when(baseFs).isValidName(Mockito.anyString());
|
|
- Assert.assertTrue(chRootedFs.isValidName("/test"));
|
|
|
|
|
|
+ assertTrue(chRootedFs.isValidName("/test"));
|
|
Mockito.verify(baseFs).isValidName("/chroot/test");
|
|
Mockito.verify(baseFs).isValidName("/chroot/test");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -324,11 +332,12 @@ public class TestChRootedFs {
|
|
AbstractFileSystem baseFs = Mockito.spy(fc.getDefaultFileSystem());
|
|
AbstractFileSystem baseFs = Mockito.spy(fc.getDefaultFileSystem());
|
|
ChRootedFs chRootedFs = new ChRootedFs(baseFs, new Path("/chroot"));
|
|
ChRootedFs chRootedFs = new ChRootedFs(baseFs, new Path("/chroot"));
|
|
Mockito.doReturn(false).when(baseFs).isValidName(Mockito.anyString());
|
|
Mockito.doReturn(false).when(baseFs).isValidName(Mockito.anyString());
|
|
- Assert.assertFalse(chRootedFs.isValidName("/test"));
|
|
|
|
|
|
+ assertFalse(chRootedFs.isValidName("/test"));
|
|
Mockito.verify(baseFs).isValidName("/chroot/test");
|
|
Mockito.verify(baseFs).isValidName("/chroot/test");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 30000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 30)
|
|
public void testCreateSnapshot() throws Exception {
|
|
public void testCreateSnapshot() throws Exception {
|
|
Path snapRootPath = new Path("/snapPath");
|
|
Path snapRootPath = new Path("/snapPath");
|
|
Path chRootedSnapRootPath = new Path(
|
|
Path chRootedSnapRootPath = new Path(
|
|
@@ -337,12 +346,13 @@ public class TestChRootedFs {
|
|
ChRootedFs chRootedFs = new ChRootedFs(baseFs, chrootedTo);
|
|
ChRootedFs chRootedFs = new ChRootedFs(baseFs, chrootedTo);
|
|
Mockito.doReturn(snapRootPath).when(baseFs)
|
|
Mockito.doReturn(snapRootPath).when(baseFs)
|
|
.createSnapshot(chRootedSnapRootPath, "snap1");
|
|
.createSnapshot(chRootedSnapRootPath, "snap1");
|
|
- Assert.assertEquals(snapRootPath,
|
|
|
|
|
|
+ assertEquals(snapRootPath,
|
|
chRootedFs.createSnapshot(snapRootPath, "snap1"));
|
|
chRootedFs.createSnapshot(snapRootPath, "snap1"));
|
|
Mockito.verify(baseFs).createSnapshot(chRootedSnapRootPath, "snap1");
|
|
Mockito.verify(baseFs).createSnapshot(chRootedSnapRootPath, "snap1");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 30000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 30)
|
|
public void testDeleteSnapshot() throws Exception {
|
|
public void testDeleteSnapshot() throws Exception {
|
|
Path snapRootPath = new Path("/snapPath");
|
|
Path snapRootPath = new Path("/snapPath");
|
|
Path chRootedSnapRootPath = new Path(
|
|
Path chRootedSnapRootPath = new Path(
|
|
@@ -355,7 +365,8 @@ public class TestChRootedFs {
|
|
Mockito.verify(baseFs).deleteSnapshot(chRootedSnapRootPath, "snap1");
|
|
Mockito.verify(baseFs).deleteSnapshot(chRootedSnapRootPath, "snap1");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 30000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 30)
|
|
public void testRenameSnapshot() throws Exception {
|
|
public void testRenameSnapshot() throws Exception {
|
|
Path snapRootPath = new Path("/snapPath");
|
|
Path snapRootPath = new Path("/snapPath");
|
|
Path chRootedSnapRootPath = new Path(
|
|
Path chRootedSnapRootPath = new Path(
|