I have declared a RestTemplate as a bean in my Spring project to centralise some custom config. Judging by the source code, if I use MockRestServiceServer.createServer() on it, the bean will be "polluted" with a mock RequestFactory.
This fact is also not documented so even if I manually save and restore the Factory, it may stop working when the implementation of MockRestServiceServer changes.
I am wondering is there any clean workaround/pattern that would
- make sure all
RestTemplates go through a central config process, and - allow
RestTemplatecalls in a bean to be mocked without having to manually instantiate bean and wire it
(Of course, none of these would be needed if the author of MockRestServiceServer provided a way to undo the changes... I will raise a ticket if no satisfactory solution can be found.)
Aucun commentaire:
Enregistrer un commentaire