chkpnt commented on code in PR #486:
URL: https://github.com/apache/commons-io/pull/486#discussion_r1340216272
##########
src/test/java/org/apache/commons/io/FileUtilsTest.java:
##########
@@ -2463,6 +2482,24 @@ public void testReadFileToStringWithEncoding() throws
Exception {
assertEquals("Hello /u1234", data);
}
+ @Test
+ public void testReadFileToString_Errors() {
+ assertThrows(NullPointerException.class, () ->
FileUtils.readFileToString(null));
+ assertThrows(IOException.class, () -> FileUtils.readFileToString(new
File("non-exsistent")));
+ assertThrows(IOException.class, () ->
FileUtils.readFileToString(tempDirFile));
+ assertThrows(IOException.class, () ->
FileUtils.readFileToString(tempDirFile, "unsupported-charset"));
+ }
+
+ @Test
+ @EnabledIf("isPosixFilePermissionsSupported")
+ public void testReadFileToString_IOExceptionOnPosixFileSystem() throws
Exception {
Review Comment:
Just stumbled over
```
if (!SystemUtils.IS_OS_WINDOWS) {
final Set<PosixFilePermission> parentPerms =
Files.getPosixFilePermissions(target.getParentFile().toPath());
final Set<PosixFilePermission> targetPerms =
Files.getPosixFilePermissions(target.toPath());
assertEquals(parentPerms, targetPerms);
}
```
in line 862. So do you prefer such an condition in
`testReadFileToByteArray_Errors()` instead of this conditional test? (But I'm
not experienced enough in regards of filesystems: Is
`!SystemUtils.IS_OS_WINDOWS` enough to rely on for the usage of
`PosixFilePermissions`? `isPosixFilePermissionsSupported()` might be safer?)
--
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]