Add constructor to TestRestTemplate that takes a RestTemplateBuilder

Closes gh-6706
See gh-6702
This commit is contained in:
Maciej Walkowiak
2016-08-20 22:46:34 +02:00
committed by Andy Wilkinson
parent 6cb18835b9
commit 53d7fd5aab
2 changed files with 24 additions and 0 deletions

View File

@@ -82,6 +82,19 @@ public class TestRestTemplate {
private final RestTemplate restTemplate;
/**
* Create a new {@link TestRestTemplate} instance.
* @param restTemplateBuilder builder used to configure underlying {@link RestTemplate}
*/
public TestRestTemplate(RestTemplateBuilder restTemplateBuilder) {
this(buildRestTemplate(restTemplateBuilder));
}
private static RestTemplate buildRestTemplate(RestTemplateBuilder restTemplateBuilder) {
Assert.notNull(restTemplateBuilder, "RestTemplateBuilder must not be null");
return restTemplateBuilder.build();
}
/**
* Create a new {@link TestRestTemplate} instance.
* @param httpClientOptions client options to use if the Apache HTTP Client is used