Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom McCormick committed Oct 21, 2023
1 parent 1812adc commit e38352d
Showing 1 changed file with 24 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,31 @@ public void testEnclosingRootEquivalence() throws IOException {
Path root = path("/");
Path foobar = path("/foo/bar");

// Ensure getEnclosingRoot on the root directory returns the root directory.
assertEquals(root, fs.getEnclosingRoot(foobar));

// Ensure getEnclosingRoot called on itself returns the root directory.
assertEquals(root, fs.getEnclosingRoot(fs.getEnclosingRoot(foobar)));

// Ensure getEnclosingRoot for different paths in the same enclosing root returns the same path.
assertEquals(fs.getEnclosingRoot(root), fs.getEnclosingRoot(foobar));

// Ensure getEnclosingRoot on a path returns the root directory.
assertEquals(root, fs.getEnclosingRoot(methodPath()));

// Ensure getEnclosingRoot called on itself on a path returns the root directory.
assertEquals(root, fs.getEnclosingRoot(fs.getEnclosingRoot(methodPath())));

// Ensure getEnclosingRoot for different paths in the same enclosing root returns the same path.
assertEquals(fs.getEnclosingRoot(root), fs.getEnclosingRoot(methodPath()));
assertEquals("Ensure getEnclosingRoot on the root directory returns the root directory",
root, fs.getEnclosingRoot(foobar));
assertEquals("Ensure getEnclosingRoot called on itself returns the root directory",
root, fs.getEnclosingRoot(fs.getEnclosingRoot(foobar)));
assertEquals("Ensure getEnclosingRoot for different paths in the same enclosing root returns the same path",
fs.getEnclosingRoot(root), fs.getEnclosingRoot(foobar));
assertEquals("Ensure getEnclosingRoot on a path returns the root directory",
root, fs.getEnclosingRoot(methodPath()));
assertEquals("Ensure getEnclosingRoot called on itself on a path returns the root directory",
root, fs.getEnclosingRoot(fs.getEnclosingRoot(methodPath())));
assertEquals("Ensure getEnclosingRoot for different paths in the same enclosing root returns the same path", fs.getEnclosingRoot(root), fs.getEnclosingRoot(methodPath()));
}


@Test
public void testEnclosingRootPathExists() throws Exception {
FileSystem fs = getFileSystem();
Path root = path("/");
Path foobar = path("/foo/bar");
Path foobar = methodPath();
fs.mkdirs(foobar);

// Ensure getEnclosingRoot returns the root directory when the path exists.
assertEquals(root, fs.getEnclosingRoot(foobar));
assertEquals(root, fs.getEnclosingRoot(methodPath()));
assertEquals("Ensure getEnclosingRoot returns the root directory when the root directory exists",
root, fs.getEnclosingRoot(foobar));
assertEquals("Ensure getEnclosingRoot returns the root directory when the directory exists",
root, fs.getEnclosingRoot(foobar));
}

@Test
Expand All @@ -74,24 +69,26 @@ public void testEnclosingRootPathDNE() throws Exception {
Path foobar = path("/foo/bar");
Path root = path("/");

// Ensure getEnclosingRoot returns the root directory even when the path does not exist.
assertEquals(root, fs.getEnclosingRoot(foobar));
assertEquals(root, fs.getEnclosingRoot(methodPath()));
// .
assertEquals("Ensure getEnclosingRoot returns the root directory even when the path does not exist",
root, fs.getEnclosingRoot(foobar));
assertEquals("Ensure getEnclosingRoot returns the root directory even when the path does not exist",
root, fs.getEnclosingRoot(methodPath()));
}

@Test
public void testEnclosingRootWrapped() throws Exception {
FileSystem fs = getFileSystem();
Path root = path("/");

assertEquals(root, fs.getEnclosingRoot(new Path("/foo/bar")));
assertEquals("Ensure getEnclosingRoot returns the root directory when the directory exists",
root, fs.getEnclosingRoot(new Path("/foo/bar")));

UserGroupInformation ugi = UserGroupInformation.createRemoteUser("foo");
Path p = ugi.doAs((PrivilegedExceptionAction<Path>) () -> {
FileSystem wFs = getContract().getTestFileSystem();
return wFs.getEnclosingRoot(new Path("/foo/bar"));
});
// Ensure getEnclosingRoot works correctly within a wrapped FileSystem
assertEquals(root, p);
assertEquals("Ensure getEnclosingRoot works correctly within a wrapped FileSystem", root, p);
}
}

0 comments on commit e38352d

Please sign in to comment.