roadSurfer commented on code in PR #297: URL: https://github.com/apache/maven-enforcer/pull/297#discussion_r1939745146
########## enforcer-rules/src/test/java/org/apache/maven/enforcer/rules/files/TestRequireFilesDontExist.java: ########## @@ -105,19 +109,62 @@ void testEmptyFileListAllowNull() { } @Test - void testFileDoesNotExist() throws EnforcerRuleException, IOException { + void testDeletedFileDetected() throws EnforcerRuleException, IOException { File f = File.createTempFile("junit", null, temporaryFolder); + rule.setFilesList(Collections.singletonList(f)); + + // Check the file is detected as being present + EnforcerRuleException e = assertThrows(EnforcerRuleException.class, rule::execute); + assumeFalse(e.getMessage() == null); + f.delete(); assertFalse(f.exists()); - rule.setFilesList(Collections.singletonList(f)); + // Rule should now pass as the file was deleted + rule.execute(); + } + + @Test + void testSymbolicLinkDeletedDetected() throws Exception { + File canonicalFile = File.createTempFile("canonical_", null, temporaryFolder); + File linkFile = Files.createSymbolicLink( + Paths.get(temporaryFolder.getAbsolutePath(), "symbolic.link"), + Paths.get(canonicalFile.getAbsolutePath())) + .toFile(); + + rule.setFilesList(Collections.singletonList(linkFile)); + // Check the link is detected as being present + EnforcerRuleException e = assertThrows(EnforcerRuleException.class, rule::execute); + assumeFalse(e.getMessage() == null); Review Comment: Done -- 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: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org