From e38352dea93ebc7e49d2fc6d5f955a5cf181f62e Mon Sep 17 00:00:00 2001 From: Tom McCormick Date: Sat, 21 Oct 2023 16:08:02 -0700 Subject: [PATCH] pr comments --- .../AbstractContractGetEnclosingRoot.java | 51 +++++++++---------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractGetEnclosingRoot.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractGetEnclosingRoot.java index 6598048838324..597cc19ece686 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractGetEnclosingRoot.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractGetEnclosingRoot.java @@ -36,23 +36,17 @@ 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())); } @@ -60,12 +54,13 @@ public void testEnclosingRootEquivalence() throws IOException { 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 @@ -74,9 +69,11 @@ 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 @@ -84,14 +81,14 @@ 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) () -> { 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); } }