use of org.springframework.http.client.ClientHttpRequestFactory in project spring-boot by spring-projects.
the class RestTemplateBuilderTests method connectTimeoutCanBeConfiguredOnNetty4RequestFactory.
@Test
public void connectTimeoutCanBeConfiguredOnNetty4RequestFactory() {
ClientHttpRequestFactory requestFactory = this.builder.requestFactory(Netty4ClientHttpRequestFactory.class).setConnectTimeout(1234).build().getRequestFactory();
assertThat(ReflectionTestUtils.getField(requestFactory, "connectTimeout")).isEqualTo(1234);
}
use of org.springframework.http.client.ClientHttpRequestFactory in project spring-boot by spring-projects.
the class RestTemplateBuilderTests method customizersShouldBeAppliedLast.
@Test
public void customizersShouldBeAppliedLast() throws Exception {
RestTemplate template = spy(new RestTemplate());
this.builder.additionalCustomizers(new RestTemplateCustomizer() {
@Override
public void customize(RestTemplate restTemplate) {
verify(restTemplate).setRequestFactory((ClientHttpRequestFactory) any());
}
});
this.builder.configure(template);
}
use of org.springframework.http.client.ClientHttpRequestFactory in project spring-boot by spring-projects.
the class TestRestTemplateTests method verifyRelativeUriHandling.
private void verifyRelativeUriHandling(TestRestTemplateCallback callback) throws IOException {
ClientHttpRequestFactory requestFactory = mock(ClientHttpRequestFactory.class);
MockClientHttpRequest request = new MockClientHttpRequest();
request.setResponse(new MockClientHttpResponse(new byte[0], HttpStatus.OK));
URI absoluteUri = URI.create("http://localhost:8080/a/b/c.txt?param=%7Bsomething%7D");
given(requestFactory.createRequest(eq(absoluteUri), (HttpMethod) any())).willReturn(request);
RestTemplate delegate = new RestTemplate();
TestRestTemplate template = new TestRestTemplate(delegate);
delegate.setRequestFactory(requestFactory);
LocalHostUriTemplateHandler uriTemplateHandler = new LocalHostUriTemplateHandler(new MockEnvironment());
template.setUriTemplateHandler(uriTemplateHandler);
callback.doWithTestRestTemplate(template, URI.create("/a/b/c.txt?param=%7Bsomething%7D"));
verify(requestFactory).createRequest(eq(absoluteUri), (HttpMethod) any());
}
Aggregations