0

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:

  1. 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.
  2. 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?

Jakob Buis
  • 101
  • 3
  • A couple ideas: 1) Use a variant of #2, with two network cables, one handling email traffic and one handling SMB. 2) set up a local SMTP service on the same box as the application. Then the application can still submit mail to the queue even if the network is down. – EEAA Jun 07 '16 at 12:36
  • 1) is unfortunately not going to work: testing is setup on a VM, so I don't have physical access to or control of the hardware (I've updated the question). 2) might just work, I'll try that. – Jakob Buis Jun 07 '16 at 12:48
  • You can add a second NIC to the VM and then remove it. – EEAA Jun 07 '16 at 13:05

0 Answers0