Search in sources :

Example 1 with ClientHttpRequestMessageSender

use of org.springframework.ws.transport.http.ClientHttpRequestMessageSender in project spring-boot by spring-projects.

the class WebServiceTemplateBuilderTests method additionalMessageSendersShouldAddToExisting.

@Test
void additionalMessageSendersShouldAddToExisting() {
    ClientHttpRequestMessageSender httpMessageSender = new ClientHttpRequestMessageSender();
    WebServiceTemplate template = this.builder.messageSenders(httpMessageSender).additionalMessageSenders(this.messageSender).build();
    assertThat(template.getMessageSenders()).containsOnly(httpMessageSender, this.messageSender);
}
Also used : WebServiceTemplate(org.springframework.ws.client.core.WebServiceTemplate) ClientHttpRequestMessageSender(org.springframework.ws.transport.http.ClientHttpRequestMessageSender) Test(org.junit.jupiter.api.Test)

Example 2 with ClientHttpRequestMessageSender

use of org.springframework.ws.transport.http.ClientHttpRequestMessageSender in project spring-boot by spring-projects.

the class HttpWebServiceMessageSenderBuilderOkHttp3IntegrationTests method assertOkHttp3RequestFactory.

private OkHttp3ClientHttpRequestFactory assertOkHttp3RequestFactory(WebServiceMessageSender messageSender) {
    assertThat(messageSender).isInstanceOf(ClientHttpRequestMessageSender.class);
    ClientHttpRequestMessageSender sender = (ClientHttpRequestMessageSender) messageSender;
    ClientHttpRequestFactory requestFactory = sender.getRequestFactory();
    assertThat(requestFactory).isInstanceOf(OkHttp3ClientHttpRequestFactory.class);
    return (OkHttp3ClientHttpRequestFactory) requestFactory;
}
Also used : OkHttp3ClientHttpRequestFactory(org.springframework.http.client.OkHttp3ClientHttpRequestFactory) ClientHttpRequestFactory(org.springframework.http.client.ClientHttpRequestFactory) OkHttp3ClientHttpRequestFactory(org.springframework.http.client.OkHttp3ClientHttpRequestFactory) ClientHttpRequestMessageSender(org.springframework.ws.transport.http.ClientHttpRequestMessageSender)

Example 3 with ClientHttpRequestMessageSender

use of org.springframework.ws.transport.http.ClientHttpRequestMessageSender in project spring-boot by spring-projects.

the class HttpWebServiceMessageSenderBuilderTests method buildUsesHttpComponentsByDefault.

@Test
void buildUsesHttpComponentsByDefault() {
    ClientHttpRequestMessageSender messageSender = build(new HttpWebServiceMessageSenderBuilder().setConnectTimeout(Duration.ofSeconds(5)).setReadTimeout(Duration.ofSeconds(2)));
    ClientHttpRequestFactory requestFactory = messageSender.getRequestFactory();
    assertThat(requestFactory).isInstanceOf(HttpComponentsClientHttpRequestFactory.class);
    RequestConfig requestConfig = (RequestConfig) ReflectionTestUtils.getField(requestFactory, "requestConfig");
    assertThat(requestConfig).isNotNull();
    assertThat(requestConfig.getConnectTimeout()).isEqualTo(5000);
    assertThat(requestConfig.getSocketTimeout()).isEqualTo(2000);
}
Also used : RequestConfig(org.apache.http.client.config.RequestConfig) SimpleClientHttpRequestFactory(org.springframework.http.client.SimpleClientHttpRequestFactory) ClientHttpRequestFactory(org.springframework.http.client.ClientHttpRequestFactory) HttpComponentsClientHttpRequestFactory(org.springframework.http.client.HttpComponentsClientHttpRequestFactory) ClientHttpRequestMessageSender(org.springframework.ws.transport.http.ClientHttpRequestMessageSender) Test(org.junit.jupiter.api.Test)

Example 4 with ClientHttpRequestMessageSender

use of org.springframework.ws.transport.http.ClientHttpRequestMessageSender in project spring-boot by spring-projects.

the class HttpWebServiceMessageSenderBuilderTests method buildWithReadAndConnectTimeout.

@Test
void buildWithReadAndConnectTimeout() {
    ClientHttpRequestMessageSender messageSender = build(new HttpWebServiceMessageSenderBuilder().requestFactory(SimpleClientHttpRequestFactory::new).setConnectTimeout(Duration.ofSeconds(5)).setReadTimeout(Duration.ofSeconds(2)));
    SimpleClientHttpRequestFactory requestFactory = (SimpleClientHttpRequestFactory) messageSender.getRequestFactory();
    assertThat(requestFactory).hasFieldOrPropertyWithValue("connectTimeout", 5000);
    assertThat(requestFactory).hasFieldOrPropertyWithValue("readTimeout", 2000);
}
Also used : SimpleClientHttpRequestFactory(org.springframework.http.client.SimpleClientHttpRequestFactory) ClientHttpRequestMessageSender(org.springframework.ws.transport.http.ClientHttpRequestMessageSender) Test(org.junit.jupiter.api.Test)

Example 5 with ClientHttpRequestMessageSender

use of org.springframework.ws.transport.http.ClientHttpRequestMessageSender in project spring-boot by spring-projects.

the class HttpWebServiceMessageSenderBuilderTests method buildWithRequestFactorySupplier.

@Test
void buildWithRequestFactorySupplier() {
    ClientHttpRequestFactory requestFactory = mock(ClientHttpRequestFactory.class);
    ClientHttpRequestMessageSender messageSender = build(new HttpWebServiceMessageSenderBuilder().requestFactory(() -> requestFactory));
    assertThat(messageSender.getRequestFactory()).isSameAs(requestFactory);
}
Also used : SimpleClientHttpRequestFactory(org.springframework.http.client.SimpleClientHttpRequestFactory) ClientHttpRequestFactory(org.springframework.http.client.ClientHttpRequestFactory) HttpComponentsClientHttpRequestFactory(org.springframework.http.client.HttpComponentsClientHttpRequestFactory) ClientHttpRequestMessageSender(org.springframework.ws.transport.http.ClientHttpRequestMessageSender) Test(org.junit.jupiter.api.Test)

Aggregations

ClientHttpRequestMessageSender (org.springframework.ws.transport.http.ClientHttpRequestMessageSender)8 Test (org.junit.jupiter.api.Test)5 ClientHttpRequestFactory (org.springframework.http.client.ClientHttpRequestFactory)5 SimpleClientHttpRequestFactory (org.springframework.http.client.SimpleClientHttpRequestFactory)4 HttpComponentsClientHttpRequestFactory (org.springframework.http.client.HttpComponentsClientHttpRequestFactory)3 WebServiceTemplate (org.springframework.ws.client.core.WebServiceTemplate)2 RequestConfig (org.apache.http.client.config.RequestConfig)1 OkHttp3ClientHttpRequestFactory (org.springframework.http.client.OkHttp3ClientHttpRequestFactory)1