We're building a custom software program (Java + Spring.io) that writes audit trails to a log file (using logback). When a user takes an action in the system, an auditing entry is logged. This works. To be extra-100%-super-duper sure no events are missed, there is an extra requirement:
The system sends an e-mail to an e-mail address (set using configuration) when writing the auditing event to the log fails.
For the acceptance test, this requirement needs to be validated. Search didn't yield any answers, and I've tried two approaches that I could think of:
- Make the log file read-only while writing to it. Which doesn't work: Windows will happily continue to let the JVM write to the now write-protected file.
- Write to a network disk and yank the network cable This actually works, but killing the network connection also prevents the e-mail delivery. Additionally, acceptance testing is on a VM on which I don't have physical access to or control of the hardware.
Is there a way to manually trigger a 'write failure' on a file in Windows Server 2012 R2, so that the Java JVM thinks the write has failed?