So, I have a few dependencies which I'm trying to mock for integration tests.
More specifically, I have a spring-cloud
on my classpath which loads a Eureka client
as part of its bootstrap configuration process, and tries to connect to discovery service
.
Currently, I'm using a real server, but I'd like to mock it, before the client attempts to connect to it.
Unfortunately, as client is included in the library, I have no control over it, i.e. I can't add a @DependsOn
annotation to it.
I was playing with various Spring lifecycle listeners and I think I should be able to get it to work, but was wondering if there is a cleaner approach to solve the problem.