roadSurfer commented on code in PR #297: URL: https://github.com/apache/maven-enforcer/pull/297#discussion_r1939715414
########## enforcer-rules/src/test/java/org/apache/maven/enforcer/rules/files/TestRequireFilesExist.java: ########## @@ -50,12 +56,34 @@ void testFileExists() throws Exception { } @Test - void testFileOsIndependentExists() { - rule.setFilesList(Collections.singletonList(new File("POM.xml"))); + void testSymbolicLinkExists() throws Exception { + File canonicalFile = File.createTempFile("canonical_", null, temporaryFolder); + File linkFile = Files.createSymbolicLink( + Paths.get(temporaryFolder.getAbsolutePath(), "symbolic.link"), + Paths.get(canonicalFile.getAbsolutePath())) + .toFile(); - EnforcerRuleException e = assertThrows(EnforcerRuleException.class, () -> rule.execute()); + rule.setFilesList(Collections.singletonList(linkFile)); - assertNotNull(e.getMessage()); + rule.execute(); + } + + @Test + void testSymbolicLinkTargetDoesNotExist() throws Exception { + File canonicalFile = File.createTempFile("canonical_", null, temporaryFolder); + File linkFile = Files.createSymbolicLink( + Paths.get(temporaryFolder.getAbsolutePath(), "symbolic.link"), + Paths.get(canonicalFile.getAbsolutePath())) + .toFile(); + canonicalFile.delete(); + rule.setFilesList(Collections.singletonList(linkFile)); + + try { + rule.execute(); + fail("Should have received an exception"); + } catch (Exception e) { 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