adoroszlai commented on code in PR #7955:
URL: https://github.com/apache/ozone/pull/7955#discussion_r1966699185
##########
hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/TestHddsUtils.java:
##########
@@ -68,21 +68,21 @@ void testGetHostName() {
@Test
void validatePath() {
- HddsUtils.validatePath(Paths.get("/"), Paths.get("/"));
- HddsUtils.validatePath(Paths.get("/a"), Paths.get("/"));
- HddsUtils.validatePath(Paths.get("/a"), Paths.get("/a"));
- HddsUtils.validatePath(Paths.get("/a/b"), Paths.get("/a"));
- HddsUtils.validatePath(Paths.get("/a/b/c"), Paths.get("/a"));
- HddsUtils.validatePath(Paths.get("/a/../a/b"), Paths.get("/a"));
+ HddsUtils.validatePath(Paths.get("root"), Paths.get("root"));
Review Comment:
Instead of changing the test paths, we can parameterize the test case. This
is enough for findbugs to stop complaining, and also improves the code (which
was added before we started using JUnit5).
```java
static List<Arguments> validPaths() {
return Arrays.asList(
Arguments.of("/", "/"),
...
@ParameterizedTest
@MethodSource("validPaths")
void validatePathAcceptsValidPath(String path, String ancestor) {
HddsUtils.validatePath(Paths.get(path), Paths.get(ancestor));
}
static List<Arguments> invalidPaths() {
return Arrays.asList(
Arguments.of("/b/c", "/a"),
...
@ParameterizedTest
@MethodSource("invalidPaths")
void validatePathRejectsInvalidPath(String path, String ancestor) {
assertThrows(IllegalArgumentException.class,
() -> HddsUtils.validatePath(Paths.get(path), Paths.get(ancestor)));
}
```
##########
hadoop-hdds/common/dev-support/findbugsExcludeFile.xml:
##########
@@ -33,10 +33,6 @@
</Match>
<!-- Test -->
- <Match>
- <Class name="org.apache.hadoop.hdds.TestHddsUtils"></Class>
- <Bug pattern="DMI_HARDCODED_ABSOLUTE_FILENAME" />
- </Match>
<Match>
<Class
name="~org\.apache\.hadoop\.hdds\.scm\.net\.TestNodeSchemaLoader\$.*"></Class>
<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD" />
Review Comment:
Other suppressions can be also removed. I guess they must have been
resolved earlier.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]