import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.web.client.RestTemplate;
/**
* @author waqas.ikram@ericsson.com
*
*/
+@Profile("test")
@Configuration
public class TestRestTemplateConfigration {
@Bean
public TestRestTemplate testRestTemplate() throws Exception {
-
final TestRestTemplate testRestTemplate = new TestRestTemplate();
((HttpComponentsClientHttpRequestFactory) testRestTemplate.getRestTemplate().getRequestFactory())
.setHttpClient(httpClient());
}
+ @Bean
+ public RestTemplate restTemplate() throws Exception {
+ final RestTemplate restTemplate = new RestTemplate();
+ restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory(httpClient()));
+ return restTemplate;
+ }
+
private CloseableHttpClient httpClient() throws Exception {
final TrustStrategy acceptingTrustStrategy = (cert, authType) -> true;