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:
committed by
Greg L. Turnquist
parent
58c686874f
commit
24b466a0e1
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user