|
27 | 27 | import org.springframework.boot.autoconfigure.http.HttpMessageConverters; |
28 | 28 | import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration; |
29 | 29 | import org.springframework.boot.autoconfigure.http.client.HttpClientAutoConfiguration; |
| 30 | +import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration; |
30 | 31 | import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder; |
31 | 32 | import org.springframework.boot.http.client.ClientHttpRequestFactorySettings; |
32 | 33 | import org.springframework.boot.http.client.ClientHttpRequestFactorySettings.Redirects; |
|
57 | 58 | * @author Arjen Poutsma |
58 | 59 | * @author Moritz Halbritter |
59 | 60 | * @author Dmytro Nosan |
| 61 | + * @author Dmitry Sulman |
60 | 62 | */ |
61 | 63 | class RestClientAutoConfigurationTests { |
62 | 64 |
|
@@ -287,16 +289,34 @@ void whenServletWebApplicationRestClientIsConfigured() { |
287 | 289 |
|
288 | 290 | @Test |
289 | 291 | @EnabledForJreRange(min = JRE.JAVA_21) |
290 | | - void whenReactiveWebApplicationAndVirtualThreadsAreEnabledOnJava21AndLaterRestClientIsConfigured() { |
| 292 | + void whenReactiveWebApplicationAndVirtualThreadsEnabledAndTaskExecutorBean() { |
291 | 293 | new ReactiveWebApplicationContextRunner().withPropertyValues("spring.threads.virtual.enabled=true") |
292 | | - .withConfiguration(AutoConfigurations.of(RestClientAutoConfiguration.class)) |
| 294 | + .withConfiguration( |
| 295 | + AutoConfigurations.of(RestClientAutoConfiguration.class, TaskExecutionAutoConfiguration.class)) |
293 | 296 | .run((context) -> { |
294 | 297 | assertThat(context).hasSingleBean(HttpMessageConvertersRestClientCustomizer.class); |
295 | 298 | assertThat(context).hasSingleBean(RestClientBuilderConfigurer.class); |
296 | 299 | assertThat(context).hasSingleBean(RestClient.Builder.class); |
297 | 300 | }); |
298 | 301 | } |
299 | 302 |
|
| 303 | + @Test |
| 304 | + @EnabledForJreRange(min = JRE.JAVA_21) |
| 305 | + void whenReactiveWebApplicationAndVirtualThreadsDisabled() { |
| 306 | + new ReactiveWebApplicationContextRunner().withPropertyValues("spring.threads.virtual.enabled=false") |
| 307 | + .withConfiguration( |
| 308 | + AutoConfigurations.of(RestClientAutoConfiguration.class, TaskExecutionAutoConfiguration.class)) |
| 309 | + .run((context) -> assertThat(context).doesNotHaveBean(RestClient.Builder.class)); |
| 310 | + } |
| 311 | + |
| 312 | + @Test |
| 313 | + @EnabledForJreRange(min = JRE.JAVA_21) |
| 314 | + void whenReactiveWebApplicationAndVirtualThreadsEnabledAndNoTaskExecutorBean() { |
| 315 | + new ReactiveWebApplicationContextRunner().withPropertyValues("spring.threads.virtual.enabled=true") |
| 316 | + .withConfiguration(AutoConfigurations.of(RestClientAutoConfiguration.class)) |
| 317 | + .run((context) -> assertThat(context).doesNotHaveBean(RestClient.Builder.class)); |
| 318 | + } |
| 319 | + |
300 | 320 | @Configuration(proxyBeanMethods = false) |
301 | 321 | static class CodecConfiguration { |
302 | 322 |
|
|
0 commit comments