Search in sources :

Example 6 with RestTemplate

use of cn.taketoday.web.client.RestTemplate in project today-infrastructure by TAKETODAY.

the class RestTemplateBuilderTests method defaultMessageConvertersShouldSetDefaultList.

@Test
void defaultMessageConvertersShouldSetDefaultList() {
    RestTemplate template = new RestTemplate(Collections.singletonList(new StringHttpMessageConverter()));
    this.builder.defaultMessageConverters().configure(template);
    assertThat(template.getMessageConverters()).hasSameSizeAs(new RestTemplate().getMessageConverters());
}
Also used : RestTemplate(cn.taketoday.web.client.RestTemplate) StringHttpMessageConverter(cn.taketoday.http.converter.StringHttpMessageConverter) Test(org.junit.jupiter.api.Test)

Example 7 with RestTemplate

use of cn.taketoday.web.client.RestTemplate in project today-infrastructure by TAKETODAY.

the class RestTemplateBuilderTests method customizersShouldBeAppliedLast.

@Test
void customizersShouldBeAppliedLast() {
    RestTemplate template = spy(new RestTemplate());
    this.builder.additionalCustomizers((restTemplate) -> verify(restTemplate).setRequestFactory(any(ClientHttpRequestFactory.class)));
    this.builder.configure(template);
}
Also used : RestTemplate(cn.taketoday.web.client.RestTemplate) Test(org.junit.jupiter.api.Test)

Example 8 with RestTemplate

use of cn.taketoday.web.client.RestTemplate in project today-infrastructure by TAKETODAY.

the class RestTemplateBuilderTests method configureShouldApply.

@Test
void configureShouldApply() {
    RestTemplate template = new RestTemplate();
    this.builder.configure(template);
    assertThat(template.getRequestFactory()).isInstanceOf(HttpComponentsClientHttpRequestFactory.class);
}
Also used : RestTemplate(cn.taketoday.web.client.RestTemplate) Test(org.junit.jupiter.api.Test)

Example 9 with RestTemplate

use of cn.taketoday.web.client.RestTemplate in project today-infrastructure by TAKETODAY.

the class RestTemplateBuilderTests method requestFactoryPackagePrivateClassShouldApply.

@Test
void requestFactoryPackagePrivateClassShouldApply() {
    RestTemplate template = this.builder.requestFactory(TestClientHttpRequestFactory.class).build();
    assertThat(template.getRequestFactory()).isInstanceOf(TestClientHttpRequestFactory.class);
}
Also used : RestTemplate(cn.taketoday.web.client.RestTemplate) Test(org.junit.jupiter.api.Test)

Example 10 with RestTemplate

use of cn.taketoday.web.client.RestTemplate in project today-infrastructure by TAKETODAY.

the class RestTemplateBuilderTests method errorHandlerShouldApply.

@Test
void errorHandlerShouldApply() {
    ResponseErrorHandler errorHandler = mock(ResponseErrorHandler.class);
    RestTemplate template = this.builder.errorHandler(errorHandler).build();
    assertThat(template.getErrorHandler()).isSameAs(errorHandler);
}
Also used : ResponseErrorHandler(cn.taketoday.web.client.ResponseErrorHandler) RestTemplate(cn.taketoday.web.client.RestTemplate) Test(org.junit.jupiter.api.Test)

Aggregations

RestTemplate (cn.taketoday.web.client.RestTemplate)100 Test (org.junit.jupiter.api.Test)66 URI (java.net.URI)30 StringHttpMessageConverter (cn.taketoday.http.converter.StringHttpMessageConverter)14 ClientHttpRequest (cn.taketoday.http.client.ClientHttpRequest)12 SimpleClientHttpRequestFactory (cn.taketoday.http.client.SimpleClientHttpRequestFactory)12 BufferingClientHttpRequestFactory (cn.taketoday.http.client.BufferingClientHttpRequestFactory)10 ClientHttpRequestInterceptor (cn.taketoday.http.client.ClientHttpRequestInterceptor)10 HttpComponentsClientHttpRequestFactory (cn.taketoday.http.client.HttpComponentsClientHttpRequestFactory)10 HttpMessageConverter (cn.taketoday.http.converter.HttpMessageConverter)10 ResourceHttpMessageConverter (cn.taketoday.http.converter.ResourceHttpMessageConverter)10 UriTemplateHandler (cn.taketoday.web.util.UriTemplateHandler)10 HttpHeaders (cn.taketoday.http.HttpHeaders)8 ClientHttpRequestFactory (cn.taketoday.http.client.ClientHttpRequestFactory)8 InterceptingClientHttpRequestFactory (cn.taketoday.http.client.InterceptingClientHttpRequestFactory)8 OkHttp3ClientHttpRequestFactory (cn.taketoday.http.client.OkHttp3ClientHttpRequestFactory)8 ResponseErrorHandler (cn.taketoday.web.client.ResponseErrorHandler)8 BeforeEach (org.junit.jupiter.api.BeforeEach)8 InOrder (org.mockito.InOrder)8 HttpMethod (cn.taketoday.http.HttpMethod)6