Integration test block port
Is there a way to block a port to run a Java application, emulate connection failures, for false positive tests:
- Block DB connection for emulation ** DB error
- Block JMS connection to emulate JMS failure
- Block internet connection to emulate offline behavior
I'm talking here about integrating testing, with a standalone jetty server running on the same machine but in a different JVM. So I am looking for a more general port blocking mechanism than those Mock frameworks have.
source to share
Mocking structure, for example. Mockito can be used to test cases like this. for example Using mockito you can mock the class DBConnection
so that when you try to call a method to run a SQL query you can make this throw method ConnectionException
or timeout
to check how your application reacts to such cases.
source to share