Search in sources :

Example 16 with RestTemplate

use of org.springframework.web.client.RestTemplate in project spring-boot by spring-projects.

the class RestTemplateBuilderTests method uriTemplateHandlerShouldApply.

@Test
public void uriTemplateHandlerShouldApply() throws Exception {
    UriTemplateHandler uriTemplateHandler = mock(UriTemplateHandler.class);
    RestTemplate template = this.builder.uriTemplateHandler(uriTemplateHandler).build();
    assertThat(template.getUriTemplateHandler()).isSameAs(uriTemplateHandler);
}
Also used : UriTemplateHandler(org.springframework.web.util.UriTemplateHandler) RestTemplate(org.springframework.web.client.RestTemplate) Test(org.junit.Test)

Example 17 with RestTemplate

use of org.springframework.web.client.RestTemplate in project spring-boot by spring-projects.

the class RestTemplateBuilderTests method createWithCustomizersShouldApplyCustomizers.

@Test
public void createWithCustomizersShouldApplyCustomizers() throws Exception {
    RestTemplateCustomizer customizer = mock(RestTemplateCustomizer.class);
    RestTemplate template = new RestTemplateBuilder(customizer).build();
    verify(customizer).customize(template);
}
Also used : RestTemplate(org.springframework.web.client.RestTemplate) Test(org.junit.Test)

Example 18 with RestTemplate

use of org.springframework.web.client.RestTemplate in project spring-boot by spring-projects.

the class RestTemplateBuilderTests method additionalCustomizersShouldAddToExisting.

@Test
public void additionalCustomizersShouldAddToExisting() throws Exception {
    RestTemplateCustomizer customizer1 = mock(RestTemplateCustomizer.class);
    RestTemplateCustomizer customizer2 = mock(RestTemplateCustomizer.class);
    RestTemplate template = this.builder.customizers(customizer1).additionalCustomizers(customizer2).build();
    verify(customizer1).customize(template);
    verify(customizer2).customize(template);
}
Also used : RestTemplate(org.springframework.web.client.RestTemplate) Test(org.junit.Test)

Example 19 with RestTemplate

use of org.springframework.web.client.RestTemplate in project spring-boot by spring-projects.

the class RestTemplateBuilderTests method defaultMessageConvertersShouldClearExisting.

@Test
public void defaultMessageConvertersShouldClearExisting() throws Exception {
    RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(new StringHttpMessageConverter()));
    this.builder.additionalMessageConverters(this.messageConverter).defaultMessageConverters().configure(template);
    assertThat(template.getMessageConverters()).hasSameSizeAs(new RestTemplate().getMessageConverters());
}
Also used : RestTemplate(org.springframework.web.client.RestTemplate) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter) Test(org.junit.Test)

Example 20 with RestTemplate

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);
}
Also used : ClientHttpRequestFactory(org.springframework.http.client.ClientHttpRequestFactory) SimpleClientHttpRequestFactory(org.springframework.http.client.SimpleClientHttpRequestFactory) Netty4ClientHttpRequestFactory(org.springframework.http.client.Netty4ClientHttpRequestFactory) OkHttp3ClientHttpRequestFactory(org.springframework.http.client.OkHttp3ClientHttpRequestFactory) HttpComponentsClientHttpRequestFactory(org.springframework.http.client.HttpComponentsClientHttpRequestFactory) BufferingClientHttpRequestFactory(org.springframework.http.client.BufferingClientHttpRequestFactory) RestTemplate(org.springframework.web.client.RestTemplate) Test(org.junit.Test)

Aggregations

RestTemplate (org.springframework.web.client.RestTemplate)189 Test (org.junit.Test)107 URI (java.net.URI)39 HttpMessageConverter (org.springframework.http.converter.HttpMessageConverter)29 ArrayList (java.util.ArrayList)24 HttpComponentsClientHttpRequestFactory (org.springframework.http.client.HttpComponentsClientHttpRequestFactory)20 HashMap (java.util.HashMap)19 MapPropertySource (org.springframework.core.env.MapPropertySource)15 StandardEnvironment (org.springframework.core.env.StandardEnvironment)15 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)15 SerDeHttpMessageConverter (com.kixeye.chassis.transport.http.SerDeHttpMessageConverter)13 MessageSerDe (com.kixeye.chassis.transport.serde.MessageSerDe)13 HttpHeaders (org.springframework.http.HttpHeaders)13 StringHttpMessageConverter (org.springframework.http.converter.StringHttpMessageConverter)13 IOException (java.io.IOException)12 JSONObject (org.json.JSONObject)12 ClientHttpResponse (org.springframework.http.client.ClientHttpResponse)11 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)11 JSONException (org.json.JSONException)10 RestTemplateBuilder (org.springframework.boot.web.client.RestTemplateBuilder)10