|
25 | 25 | import java.util.function.Supplier;
|
26 | 26 |
|
27 | 27 | import okhttp3.OkHttpClient;
|
28 |
| -import org.apache.http.client.config.RequestConfig; |
29 | 28 | import org.assertj.core.api.InstanceOfAssertFactories;
|
30 | 29 | import org.junit.jupiter.api.Test;
|
31 | 30 | import org.junit.jupiter.api.extension.ExtendWith;
|
|
63 | 62 | import static org.assertj.core.api.Assertions.assertThat;
|
64 | 63 | import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
65 | 64 | import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
| 65 | +import static org.assertj.core.api.Assertions.assertThatThrownBy; |
66 | 66 | import static org.assertj.core.api.Assertions.entry;
|
67 | 67 | import static org.mockito.ArgumentMatchers.any;
|
68 | 68 | import static org.mockito.BDDMockito.then;
|
|
81 | 81 | * @author Dmytro Nosan
|
82 | 82 | * @author Kevin Strijbos
|
83 | 83 | * @author Ilya Lukyanovich
|
| 84 | + * @author Brian Clozel |
84 | 85 | */
|
85 | 86 | @ExtendWith(MockitoExtension.class)
|
86 | 87 | class RestTemplateBuilderTests {
|
@@ -477,17 +478,14 @@ void connectTimeoutCanBeConfiguredOnHttpComponentsRequestFactory() {
|
477 | 478 | ClientHttpRequestFactory requestFactory = this.builder
|
478 | 479 | .requestFactory(HttpComponentsClientHttpRequestFactory.class).setConnectTimeout(Duration.ofMillis(1234))
|
479 | 480 | .build().getRequestFactory();
|
480 |
| - assertThat(((RequestConfig) ReflectionTestUtils.getField(requestFactory, "requestConfig")).getConnectTimeout()) |
481 |
| - .isEqualTo(1234); |
| 481 | + assertThat(((int) ReflectionTestUtils.getField(requestFactory, "connectTimeout"))).isEqualTo(1234); |
482 | 482 | }
|
483 | 483 |
|
484 | 484 | @Test
|
485 |
| - void readTimeoutCanBeConfiguredOnHttpComponentsRequestFactory() { |
486 |
| - ClientHttpRequestFactory requestFactory = this.builder |
487 |
| - .requestFactory(HttpComponentsClientHttpRequestFactory.class).setReadTimeout(Duration.ofMillis(1234)) |
488 |
| - .build().getRequestFactory(); |
489 |
| - assertThat(((RequestConfig) ReflectionTestUtils.getField(requestFactory, "requestConfig")).getSocketTimeout()) |
490 |
| - .isEqualTo(1234); |
| 485 | + void readTimeoutConfigurationFailsOnHttpComponentsRequestFactory() { |
| 486 | + assertThatThrownBy(() -> this.builder.requestFactory(HttpComponentsClientHttpRequestFactory.class) |
| 487 | + .setReadTimeout(Duration.ofMillis(1234)).build()).isInstanceOf(IllegalStateException.class) |
| 488 | + .hasMessageContaining("setReadTimeout method marked as deprecated"); |
491 | 489 | }
|
492 | 490 |
|
493 | 491 | @Test
|
|
0 commit comments