use of org.springframework.web.client.RestTemplate in project spring-boot by spring-projects.
the class RestTemplateBuilderTests method requestFactoryShouldApply.
@Test
public void requestFactoryShouldApply() throws Exception {
ClientHttpRequestFactory requestFactory = mock(ClientHttpRequestFactory.class);
RestTemplate template = this.builder.requestFactory(requestFactory).build();
assertThat(template.getRequestFactory()).isSameAs(requestFactory);
}
use of org.springframework.web.client.RestTemplate in project spring-boot by spring-projects.
the class RestTemplateBuilderTests method rootUriShouldApply.
@Test
public void rootUriShouldApply() throws Exception {
RestTemplate restTemplate = this.builder.rootUri("http://example.com").build();
MockRestServiceServer server = MockRestServiceServer.bindTo(restTemplate).build();
server.expect(requestTo("http://example.com/hello")).andRespond(withSuccess());
restTemplate.getForEntity("/hello", String.class);
server.verify();
}
use of org.springframework.web.client.RestTemplate in project spring-boot by spring-projects.
the class RestTemplateBuilderTests method requestFactoryClassShouldApply.
@Test
public void requestFactoryClassShouldApply() throws Exception {
RestTemplate template = this.builder.requestFactory(SimpleClientHttpRequestFactory.class).build();
assertThat(template.getRequestFactory()).isInstanceOf(SimpleClientHttpRequestFactory.class);
}
use of org.springframework.web.client.RestTemplate in project spring-boot by spring-projects.
the class RestTemplateBuilderTests method unwrappingDoesNotAffectRequestFactoryThatIsSetOnTheBuiltTemplate.
@Test
public void unwrappingDoesNotAffectRequestFactoryThatIsSetOnTheBuiltTemplate() {
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
RestTemplate template = this.builder.requestFactory(new BufferingClientHttpRequestFactory(requestFactory)).build();
assertThat(template.getRequestFactory()).isInstanceOf(BufferingClientHttpRequestFactory.class);
}
use of org.springframework.web.client.RestTemplate in project spring-boot by spring-projects.
the class RestTemplateBuilderTests method defaultMessageConvertersShouldSetDefaultList.
@Test
public void defaultMessageConvertersShouldSetDefaultList() throws Exception {
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(new StringHttpMessageConverter()));
this.builder.defaultMessageConverters().configure(template);
assertThat(template.getMessageConverters()).hasSameSizeAs(new RestTemplate().getMessageConverters());
}
Aggregations