Enhance HttpComponents5MessageSender.

* The clientFactory could be null, so this must be handled.
* AuthScope.ANY no longer exists, so we need a suitable value object to take its place.
* Polish documentation and javadocs to support the community.

Resolves #1357.
This commit is contained in:
Lars Uffmann
2023-05-13 14:34:54 +02:00
committed by Greg L. Turnquist
parent 58c686874f
commit 24b466a0e1
3 changed files with 53 additions and 3 deletions

View File

@@ -0,0 +1,33 @@
package org.springframework.ws.transport.http;
import java.time.Duration;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.*;
class HttpComponents5MessageSenderTest {
@Test
void afterPropertiesSet_createHttpClient() throws Exception {
HttpComponents5MessageSender messageSender = new HttpComponents5MessageSender();
assertThat(messageSender.getHttpClient()).isNull();
Duration timeout = Duration.ofSeconds(1);
assertThatCode(() -> messageSender.setConnectionTimeout(timeout)).doesNotThrowAnyException();
messageSender.afterPropertiesSet();
assertThat(messageSender.getHttpClient()).isNotNull();
}
@Test
void afterPropertiesSet_httpClientAlreadySet() throws Exception {
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpComponents5MessageSender messageSender = new HttpComponents5MessageSender(httpClient);
Duration timeout = Duration.ofSeconds(1);
assertThatCode(() -> messageSender.setConnectionTimeout(timeout)).isInstanceOf(IllegalStateException.class);
messageSender.afterPropertiesSet();
assertThat(messageSender.getHttpClient()).isSameAs(httpClient);
}
}