|
28 | 28 | import org.springframework.boot.http.client.ClientHttpRequestFactorySettings;
|
29 | 29 | import org.springframework.boot.http.client.ClientHttpRequestFactorySettings.Redirects;
|
30 | 30 | import org.springframework.boot.http.client.HttpComponentsClientHttpRequestFactoryBuilder;
|
| 31 | +import org.springframework.boot.http.client.JdkClientHttpRequestFactoryBuilder; |
31 | 32 | import org.springframework.boot.http.client.JettyClientHttpRequestFactoryBuilder;
|
| 33 | +import org.springframework.boot.http.client.ReactorClientHttpRequestFactoryBuilder; |
32 | 34 | import org.springframework.boot.http.client.SimpleClientHttpRequestFactoryBuilder;
|
| 35 | +import org.springframework.boot.test.context.FilteredClassLoader; |
33 | 36 | import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
34 | 37 | import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
|
35 | 38 | import org.springframework.context.annotation.Bean;
|
@@ -87,6 +90,32 @@ private List<String> sslPropertyValues() {
|
87 | 90 | return propertyValues;
|
88 | 91 | }
|
89 | 92 |
|
| 93 | + @Test |
| 94 | + void whenHttpComponentsIsUnavailableThenJettyClientBeansAreDefined() { |
| 95 | + this.contextRunner |
| 96 | + .withClassLoader(new FilteredClassLoader(org.apache.hc.client5.http.impl.classic.HttpClients.class)) |
| 97 | + .run((context) -> assertThat(context.getBean(ClientHttpRequestFactoryBuilder.class)) |
| 98 | + .isExactlyInstanceOf(JettyClientHttpRequestFactoryBuilder.class)); |
| 99 | + } |
| 100 | + |
| 101 | + @Test |
| 102 | + void whenHttpComponentsAndJettyAreUnavailableThenReactorClientBeansAreDefined() { |
| 103 | + this.contextRunner |
| 104 | + .withClassLoader(new FilteredClassLoader(org.apache.hc.client5.http.impl.classic.HttpClients.class, |
| 105 | + org.eclipse.jetty.client.HttpClient.class)) |
| 106 | + .run((context) -> assertThat(context.getBean(ClientHttpRequestFactoryBuilder.class)) |
| 107 | + .isExactlyInstanceOf(ReactorClientHttpRequestFactoryBuilder.class)); |
| 108 | + } |
| 109 | + |
| 110 | + @Test |
| 111 | + void whenHttpComponentsAndJettyAndReactorAreUnavailableThenJdkClientBeansAreDefined() { |
| 112 | + this.contextRunner |
| 113 | + .withClassLoader(new FilteredClassLoader(org.apache.hc.client5.http.impl.classic.HttpClients.class, |
| 114 | + org.eclipse.jetty.client.HttpClient.class, reactor.netty.http.client.HttpClient.class)) |
| 115 | + .run((context) -> assertThat(context.getBean(ClientHttpRequestFactoryBuilder.class)) |
| 116 | + .isExactlyInstanceOf(JdkClientHttpRequestFactoryBuilder.class)); |
| 117 | + } |
| 118 | + |
90 | 119 | @Test
|
91 | 120 | void whenReactiveWebApplicationBeansAreNotConfigured() {
|
92 | 121 | new ReactiveWebApplicationContextRunner().withConfiguration(autoConfigurations)
|
|
0 commit comments