|
21 | 21 | import com.github.tomakehurst.wiremock.WireMockServer; |
22 | 22 | import com.github.tomakehurst.wiremock.http.Fault; |
23 | 23 | import io.netty.handler.proxy.ProxyConnectException; |
| 24 | +import io.netty.resolver.DefaultAddressResolverGroup; |
| 25 | +import io.netty.resolver.NoopAddressResolverGroup; |
24 | 26 | import org.junit.jupiter.api.AfterAll; |
25 | 27 | import org.junit.jupiter.api.Assertions; |
26 | 28 | import org.junit.jupiter.api.BeforeAll; |
|
32 | 34 | import reactor.core.publisher.Flux; |
33 | 35 | import reactor.core.publisher.Mono; |
34 | 36 | import reactor.core.scheduler.Schedulers; |
| 37 | +import reactor.netty.resources.ConnectionProvider; |
35 | 38 | import reactor.test.StepVerifier; |
36 | 39 | import reactor.test.StepVerifierOptions; |
37 | 40 |
|
|
56 | 59 | import static org.junit.jupiter.api.Assertions.assertEquals; |
57 | 60 | import static org.junit.jupiter.api.Assertions.assertFalse; |
58 | 61 | import static org.junit.jupiter.api.Assertions.assertLinesMatch; |
| 62 | +import static org.junit.jupiter.api.Assertions.assertNotEquals; |
59 | 63 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
60 | 64 |
|
61 | 65 | public class NettyAsyncHttpClientTests { |
@@ -436,6 +440,41 @@ public void failedProxyAuthenticationReturnsCorrectError() { |
436 | 440 | } |
437 | 441 | } |
438 | 442 |
|
| 443 | + @Test |
| 444 | + public void httpClientWithDefaultResolverUsesNoopResolverWithProxy() { |
| 445 | + try (MockProxyServer mockProxyServer = new MockProxyServer()) { |
| 446 | + NettyAsyncHttpClient httpClient = (NettyAsyncHttpClient) new NettyAsyncHttpClientBuilder() |
| 447 | + .proxy(new ProxyOptions(ProxyOptions.Type.HTTP, mockProxyServer.socketAddress())) |
| 448 | + .build(); |
| 449 | + |
| 450 | + assertEquals(NoopAddressResolverGroup.INSTANCE, httpClient.nettyClient.configuration().resolver()); |
| 451 | + } |
| 452 | + } |
| 453 | + |
| 454 | + @Test |
| 455 | + public void httpClientWithConnectionProviderUsesNoopResolverWithProxy() { |
| 456 | + try (MockProxyServer mockProxyServer = new MockProxyServer()) { |
| 457 | + NettyAsyncHttpClient httpClient = (NettyAsyncHttpClient) new NettyAsyncHttpClientBuilder() |
| 458 | + .connectionProvider(ConnectionProvider.newConnection()) |
| 459 | + .proxy(new ProxyOptions(ProxyOptions.Type.HTTP, mockProxyServer.socketAddress())) |
| 460 | + .build(); |
| 461 | + |
| 462 | + assertEquals(NoopAddressResolverGroup.INSTANCE, httpClient.nettyClient.configuration().resolver()); |
| 463 | + } |
| 464 | + } |
| 465 | + |
| 466 | + @Test |
| 467 | + public void httpClientWithResolverUsesConfiguredResolverWithProxy() { |
| 468 | + try (MockProxyServer mockProxyServer = new MockProxyServer()) { |
| 469 | + NettyAsyncHttpClient httpClient = (NettyAsyncHttpClient) new NettyAsyncHttpClientBuilder( |
| 470 | + reactor.netty.http.client.HttpClient.create().resolver(DefaultAddressResolverGroup.INSTANCE)) |
| 471 | + .proxy(new ProxyOptions(ProxyOptions.Type.HTTP, mockProxyServer.socketAddress())) |
| 472 | + .build(); |
| 473 | + |
| 474 | + assertNotEquals(NoopAddressResolverGroup.INSTANCE, httpClient.nettyClient.configuration().resolver()); |
| 475 | + } |
| 476 | + } |
| 477 | + |
439 | 478 | private static Stream<Arguments> requestHeaderSupplier() { |
440 | 479 | return Stream.of( |
441 | 480 | Arguments.of(null, NettyAsyncHttpClientResponseTransformer.NULL_REPLACEMENT), |
|
0 commit comments