I created blog post on the topic. It contains also link to Github repository with working example.
The trick is using test configuration, where you override original spring bean with fake one. You can use @Primary
and @Profile
annotations for this trick.