gnodet-bot commented on code in PR #344:
URL:
https://github.com/apache/maven-clean-plugin/pull/344#discussion_r4093377210
##########
src/test/java/org/apache/maven/plugins/clean/CleanerTest.java:
##########
@@ -134,4 +135,23 @@ void
deleteDoesNotLogAnythingWhenNoPermissionAndWarnDisabled(@TempDir Path tempD
assertDoesNotThrow(() -> cleaner.delete(basedir));
verify(log, never()).warn(any(CharSequence.class),
any(Throwable.class));
}
+
+ /**
+ * Verifies that {@code followSymlinks=true} deletes the directory
correctly when {@code toRealPath()}
+ * succeeds (normal case). The fallback code path (when {@code
toRealPath()} throws, as on Windows Docker
+ * volume reparse points due to JDK-8172711) cannot be reproduced in
standard CI and is therefore not
+ * covered by an automated test.
+ */
+ @Test
+ @DisabledOnOs(OS.WINDOWS)
+ void deleteWithFollowSymlinksDeletesTarget(@TempDir Path tempDir) throws
Exception {
+ final Path target =
createDirectory(tempDir.resolve("target")).toRealPath();
+ createFile(target.resolve("file"));
+ final Path link = createSymbolicLink(tempDir.resolve("link"), target);
+ // followSymlinks=true triggers the getCanonicalPath() call (and the
new try/catch)
+ final var cleaner = new Cleaner(matcherFactory, log, false, true,
false, true, false);
+ cleaner.delete(link);
+ assertFalse(exists(target));
+ verify(log, never()).debug(any(CharSequence.class));
Review Comment:
⚠️ **Incomplete assertion — the new 2-arg debug call isn't covered.**
The assertion verifies `debug(CharSequence)` (one-arg) is never called. But
the fallback code you added calls `logger.debug(msg, e)` — the **two-arg**
`debug(CharSequence, Throwable)` overload. Mockito treats these as distinct
method signatures, so this `verify` won't catch an accidental invocation of the
fallback in this (normal) test path.
Add the two-arg check to make the assertion exhaustive:
```suggestion
verify(log, never()).debug(any(CharSequence.class));
verify(log, never()).debug(any(CharSequence.class),
any(Throwable.class));
```
--
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]