-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MockRestServiceServerAutoConfiguration with RestTemplate and RestClient together throws incorrect exception #38820
Comments
I'm not sure I understand your setup. Could you please provide a minimal sample project (either a GitHub project or zip file) that shows what you are trying to do. |
The problem is in When a I suspect that the RestClient case then uses the wrong expectation manager when the mocked response is returned. That's the error I'm getting:
|
If you have two
The same is true when you have one Applying the suggestion from the JavaDoc to the provided sample would look like this: @Test
void test(@Autowired RestClient restClient, @Autowired MockServerRestClientCustomizer customizer) {
// given
customizer.getServer().expect(requestTo("/")).andRespond(withSuccess());
// when then
restClient.get()
.uri("/")
.retrieve();
} |
It should be possible to have together RestTemplate and RestClient in application and test them independently.
Unfortunately, currently if RestTemplate is used, RestClient cannot be tested:
org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerAutoConfiguration.DeferredRequestExpectationManager#getDelegate
The text was updated successfully, but these errors were encountered: