0

For a particular scenario where my needs are expected: A java command line app that enables a RestController which forwards the request to a remote domain. Depending on arguments it initializes the server with some local request.

So, how can I perform a proper E2E with MockRestServiceServer, expecting that the localhost calls (done by the app, not by the test) are whitelisted and not accounted as expectations, and only the forwarded responder is mocked?

P.S> Currently I am using 2 restTemplates for intra/outerdomains but I don't like this solution and I am interested on the feasibility of allowing some actual calls with MockRestServiceServer. If only I could make mockRestServiceServer.expect(requestTo(localCall)); (actual response)...

Whimusical
  • 6,401
  • 11
  • 62
  • 105
  • 1
    You'll probably need to write your own `ClientHttpRequestFactory`. Separate `RestTemplates` for these routes seems like a better design anyway though. – OrangeDog Jan 13 '21 at 11:29
  • Thanks! But then I have to configure all timeouts and the like twice when I am personally ok with using same resttemplate for local calls as well – Whimusical Jan 13 '21 at 11:59
  • 1
    No you don't. You can e.g. reuse a single `RestTemplateBuilder`. – OrangeDog Jan 13 '21 at 12:03
  • Mhh I did not think of this possibility, I can inject the autoconfigured resttemplatebuilder, .call set for all tunings, and later on inject it so the creation of both restTemplates is just executing .build() – Whimusical Jan 13 '21 at 12:07

0 Answers0