I have file related code to test where I would like to test my error handling for an existing file that I cannot read.
class SomeClass {
//...
public void load(Path path) {
if (!Files.isRegularFile(path)) {
return null;
}
//...
try {
// ...
catch (IOException e) {
// cleanup
}
}
}
I am using jimfs to isolate the tests from the real file system.
So how would I create a file on jimfs that is not readable?
I have already tried assigning posix permissions and a different user to the path through Files.setAttribute
on the desired path, both of which seem to have been ignored when attempting to read or write to the path.