|
19 | 19 | import java.util.List;
|
20 | 20 |
|
21 | 21 | import org.junit.jupiter.api.Test;
|
| 22 | +import org.junit.jupiter.api.condition.EnabledForJreRange; |
| 23 | +import org.junit.jupiter.api.condition.JRE; |
22 | 24 |
|
23 | 25 | import org.springframework.boot.autoconfigure.AutoConfigurations;
|
24 | 26 | import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
|
29 | 31 | import org.springframework.boot.http.client.ClientHttpRequestFactorySettings.Redirects;
|
30 | 32 | import org.springframework.boot.ssl.SslBundles;
|
31 | 33 | import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
| 34 | +import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; |
| 35 | +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; |
32 | 36 | import org.springframework.boot.web.client.RestClientCustomizer;
|
33 | 37 | import org.springframework.boot.web.codec.CodecCustomizer;
|
34 | 38 | import org.springframework.context.annotation.Bean;
|
@@ -225,6 +229,39 @@ void shouldSupplyRestClientBuilderConfigurerWithAutoConfiguredHttpSettings() {
|
225 | 229 | });
|
226 | 230 | }
|
227 | 231 |
|
| 232 | + @Test |
| 233 | + void whenReactiveWebApplicationRestClientIsNotConfigured() { |
| 234 | + new ReactiveWebApplicationContextRunner() |
| 235 | + .withConfiguration(AutoConfigurations.of(RestClientAutoConfiguration.class)) |
| 236 | + .run((context) -> { |
| 237 | + assertThat(context).doesNotHaveBean(HttpMessageConvertersRestClientCustomizer.class); |
| 238 | + assertThat(context).doesNotHaveBean(RestClientBuilderConfigurer.class); |
| 239 | + assertThat(context).doesNotHaveBean(RestClient.Builder.class); |
| 240 | + }); |
| 241 | + } |
| 242 | + |
| 243 | + @Test |
| 244 | + void whenServletWebApplicationRestClientIsConfigured() { |
| 245 | + new WebApplicationContextRunner().withConfiguration(AutoConfigurations.of(RestClientAutoConfiguration.class)) |
| 246 | + .run((context) -> { |
| 247 | + assertThat(context).hasSingleBean(HttpMessageConvertersRestClientCustomizer.class); |
| 248 | + assertThat(context).hasSingleBean(RestClientBuilderConfigurer.class); |
| 249 | + assertThat(context).hasSingleBean(RestClient.Builder.class); |
| 250 | + }); |
| 251 | + } |
| 252 | + |
| 253 | + @Test |
| 254 | + @EnabledForJreRange(min = JRE.JAVA_21) |
| 255 | + void whenReactiveWebApplicationAndVirtualThreadsAreEnabledOnJava21AndLaterRestClientIsConfigured() { |
| 256 | + new ReactiveWebApplicationContextRunner().withPropertyValues("spring.threads.virtual.enabled=true") |
| 257 | + .withConfiguration(AutoConfigurations.of(RestClientAutoConfiguration.class)) |
| 258 | + .run((context) -> { |
| 259 | + assertThat(context).hasSingleBean(HttpMessageConvertersRestClientCustomizer.class); |
| 260 | + assertThat(context).hasSingleBean(RestClientBuilderConfigurer.class); |
| 261 | + assertThat(context).hasSingleBean(RestClient.Builder.class); |
| 262 | + }); |
| 263 | + } |
| 264 | + |
228 | 265 | @Configuration(proxyBeanMethods = false)
|
229 | 266 | static class CodecConfiguration {
|
230 | 267 |
|
|
0 commit comments