Is there a way to block a port for running Java application, to emulate connectivity failures, for false-positive tests:
I am talking here about integration testing, with standalone jetty server, which is running on the same machine but in a different JVM. So I am looking for a more generic mechanism for port blocking, than those of a Mock frameworks.
A mocking framework, e.g. Mockito can be used to test such cases. e.g. Using mockito, you can mock a DBConnection class, so that when you try to invoke method to run SQL query, you can make that method throw ConnectionException or timeout to test how your application responds to such cases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With