|
20 | 20 | import java.util.List;
|
21 | 21 |
|
22 | 22 | import org.junit.jupiter.api.Test;
|
| 23 | +import org.junit.jupiter.api.condition.EnabledForJreRange; |
| 24 | +import org.junit.jupiter.api.condition.JRE; |
23 | 25 |
|
24 | 26 | import org.springframework.boot.autoconfigure.AutoConfigurations;
|
25 | 27 | import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
|
31 | 33 | import org.springframework.boot.ssl.SslBundle;
|
32 | 34 | import org.springframework.boot.ssl.SslBundles;
|
33 | 35 | import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
| 36 | +import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; |
| 37 | +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; |
34 | 38 | import org.springframework.boot.web.client.RestClientCustomizer;
|
35 | 39 | import org.springframework.boot.web.codec.CodecCustomizer;
|
36 | 40 | import org.springframework.context.annotation.Bean;
|
@@ -260,6 +264,39 @@ void shouldSupplyRestClientBuilderConfigurerWithAutoConfiguredHttpSettings() {
|
260 | 264 | });
|
261 | 265 | }
|
262 | 266 |
|
| 267 | + @Test |
| 268 | + void whenReactiveWebApplicationRestClientIsNotConfigured() { |
| 269 | + new ReactiveWebApplicationContextRunner() |
| 270 | + .withConfiguration(AutoConfigurations.of(RestClientAutoConfiguration.class)) |
| 271 | + .run((context) -> { |
| 272 | + assertThat(context).doesNotHaveBean(HttpMessageConvertersRestClientCustomizer.class); |
| 273 | + assertThat(context).doesNotHaveBean(RestClientBuilderConfigurer.class); |
| 274 | + assertThat(context).doesNotHaveBean(RestClient.Builder.class); |
| 275 | + }); |
| 276 | + } |
| 277 | + |
| 278 | + @Test |
| 279 | + void whenServletWebApplicationRestClientIsConfigured() { |
| 280 | + new WebApplicationContextRunner().withConfiguration(AutoConfigurations.of(RestClientAutoConfiguration.class)) |
| 281 | + .run((context) -> { |
| 282 | + assertThat(context).hasSingleBean(HttpMessageConvertersRestClientCustomizer.class); |
| 283 | + assertThat(context).hasSingleBean(RestClientBuilderConfigurer.class); |
| 284 | + assertThat(context).hasSingleBean(RestClient.Builder.class); |
| 285 | + }); |
| 286 | + } |
| 287 | + |
| 288 | + @Test |
| 289 | + @EnabledForJreRange(min = JRE.JAVA_21) |
| 290 | + void whenReactiveWebApplicationAndVirtualThreadsAreEnabledOnJava21AndLaterRestClientIsConfigured() { |
| 291 | + new ReactiveWebApplicationContextRunner().withPropertyValues("spring.threads.virtual.enabled=true") |
| 292 | + .withConfiguration(AutoConfigurations.of(RestClientAutoConfiguration.class)) |
| 293 | + .run((context) -> { |
| 294 | + assertThat(context).hasSingleBean(HttpMessageConvertersRestClientCustomizer.class); |
| 295 | + assertThat(context).hasSingleBean(RestClientBuilderConfigurer.class); |
| 296 | + assertThat(context).hasSingleBean(RestClient.Builder.class); |
| 297 | + }); |
| 298 | + } |
| 299 | + |
263 | 300 | @Configuration(proxyBeanMethods = false)
|
264 | 301 | static class CodecConfiguration {
|
265 | 302 |
|
|
0 commit comments