From f600a9c4d72293c68cf5f904bdb1699a4f307df0 Mon Sep 17 00:00:00 2001 From: Stephane Maldini Date: Wed, 25 Oct 2017 15:00:42 -0700 Subject: [PATCH] fix test builder when dns resolving --- .../http/client/HttpClientOptionsTest.java | 12 ++++--- .../http/server/HttpServerOptionsTest.java | 5 +-- .../ipc/netty/options/ClientOptionsTest.java | 9 +++-- .../options/ClientProxyOptionsTests.java | 33 +++++++++++-------- 4 files changed, 36 insertions(+), 23 deletions(-) diff --git a/src/test/java/reactor/ipc/netty/http/client/HttpClientOptionsTest.java b/src/test/java/reactor/ipc/netty/http/client/HttpClientOptionsTest.java index a2364f2e64..6872376850 100644 --- a/src/test/java/reactor/ipc/netty/http/client/HttpClientOptionsTest.java +++ b/src/test/java/reactor/ipc/netty/http/client/HttpClientOptionsTest.java @@ -62,19 +62,22 @@ public void asDetailedString() { //proxy this.builder.proxy(proxyOptions); assertThat(this.builder.build().asDetailedString()) - .startsWith("connectAddress=null, proxy=SOCKS4(http://proxy:456)") + .startsWith("connectAddress=null, proxy=SOCKS4(http://proxy") + .contains(":456)") .endsWith(", acceptGzip=false"); //address this.builder.host("http://google.com").port(123); assertThat(this.builder.build().asDetailedString()) - .startsWith("connectAddress=http://google.com:123, proxy=SOCKS4(http://proxy:456)") + .startsWith("connectAddress=http://google.com:123, proxy=SOCKS4(http://proxy") + .contains(":456)") .endsWith(", acceptGzip=false"); //gzip this.builder.compression(true); assertThat(this.builder.build().asDetailedString()) - .startsWith("connectAddress=http://google.com:123, proxy=SOCKS4(http://proxy:456)") + .startsWith("connectAddress=http://google.com:123, proxy=SOCKS4(http://proxy") + .contains(":456)") .endsWith(", acceptGzip=true"); } @@ -85,7 +88,8 @@ public void toStringContainsAsDetailedString() { .proxy(proxyOptions) .compression(true); assertThat(this.builder.build().toString()) - .startsWith("HttpClientOptions{connectAddress=http://google.com:123, proxy=SOCKS4(http://proxy:456)") + .startsWith("HttpClientOptions{connectAddress=http://google.com:123, proxy=SOCKS4(http://proxy") + .contains(":456)") .endsWith(", acceptGzip=true}"); } diff --git a/src/test/java/reactor/ipc/netty/http/server/HttpServerOptionsTest.java b/src/test/java/reactor/ipc/netty/http/server/HttpServerOptionsTest.java index e10919a108..e93e106a9f 100644 --- a/src/test/java/reactor/ipc/netty/http/server/HttpServerOptionsTest.java +++ b/src/test/java/reactor/ipc/netty/http/server/HttpServerOptionsTest.java @@ -99,10 +99,11 @@ public void asDetailedString() { public void toStringContainsAsDetailedString() { HttpServerOptions.Builder builder = HttpServerOptions.builder() .compression(534) - .host("http://google.com") + .host("google.com") .port(123); assertThat(builder.build().toString()) - .startsWith("HttpServerOptions{address=http://google.com:123") + .startsWith("HttpServerOptions{address=google.com") + .contains(":123") .endsWith(", minCompressionResponseSize=534}"); } diff --git a/src/test/java/reactor/ipc/netty/options/ClientOptionsTest.java b/src/test/java/reactor/ipc/netty/options/ClientOptionsTest.java index af91e3afbf..cbb08cb381 100644 --- a/src/test/java/reactor/ipc/netty/options/ClientOptionsTest.java +++ b/src/test/java/reactor/ipc/netty/options/ClientOptionsTest.java @@ -57,12 +57,14 @@ public void asDetailedString() { //proxy this.builder.proxy(this.proxyOptions); assertThat(this.builder.build().asDetailedString()) - .startsWith("connectAddress=null, proxy=SOCKS4(http://proxy:456)"); + .startsWith("connectAddress=null, proxy=SOCKS4(http://proxy") + .contains(":456)"); //address this.builder.host("http://google.com").port(123); assertThat(this.builder.build().asDetailedString()) - .startsWith("connectAddress=http://google.com:123, proxy=SOCKS4(http://proxy:456)"); + .startsWith("connectAddress=http://google.com:123, proxy=SOCKS4(http://proxy") + .contains(":456)"); } @Test @@ -72,7 +74,8 @@ public void toStringContainsAsDetailedString() { .proxy(proxyOptions) .build(); assertThat(this.builder.build().toString()) - .startsWith("ClientOptions{connectAddress=http://google.com:123, proxy=SOCKS4(http://proxy:456)") + .startsWith("ClientOptions{connectAddress=http://google.com:123, proxy=SOCKS4(http://proxy") + .contains(":456)") .endsWith("}"); } diff --git a/src/test/java/reactor/ipc/netty/options/ClientProxyOptionsTests.java b/src/test/java/reactor/ipc/netty/options/ClientProxyOptionsTests.java index 99c072f7ba..1ec752ba74 100644 --- a/src/test/java/reactor/ipc/netty/options/ClientProxyOptionsTests.java +++ b/src/test/java/reactor/ipc/netty/options/ClientProxyOptionsTests.java @@ -15,17 +15,16 @@ */ package reactor.ipc.netty.options; -import static org.assertj.core.api.Assertions.assertThat; - import java.net.InetSocketAddress; -import org.junit.Test; - import io.netty.handler.proxy.HttpProxyHandler; import io.netty.handler.proxy.Socks4ProxyHandler; import io.netty.handler.proxy.Socks5ProxyHandler; +import org.junit.Test; import reactor.ipc.netty.options.ClientProxyOptions.Proxy; +import static org.assertj.core.api.Assertions.assertThat; + public class ClientProxyOptionsTests { @Test @@ -34,10 +33,12 @@ public void asSimpleString() { ClientProxyOptions.AddressSpec addrSpec = typeSpec.type(Proxy.HTTP); ClientProxyOptions.Builder builder = addrSpec.host("http://proxy").port(456); - assertThat(builder.build().asSimpleString()).isEqualTo("proxy=HTTP(http://proxy:456)"); + assertThat(builder.build().asSimpleString()).startsWith("proxy=HTTP" + + "(http://proxy").endsWith(":456)"); builder = addrSpec.address(new InetSocketAddress("http://another.proxy", 123)); - assertThat(builder.build().asSimpleString()).isEqualTo("proxy=HTTP(http://another.proxy:123)"); + assertThat(builder.build().asSimpleString()).startsWith("proxy=HTTP" + + "(http://another.proxy").endsWith(":123)"); } @Test @@ -47,15 +48,18 @@ public void asDetailedString() { ClientProxyOptions.AddressSpec addrSpec = typeSpec.type(Proxy.HTTP); ClientProxyOptions.Builder builder = addrSpec.host("http://proxy").port(456); assertThat(builder.build().asDetailedString()) - .isEqualTo("address=http://proxy:456, nonProxyHosts=null, type=HTTP"); + .startsWith("address=http://proxy") + .endsWith(":456, nonProxyHosts=null, type=HTTP"); builder = addrSpec.address(() -> new InetSocketAddress("http://another.proxy", 123)); assertThat(builder.build().asDetailedString()) - .isEqualTo("address=http://another.proxy:123, nonProxyHosts=null, type=HTTP"); + .startsWith("address=http://another.proxy") + .endsWith(":123, nonProxyHosts=null, type=HTTP"); builder.nonProxyHosts("localhost"); assertThat(builder.build().asDetailedString()) - .isEqualTo("address=http://another.proxy:123, nonProxyHosts=localhost, type=HTTP"); + .startsWith("address=http://another.proxy") + .endsWith(":123, nonProxyHosts=localhost, type=HTTP"); } @Test @@ -64,8 +68,9 @@ public void toStringContainsAsDetailedString() { ClientProxyOptions.Builder builder = typeSpec.type(Proxy.HTTP) .host("http://proxy") .port(456); - assertThat(builder.build().toString()).isEqualTo( - "ClientProxyOptions{address=http://proxy:456, nonProxyHosts=null, type=HTTP}"); + assertThat(builder.build().toString()).startsWith( + "ClientProxyOptions{address=http://proxy") + .endsWith(":456, nonProxyHosts=null, type=HTTP}"); } @Test @@ -76,7 +81,7 @@ public void getProxyHandlerTypeHttp() { .port(456); assertThat(builder.build().newProxyHandler()).isInstanceOf(HttpProxyHandler.class); - assertThat(builder.build().newProxyHandler().proxyAddress().toString()).isEqualTo("http://proxy:456"); + assertThat(builder.build().newProxyHandler().proxyAddress().toString()).startsWith("http://proxy").endsWith(":456"); builder.username("test1"); assertThat(((HttpProxyHandler) builder.build().newProxyHandler()).username()).isNull(); @@ -94,7 +99,7 @@ public void getProxyHandlerTypeSocks4() { .port(456); assertThat(builder.build().newProxyHandler()).isInstanceOf(Socks4ProxyHandler.class); - assertThat(builder.build().newProxyHandler().proxyAddress().toString()).isEqualTo("http://proxy:456"); + assertThat(builder.build().newProxyHandler().proxyAddress().toString()).startsWith("http://proxy").endsWith(":456"); builder.username("test1"); assertThat(((Socks4ProxyHandler) builder.build().newProxyHandler()).username()).isEqualTo("test1"); @@ -108,7 +113,7 @@ public void getProxyHandlerTypeSocks5() { .port(456); assertThat(builder.build().newProxyHandler()).isInstanceOf(Socks5ProxyHandler.class); - assertThat(builder.build().newProxyHandler().proxyAddress().toString()).isEqualTo("http://proxy:456"); + assertThat(builder.build().newProxyHandler().proxyAddress().toString()).startsWith("http://proxy").endsWith(":456"); builder.username("test1"); assertThat(((Socks5ProxyHandler) builder.build().newProxyHandler()).username()).isNull();