Tilman Rossmy
Tilman Rossmy

Reputation: 312

spring-integration: mock requestFactory on HttpRequestExecutingMessageHandler

Since upgrading spring-integration to 5.3.10.RELEASE we can't mock the requestFactory on HttpRequestExecutingMessageHandler anymore in the unit tests, it is actually checked if the requestFactory setter has been called and an exception is thrown in that case. So, how to configure the HttpRequestExecutingMessageHandler.requestFactory now with a Mockito instance?

Upvotes: 0

Views: 229

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121552

The check there is like this:

public void setRequestFactory(ClientHttpRequestFactory requestFactory) {
    assertLocalRestTemplate("requestFactory");
    this.restTemplate.setRequestFactory(requestFactory);
}

That means that you have been providing a RestTemplate into this HttpRequestExecutingMessageHandler. The requestFactory is essentially a property of the RestTemplate. So, consider to set your mock into that external RestTemplate instead.

Upvotes: 0

Related Questions