|
16 | 16 |
|
17 | 17 | package org.cloudfoundry.reactor;
|
18 | 18 |
|
| 19 | +import io.netty.handler.logging.ByteBufFormat; |
| 20 | +import io.netty.handler.logging.LogLevel; |
19 | 21 | import org.junit.After;
|
20 | 22 | import org.junit.Test;
|
| 23 | +import reactor.netty.http.client.HttpClient; |
| 24 | +import reactor.netty.transport.ProxyProvider; |
21 | 25 | import reactor.test.StepVerifier;
|
22 | 26 |
|
| 27 | +import java.net.InetSocketAddress; |
23 | 28 | import java.time.Duration;
|
| 29 | +import java.util.Optional; |
24 | 30 |
|
25 | 31 | import static io.netty.handler.codec.http.HttpMethod.GET;
|
26 | 32 | import static io.netty.handler.codec.http.HttpResponseStatus.OK;
|
| 33 | +import static org.assertj.core.api.Assertions.assertThat; |
27 | 34 |
|
28 | 35 | public final class DefaultConnectionContextTest extends AbstractRestTest {
|
29 | 36 |
|
@@ -85,4 +92,35 @@ public void multipleInstances() {
|
85 | 92 | second.dispose();
|
86 | 93 | }
|
87 | 94 |
|
| 95 | + @Test |
| 96 | + public void configurationAlwaysApplied() { |
| 97 | + DefaultConnectionContext ctx = DefaultConnectionContext.builder() |
| 98 | + .apiHost("api.example.com") |
| 99 | + .keepAlive(true) |
| 100 | + .proxyConfiguration( |
| 101 | + ProxyConfiguration.builder() |
| 102 | + .host("proxy.example.com") |
| 103 | + .port(8080) |
| 104 | + .username("foo") |
| 105 | + .password("bar") |
| 106 | + .build()) |
| 107 | + .skipSslValidation(true) |
| 108 | + .build(); |
| 109 | + |
| 110 | + assertThat(ctx.getConnectionPoolSize()).isEqualTo(24); |
| 111 | + assertThat(ctx.getApiHost()).isEqualTo("api.example.com"); |
| 112 | + assertThat(ctx.getSkipSslValidation()).isEqualTo(Optional.of(true)); |
| 113 | + |
| 114 | + HttpClient client = ctx.getHttpClient(); |
| 115 | + assertThat(client.configuration().isSecure()).isEqualTo(true); |
| 116 | + |
| 117 | + InetSocketAddress addr = client.configuration().proxyProvider().getAddress().get(); |
| 118 | + assertThat(addr.getHostName()).isEqualTo("proxy.example.com"); |
| 119 | + assertThat(addr.getPort()).isEqualTo(8080); |
| 120 | + assertThat(client.configuration().proxyProvider().getType()).isEqualTo(ProxyProvider.Proxy.HTTP); |
| 121 | + |
| 122 | + assertThat(client.configuration().loggingHandler().level()).isEqualTo(LogLevel.TRACE); |
| 123 | + assertThat(client.configuration().loggingHandler().byteBufFormat()).isEqualTo(ByteBufFormat.HEX_DUMP); |
| 124 | + } |
| 125 | + |
88 | 126 | }
|
0 commit comments