I need to write a Unittest for the following method, simulating the the file/Directory accessed is somehow not readable fpr the application:
public void writeFile(String path) {
File f = new File(path);
//some stuff...
}
How do i unittest this setup, if i can only provide a Path and cannot influence or even KNOW (blackbox) how the Developer of "writeFile(String path)" implemented the file access, i only know the Method signature and that a file is read.
basically, i need to know if it is possible to make JUnit "intercept" request to the filesystem and react depending on what path is to be accessed. Or is the only possibility to actually create a file in the unittest, that is inaccesible to the Unittest itself? In that case, how can the unittest "clean up" after itself?
I am open to all solution that utilize common Mocking frameworks or JUnit.
thanks in advance,
BillDoor