Skip to content

Commit 8dbb04d

Browse files
committed
Polishing.
See #1357.
1 parent 24b466a commit 8dbb04d

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponents5ClientFactory.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@
4545
public class HttpComponents5ClientFactory implements FactoryBean<CloseableHttpClient> {
4646

4747
/**
48-
* AuthScope to match any Host.
48+
* {@link AuthScope} to match any Host.
4949
* <p>
50-
* <b>HEADS-UP</b>: ANY has been removed from {@link AuthScope} since httpcomponents version 5.x. It has been
51-
* redefined here to ease migration from httpcomponents 4. The associated functionality might be removed in a future
52-
* version of apache httpcomponents. Consider using a {@link ClientInterceptor} to implement http client agnostic
50+
* <b>NOTE</b>: {@code ANY} was removed from {@link AuthScope} in HttpComponents 5.0. This value object will easy
51+
* migration from HttpComponents 4. Consider using a {@link ClientInterceptor} to implement http client agnostic
5352
* preemptive basic auth.
5453
*
5554
* @see AuthScope#AuthScope(String, String, int, String, String)
@@ -91,7 +90,7 @@ public void setCredentials(Credentials credentials) {
9190
/**
9291
* Sets the authentication scope to be used. Only used when the {@code credentials} property has been set.
9392
* <p>
94-
* By default, the {@link #ANY} is used.
93+
* By default, {@link #ANY} is used.
9594
*
9695
* @see #setCredentials(Credentials)
9796
*/
Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,54 @@
1+
/*
2+
* Copyright 2005-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.springframework.ws.transport.http;
218

19+
import static org.assertj.core.api.Assertions.*;
20+
321
import java.time.Duration;
422

523
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
624
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
725
import org.junit.jupiter.api.Test;
826

9-
import static org.assertj.core.api.Assertions.*;
10-
1127
class HttpComponents5MessageSenderTest {
1228

1329
@Test
14-
void afterPropertiesSet_createHttpClient() throws Exception {
30+
void afterPropertiesSetShouldProperlyInitializeHttpClient() throws Exception {
31+
1532
HttpComponents5MessageSender messageSender = new HttpComponents5MessageSender();
1633
assertThat(messageSender.getHttpClient()).isNull();
34+
1735
Duration timeout = Duration.ofSeconds(1);
1836
assertThatCode(() -> messageSender.setConnectionTimeout(timeout)).doesNotThrowAnyException();
37+
1938
messageSender.afterPropertiesSet();
2039
assertThat(messageSender.getHttpClient()).isNotNull();
2140
}
2241

2342
@Test
24-
void afterPropertiesSet_httpClientAlreadySet() throws Exception {
43+
void afterPropertiesSetShouldUseAlreadyProvidedHttpClientIfAvailable() throws Exception {
44+
2545
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
2646
HttpComponents5MessageSender messageSender = new HttpComponents5MessageSender(httpClient);
47+
2748
Duration timeout = Duration.ofSeconds(1);
2849
assertThatCode(() -> messageSender.setConnectionTimeout(timeout)).isInstanceOf(IllegalStateException.class);
50+
2951
messageSender.afterPropertiesSet();
3052
assertThat(messageSender.getHttpClient()).isSameAs(httpClient);
3153
}
32-
33-
}
54+
}

0 commit comments

Comments
 (0)