|
23 | 23 | import org.apache.hc.client5.http.impl.async.HttpAsyncClients; |
24 | 24 | import org.junit.jupiter.api.Test; |
25 | 25 | import reactor.netty.http.client.HttpClient; |
| 26 | +import reactor.netty.resources.LoopResources; |
26 | 27 |
|
27 | 28 | import org.springframework.beans.factory.config.BeanDefinition; |
28 | 29 | import org.springframework.boot.autoconfigure.AutoConfigurations; |
@@ -114,6 +115,21 @@ void shouldUseCustomReactorResourceFactory() { |
114 | 115 | assertThat(context).hasSingleBean(ClientHttpConnector.class); |
115 | 116 | assertThat(context).hasSingleBean(ReactorResourceFactory.class); |
116 | 117 | assertThat(context).hasBean("customReactorResourceFactory"); |
| 118 | + ClientHttpConnector connector = context.getBean(ClientHttpConnector.class); |
| 119 | + assertThat(connector).extracting("httpClient.config.loopResources") |
| 120 | + .isEqualTo(context.getBean("customReactorResourceFactory", ReactorResourceFactory.class) |
| 121 | + .getLoopResources()); |
| 122 | + }); |
| 123 | + } |
| 124 | + |
| 125 | + @Test |
| 126 | + void shouldUseReactorResourceFactory() { |
| 127 | + this.contextRunner.run((context) -> { |
| 128 | + assertThat(context).hasSingleBean(ClientHttpConnector.class); |
| 129 | + assertThat(context).hasSingleBean(ReactorResourceFactory.class); |
| 130 | + ClientHttpConnector connector = context.getBean(ClientHttpConnector.class); |
| 131 | + assertThat(connector).extracting("httpClient.config.loopResources") |
| 132 | + .isEqualTo(context.getBean(ReactorResourceFactory.class).getLoopResources()); |
117 | 133 | }); |
118 | 134 | } |
119 | 135 |
|
@@ -190,7 +206,10 @@ static class CustomReactorResourceConfig { |
190 | 206 |
|
191 | 207 | @Bean |
192 | 208 | ReactorResourceFactory customReactorResourceFactory() { |
193 | | - return new ReactorResourceFactory(); |
| 209 | + ReactorResourceFactory reactorResourceFactory = new ReactorResourceFactory(); |
| 210 | + reactorResourceFactory.setUseGlobalResources(false); |
| 211 | + reactorResourceFactory.setLoopResources(LoopResources.create("custom-loop", 1, true)); |
| 212 | + return reactorResourceFactory; |
194 | 213 | } |
195 | 214 |
|
196 | 215 | } |
|
0 commit comments