Search in sources :

Example 1 with ClientHttpRequestFactory

use of org.springframework.http.client.ClientHttpRequestFactory in project spring-boot by spring-projects.

the class RestTemplateBuilderTests method readTimeoutCanBeConfiguredOnNetty4RequestFactory.

@Test
public void readTimeoutCanBeConfiguredOnNetty4RequestFactory() {
    ClientHttpRequestFactory requestFactory = this.builder.requestFactory(Netty4ClientHttpRequestFactory.class).setReadTimeout(1234).build().getRequestFactory();
    assertThat(ReflectionTestUtils.getField(requestFactory, "readTimeout")).isEqualTo(1234);
}
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) Netty4ClientHttpRequestFactory(org.springframework.http.client.Netty4ClientHttpRequestFactory) Test(org.junit.Test)

Example 2 with ClientHttpRequestFactory

use of org.springframework.http.client.ClientHttpRequestFactory in project spring-boot by spring-projects.

the class RestTemplateBuilderTests method connectTimeoutCanBeConfiguredOnOkHttp3RequestFactory.

@Test
public void connectTimeoutCanBeConfiguredOnOkHttp3RequestFactory() {
    ClientHttpRequestFactory requestFactory = this.builder.requestFactory(OkHttp3ClientHttpRequestFactory.class).setConnectTimeout(1234).build().getRequestFactory();
    assertThat(ReflectionTestUtils.getField(ReflectionTestUtils.getField(requestFactory, "client"), "connectTimeout")).isEqualTo(1234);
}
Also used : OkHttp3ClientHttpRequestFactory(org.springframework.http.client.OkHttp3ClientHttpRequestFactory) 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) Test(org.junit.Test)

Example 3 with ClientHttpRequestFactory

use of org.springframework.http.client.ClientHttpRequestFactory 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)

Example 4 with ClientHttpRequestFactory

use of org.springframework.http.client.ClientHttpRequestFactory in project spring-boot by spring-projects.

the class RestTemplateBuilderTests method connectTimeoutCanBeConfiguredOnHttpComponentsRequestFactory.

@Test
public void connectTimeoutCanBeConfiguredOnHttpComponentsRequestFactory() {
    ClientHttpRequestFactory requestFactory = this.builder.requestFactory(HttpComponentsClientHttpRequestFactory.class).setConnectTimeout(1234).build().getRequestFactory();
    assertThat(((RequestConfig) ReflectionTestUtils.getField(requestFactory, "requestConfig")).getConnectTimeout()).isEqualTo(1234);
}
Also used : RequestConfig(org.apache.http.client.config.RequestConfig) 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) HttpComponentsClientHttpRequestFactory(org.springframework.http.client.HttpComponentsClientHttpRequestFactory) Test(org.junit.Test)

Example 5 with ClientHttpRequestFactory

use of org.springframework.http.client.ClientHttpRequestFactory in project spring-boot by spring-projects.

the class RestTemplateBuilderTests method readTimeoutCanBeConfiguredOnOkHttp3RequestFactory.

@Test
public void readTimeoutCanBeConfiguredOnOkHttp3RequestFactory() {
    ClientHttpRequestFactory requestFactory = this.builder.requestFactory(OkHttp3ClientHttpRequestFactory.class).setReadTimeout(1234).build().getRequestFactory();
    assertThat(ReflectionTestUtils.getField(ReflectionTestUtils.getField(requestFactory, "client"), "readTimeout")).isEqualTo(1234);
}
Also used : OkHttp3ClientHttpRequestFactory(org.springframework.http.client.OkHttp3ClientHttpRequestFactory) 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) Test(org.junit.Test)

Aggregations

ClientHttpRequestFactory (org.springframework.http.client.ClientHttpRequestFactory)23 Test (org.junit.Test)17 HttpComponentsClientHttpRequestFactory (org.springframework.http.client.HttpComponentsClientHttpRequestFactory)12 SimpleClientHttpRequestFactory (org.springframework.http.client.SimpleClientHttpRequestFactory)12 URI (java.net.URI)11 BufferingClientHttpRequestFactory (org.springframework.http.client.BufferingClientHttpRequestFactory)10 Netty4ClientHttpRequestFactory (org.springframework.http.client.Netty4ClientHttpRequestFactory)10 OkHttp3ClientHttpRequestFactory (org.springframework.http.client.OkHttp3ClientHttpRequestFactory)10 HttpMethod (org.springframework.http.HttpMethod)9 ClientHttpRequest (org.springframework.http.client.ClientHttpRequest)9 IOException (java.io.IOException)7 RestTemplate (org.springframework.web.client.RestTemplate)6 HttpHeaders (org.springframework.http.HttpHeaders)4 AccessTokenRequest (org.springframework.security.oauth2.client.token.AccessTokenRequest)4 DefaultAccessTokenRequest (org.springframework.security.oauth2.client.token.DefaultAccessTokenRequest)4 DefaultOAuth2AccessToken (org.springframework.security.oauth2.common.DefaultOAuth2AccessToken)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ArrayList (java.util.ArrayList)2 RequestConfig (org.apache.http.client.config.RequestConfig)2 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)2