Search in sources :

Example 1 with BufferingClientHttpRequestFactory

use of cn.taketoday.http.client.BufferingClientHttpRequestFactory in project today-infrastructure by TAKETODAY.

the class RestTemplateBuilderTests method bufferRequestBodyCanBeConfiguredOnAWrappedRequestFactory.

@Test
void bufferRequestBodyCanBeConfiguredOnAWrappedRequestFactory() {
    SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
    this.builder.requestFactory(() -> new BufferingClientHttpRequestFactory(requestFactory)).setBufferRequestBody(false).build();
    assertThat(requestFactory).hasFieldOrPropertyWithValue("bufferRequestBody", false);
    this.builder.requestFactory(() -> new BufferingClientHttpRequestFactory(requestFactory)).setBufferRequestBody(true).build();
    assertThat(requestFactory).hasFieldOrPropertyWithValue("bufferRequestBody", true);
    this.builder.requestFactory(() -> new BufferingClientHttpRequestFactory(requestFactory)).build();
    assertThat(requestFactory).hasFieldOrPropertyWithValue("bufferRequestBody", true);
}
Also used : SimpleClientHttpRequestFactory(cn.taketoday.http.client.SimpleClientHttpRequestFactory) BufferingClientHttpRequestFactory(cn.taketoday.http.client.BufferingClientHttpRequestFactory) Test(org.junit.jupiter.api.Test)

Example 2 with BufferingClientHttpRequestFactory

use of cn.taketoday.http.client.BufferingClientHttpRequestFactory in project today-framework by TAKETODAY.

the class RestTemplateBuilderTests method connectTimeoutCanBeConfiguredOnAWrappedRequestFactory.

@Test
void connectTimeoutCanBeConfiguredOnAWrappedRequestFactory() {
    SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
    this.builder.requestFactory(() -> new BufferingClientHttpRequestFactory(requestFactory)).setConnectTimeout(Duration.ofMillis(1234)).build();
    assertThat(requestFactory).hasFieldOrPropertyWithValue("connectTimeout", 1234);
}
Also used : SimpleClientHttpRequestFactory(cn.taketoday.http.client.SimpleClientHttpRequestFactory) BufferingClientHttpRequestFactory(cn.taketoday.http.client.BufferingClientHttpRequestFactory) Test(org.junit.jupiter.api.Test)

Example 3 with BufferingClientHttpRequestFactory

use of cn.taketoday.http.client.BufferingClientHttpRequestFactory in project today-framework by TAKETODAY.

the class RestTemplateBuilderTests method unwrappingDoesNotAffectRequestFactoryThatIsSetOnTheBuiltTemplate.

@Test
void unwrappingDoesNotAffectRequestFactoryThatIsSetOnTheBuiltTemplate() {
    SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
    RestTemplate template = this.builder.requestFactory(() -> new BufferingClientHttpRequestFactory(requestFactory)).build();
    assertThat(template.getRequestFactory()).isInstanceOf(BufferingClientHttpRequestFactory.class);
}
Also used : SimpleClientHttpRequestFactory(cn.taketoday.http.client.SimpleClientHttpRequestFactory) RestTemplate(cn.taketoday.web.client.RestTemplate) BufferingClientHttpRequestFactory(cn.taketoday.http.client.BufferingClientHttpRequestFactory) Test(org.junit.jupiter.api.Test)

Example 4 with BufferingClientHttpRequestFactory

use of cn.taketoday.http.client.BufferingClientHttpRequestFactory in project today-framework by TAKETODAY.

the class RestTemplateBuilderTests method readTimeoutCanBeConfiguredOnAWrappedRequestFactory.

@Test
void readTimeoutCanBeConfiguredOnAWrappedRequestFactory() {
    SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
    this.builder.requestFactory(() -> new BufferingClientHttpRequestFactory(requestFactory)).setReadTimeout(Duration.ofMillis(1234)).build();
    assertThat(requestFactory).hasFieldOrPropertyWithValue("readTimeout", 1234);
}
Also used : SimpleClientHttpRequestFactory(cn.taketoday.http.client.SimpleClientHttpRequestFactory) BufferingClientHttpRequestFactory(cn.taketoday.http.client.BufferingClientHttpRequestFactory) Test(org.junit.jupiter.api.Test)

Example 5 with BufferingClientHttpRequestFactory

use of cn.taketoday.http.client.BufferingClientHttpRequestFactory in project today-framework by TAKETODAY.

the class RestTemplateBuilderTests method bufferRequestBodyCanBeConfiguredOnAWrappedRequestFactory.

@Test
void bufferRequestBodyCanBeConfiguredOnAWrappedRequestFactory() {
    SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
    this.builder.requestFactory(() -> new BufferingClientHttpRequestFactory(requestFactory)).setBufferRequestBody(false).build();
    assertThat(requestFactory).hasFieldOrPropertyWithValue("bufferRequestBody", false);
    this.builder.requestFactory(() -> new BufferingClientHttpRequestFactory(requestFactory)).setBufferRequestBody(true).build();
    assertThat(requestFactory).hasFieldOrPropertyWithValue("bufferRequestBody", true);
    this.builder.requestFactory(() -> new BufferingClientHttpRequestFactory(requestFactory)).build();
    assertThat(requestFactory).hasFieldOrPropertyWithValue("bufferRequestBody", true);
}
Also used : SimpleClientHttpRequestFactory(cn.taketoday.http.client.SimpleClientHttpRequestFactory) BufferingClientHttpRequestFactory(cn.taketoday.http.client.BufferingClientHttpRequestFactory) Test(org.junit.jupiter.api.Test)

Aggregations

BufferingClientHttpRequestFactory (cn.taketoday.http.client.BufferingClientHttpRequestFactory)8 SimpleClientHttpRequestFactory (cn.taketoday.http.client.SimpleClientHttpRequestFactory)8 Test (org.junit.jupiter.api.Test)8 RestTemplate (cn.taketoday.web.client.RestTemplate)2