Announcement Announcement Module
No announcement yet.
Unit Testing with Indirect Invocation of RestTemplate Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unit Testing with Indirect Invocation of RestTemplate

    I am trying to unit test some client code that relies on Spring's RestTemplate. I would like to use the testing suite that Spring has developed already for this purpose:


    Spring MVC Sample Tests

    These sample tests show how to test an instance of RestTemplate directly. My problem is that my instance of RestTemplate is being invoked indirectly within the client code. The code comments in Spring's test source imply that indirect usage of RestTemplate can still be tested with their mock server, but I don't see how without having some direct access to the RestTemplate itself.

    My Question:
    Does anyone have any ideas on how I can still mock the REST interactions without having to refactor my class to make my RestTemplate publicly exportable? I'd love it if the solution still allowed me to rely on this mock server from Spring, but any ideas and advice would be appreciated.

  • #2
    The project has been divided into small modules. The coding has to be checked.The rest template has automatically close.