Is it possible to override a single DNS lookup in the java jvm?
I am running a junit test in java. The test makes a connection to an external server host1. Instead, I want the jvm to contact localhost when it tries to contact host1.
The test succeeds if /etc/hosts file contains:
127.0.0.1 host1
I am wondering if it can be done without modifying the hosts file.
We are using java 8. The junit test uses mockito & powermock libraries. It will run on Mac OS Mojave & CentOS (some container in some kubernetes pod on gcp/aws).
Thanks for reading.