I'm looking for a way to test if my application can survive if the database it connects to goes down and back up again. In which case the expected behaviour of the application would be to first throw an exception and then reconnect successfully once the database is up.
I would like to do so in an automated integration test (so manually powering off/on the database and see how the app behaves is out of question).
Connecting to an in-memory database is an option but this will devalue the test somewhat since the prod code and test code wont run against exactly the same db and drivers, so not ideal.
Another option would be for the test to trigger a process which would cutoff the connection between the database and the app for a few seconds (not sure how to do that).
Any other ideas ?
Technical stack is Java with Spring (jdbc templates).