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+
117package org .springframework .ws .transport .http ;
218
19+ import static org .assertj .core .api .Assertions .*;
20+
321import java .time .Duration ;
422
523import org .apache .hc .client5 .http .impl .classic .CloseableHttpClient ;
624import org .apache .hc .client5 .http .impl .classic .HttpClientBuilder ;
725import org .junit .jupiter .api .Test ;
826
9- import static org .assertj .core .api .Assertions .*;
10-
1127class 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