Skip to content

Commit

Permalink
Use example.com urls instead of foo/google
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbasle authored and smaldini committed May 16, 2019
1 parent d7267e1 commit 1ad3178
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 94 deletions.
40 changes: 0 additions & 40 deletions src/test/java/reactor/netty/channel/FluxReceiveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,44 +126,4 @@ public void testByteBufsReleasedWhenTimeoutUsingHandlers() {
server1.disposeNow();
server2.disposeNow();
}

/*static final Logger logger = Loggers.getLogger(FluxReceiveTest.class);
@Test
public void issue362() throws InterruptedException {
HttpClient client = HttpClient.newConnection()
.tcpConfiguration(tcp -> tcp.runOn(LoopResources.create("my-loop", 2, false))
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 2000));
client.doOnRequest((req, c) -> c.addHandlerFirst(new IdleStateHandler(1, 0, 0))
.addHandlerLast(new ChannelDuplexHandler() {
@Override
public void userEventTriggered(
ChannelHandlerContext ctx,
Object evt) throws Exception {
if (evt instanceof IdleStateEvent) {
ctx.close();
}
else {
super.userEventTriggered(ctx, evt);
}
}
}))
.get()
.uri("http://releases.ubuntu.com/16.04.4/ubuntu-16.04.4-desktop-amd64.iso")
.responseContent()
.log(logger.getName())
.retry(IOException.class::isInstance)
.subscribe(byteBuf -> {
logger.info("Msg: {}", byteBuf);
Flux.just(1, 2, 3)
.onErrorReturn(8)
.subscribe(i -> {
throw new RuntimeException(i + " error");
});
});
Thread.sleep(Duration.ofMinutes(5)
.toMillis());
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void httpStatusCode404IsHandledByTheClient() {

Mono<Integer> content = client.headers(h -> h.add("Content-Type", "text/plain"))
.request(HttpMethod.GET)
.uri("/unsupportedURI")
.uri("/status/404")
.send(ByteBufFlux.fromString(Flux.just("Hello")
.log("client-send")))
.responseSingle((res, buf) -> Mono.just(res.status().code()))
Expand Down
60 changes: 26 additions & 34 deletions src/test/java/reactor/netty/http/client/HttpClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,41 +321,33 @@ public void serverInfiniteClientClose() throws Exception {
}

@Test
@Ignore
public void postUpload() throws IOException {
HttpClient client =
HttpClient.create()
.tcpConfiguration(tcpClient -> tcpClient.host("google.com"))
.tcpConfiguration(tcpClient -> tcpClient.host("httpbin.org"))
.wiretap(true);

try (InputStream f = getClass().getResourceAsStream("/public/index.html")) {
client.put()
Tuple2<Integer, String> res;
try (InputStream f = getClass().getResourceAsStream("/smallFile.txt")) {
res = client.post()
.uri("/post")
.sendForm((req, form) -> form.multipart(true)
.file("test", f)
.attr("att1", "attr2")
.attr("attr1", "attr2")
.file("test2", f))
.responseSingle((r, buf) -> Mono.just(r.status().code()))
.responseSingle((r, buf) -> buf.asString().map(s -> Tuples.of(r.status().code(), s)))
.block(Duration.ofSeconds(30));
}

Integer res = client.followRedirect(true)
.get()
.uri("/search")
.responseSingle((r, out) -> Mono.just(r.status().code()))
.log()
.block(Duration.ofSeconds(30));

assertThat(res).isNotNull();
if (res != 200) {
throw new IllegalStateException("test status failed with " + res);
}
assertThat(res).as("response").isNotNull();
assertThat(res.getT1()).as("status code").isEqualTo(200);
assertThat(res.getT2()).as("response body reflecting request").contains("\"form\": {\n \"attr1\": \"attr2\", \n \"test\": \"This is an UTF-8 file that is smaller than 1024 bytes.\\nIt contains accents like \\u00e9.\\nEnd of File\", \n \"test2\": \"\"\n },");
}

@Test
public void simpleTest404() {
doSimpleTest404(HttpClient.create()
.baseUrl("google.com"));
.baseUrl("example.com"));
}

@Test
Expand All @@ -364,7 +356,7 @@ public void simpleTest404_1() {
HttpClient client =
HttpClient.create(pool)
.port(80)
.tcpConfiguration(tcpClient -> tcpClient.host("google.com"))
.tcpConfiguration(tcpClient -> tcpClient.host("example.com"))
.wiretap(true);
doSimpleTest404(client);
doSimpleTest404(client);
Expand All @@ -374,7 +366,7 @@ public void simpleTest404_1() {
private void doSimpleTest404(HttpClient client) {
Integer res = client.followRedirect(true)
.get()
.uri("/unsupportedURI")
.uri("/status/404")
.responseSingle((r, buf) -> Mono.just(r.status().code()))
.log()
.block();
Expand All @@ -389,11 +381,11 @@ private void doSimpleTest404(HttpClient client) {
public void disableChunkForced() {
Tuple2<HttpResponseStatus, String> r =
HttpClient.newConnection()
.tcpConfiguration(tcpClient -> tcpClient.host("google.com"))
.tcpConfiguration(tcpClient -> tcpClient.host("example.com"))
.headers(h -> h.set(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED))
.wiretap(true)
.request(HttpMethod.GET)
.uri("/unsupportedURI")
.uri("/status/404")
.send(ByteBufFlux.fromString(Flux.just("hello")))
.responseSingle((res, conn) -> Mono.just(res.status())
.zipWith(conn.asString()))
Expand All @@ -408,11 +400,11 @@ public void disableChunkForced() {
public void disableChunkForced2() {
Tuple2<HttpResponseStatus, String> r =
HttpClient.newConnection()
.tcpConfiguration(tcpClient -> tcpClient.host("google.com"))
.tcpConfiguration(tcpClient -> tcpClient.host("example.com"))
.wiretap(true)
.keepAlive(false)
.get()
.uri("/unsupportedURI")
.uri("/status/404")
.responseSingle((res, conn) -> Mono.just(res.status())
.zipWith(conn.asString()))
.block(Duration.ofSeconds(30));
Expand All @@ -433,15 +425,15 @@ public void simpleClientPooling() {
.doOnResponse((res, c) -> ch1.set(c.channel()))
.wiretap(true)
.get()
.uri("http://google.com/unsupportedURI")
.uri("http://example.com/status/404")
.responseSingle((res, buf) -> buf.thenReturn(res.status()))
.block(Duration.ofSeconds(30));

HttpClient.create(p)
.doOnResponse((res, c) -> ch2.set(c.channel()))
.wiretap(true)
.get()
.uri("http://google.com/unsupportedURI")
.uri("http://example.com/status/404")
.responseSingle((res, buf) -> buf.thenReturn(res.status()))
.block(Duration.ofSeconds(30));

Expand All @@ -460,12 +452,12 @@ public void disableChunkImplicitDefault() {
ConnectionProvider p = ConnectionProvider.fixed("test", 1);
HttpClient client =
HttpClient.create(p)
.tcpConfiguration(tcpClient -> tcpClient.host("google.com"))
.tcpConfiguration(tcpClient -> tcpClient.host("example.com"))
.wiretap(true);

Tuple2<HttpResponseStatus, Channel> r =
client.get()
.uri("/unsupportedURI")
.uri("/status/404")
.responseConnection((res, conn) -> Mono.just(res.status())
.delayUntil(s -> conn.inbound().receive())
.zipWith(Mono.just(conn.channel())))
Expand All @@ -475,7 +467,7 @@ public void disableChunkImplicitDefault() {

Channel r2 =
client.get()
.uri("/unsupportedURI")
.uri("/status/404")
.responseConnection((res, conn) -> Mono.just(conn.channel())
.delayUntil(s -> conn.inbound().receive()))
.blockLast(Duration.ofSeconds(30));
Expand All @@ -498,13 +490,13 @@ public void contentHeader() {

HttpResponseStatus r =
client.request(HttpMethod.GET)
.uri("http://google.com")
.uri("http://example.com")
.send(ByteBufFlux.fromString(Mono.just(" ")))
.responseSingle((res, buf) -> Mono.just(res.status()))
.block(Duration.ofSeconds(30));

client.request(HttpMethod.GET)
.uri("http://google.com")
.uri("http://example.com")
.send(ByteBufFlux.fromString(Mono.just(" ")))
.responseSingle((res, buf) -> Mono.just(res.status()))
.block(Duration.ofSeconds(30));
Expand All @@ -518,7 +510,7 @@ public void simpleTestHttps() {
StepVerifier.create(HttpClient.create()
.wiretap(true)
.get()
.uri("https://developer.chrome.com")
.uri("https://example.com")
.response((r, buf) -> Mono.just(r.status().code())))
.expectNextMatches(status -> status >= 200 && status < 400)
.expectComplete()
Expand All @@ -527,7 +519,7 @@ public void simpleTestHttps() {
StepVerifier.create(HttpClient.create()
.wiretap(true)
.get()
.uri("https://developer.chrome.com")
.uri("https://example.com")
.response((r, buf) -> Mono.just(r.status().code())))
.expectNextMatches(status -> status >= 200 && status < 400)
.expectComplete()
Expand Down Expand Up @@ -685,7 +677,7 @@ public void testUserAgent() {
@Test
public void gettingOptionsDuplicates() {
HttpClient client = HttpClient.create()
.tcpConfiguration(tcpClient -> tcpClient.host("foo"))
.tcpConfiguration(tcpClient -> tcpClient.host("example.com"))
.wiretap(true)
.port(123)
.compress(true);
Expand Down
20 changes: 10 additions & 10 deletions src/test/java/reactor/netty/http/client/UriEndpointFactoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ public void createUriEndpointRelativeSslSupport() {
@Test
public void createUriEndpointRelativeNoLeadingSlash() {
String test1 = this.builder.build()
.createUriEndpoint("foo:8080/bar", false)
.createUriEndpoint("example.com:8080/bar", false)
.toExternalForm();
String test2 = this.builder.build()
.createUriEndpoint("foo:8080/bar", true)
.createUriEndpoint("example.com:8080/bar", true)
.toExternalForm();

assertThat(test1).isEqualTo("http://foo:8080/bar");
assertThat(test2).isEqualTo("ws://foo:8080/bar");
assertThat(test1).isEqualTo("http://example.com:8080/bar");
assertThat(test2).isEqualTo("ws://example.com:8080/bar");
}

@Test
Expand Down Expand Up @@ -155,33 +155,33 @@ public void createUriEndpointIPv6Address() {

@Test
public void createUriEndpointRelativeAddressSsl() {
String test1 = this.builder.host("example")
String test1 = this.builder.host("example.com")
.port(8080)
.sslSupport()
.build()
.createUriEndpoint("/foo", false)
.toExternalForm();
String test2 = this.builder.host("example")
String test2 = this.builder.host("example.com")
.port(8080)
.sslSupport()
.build()
.createUriEndpoint("/foo", true)
.toExternalForm();

assertThat(test1).isEqualTo("https://example:8080/foo");
assertThat(test2).isEqualTo("wss://example:8080/foo");
assertThat(test1).isEqualTo("https://example.com:8080/foo");
assertThat(test2).isEqualTo("wss://example.com:8080/foo");
}

@Test
public void createUriEndpointRelativeWithPort() {
String test = this.builder
.host("google.com")
.host("example.com")
.port(80)
.build()
.createUriEndpoint("/foo", false)
.toExternalForm();

assertThat(test).isEqualTo("http://google.com/foo");
assertThat(test).isEqualTo("http://example.com/foo");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ public void keepAlive() throws URISyntaxException {
public void gettingOptionsDuplicates() {
HttpServer server = HttpServer.create()
.port(123)
.host(("foo"))
.host(("example.com"))
.compress(true);
assertThat(server.tcpConfiguration().configure())
.isNotSameAs(HttpServer.DEFAULT_TCP_SERVER)
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/reactor/netty/tcp/InetSocketAddressUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public void shouldCreateResolvedNumericIPv6Address() {
@Test
public void shouldCreateUnresolvedAddressByHostName() {
InetSocketAddress socketAddress = InetSocketAddressUtil
.createUnresolved("google.com", 80);
.createUnresolved("example.com", 80);
assertThat(socketAddress.isUnresolved()).isTrue();
assertThat(socketAddress.getPort()).isEqualTo(80);
assertThat(socketAddress.getHostString()).isEqualTo("google.com");
assertThat(socketAddress.getHostString()).isEqualTo("example.com");
}

@Test
Expand Down Expand Up @@ -80,7 +80,7 @@ public void shouldReplaceNumericIPAddressWithResolvedInstance() {

@Test
public void shouldNotReplaceIfNonNumeric() {
InetSocketAddress socketAddress = InetSocketAddress.createUnresolved("google.com",
InetSocketAddress socketAddress = InetSocketAddress.createUnresolved("example.com",
80);
InetSocketAddress processedAddress = InetSocketAddressUtil
.replaceUnresolvedNumericIp(socketAddress);
Expand All @@ -97,7 +97,7 @@ public void shouldNotReplaceIfAlreadyResolvedWhenCallingReplaceUnresolveNumericI

@Test
public void shouldResolveUnresolvedAddress() {
InetSocketAddress socketAddress = InetSocketAddress.createUnresolved("google.com",
InetSocketAddress socketAddress = InetSocketAddress.createUnresolved("example.com",
80);
InetSocketAddress processedAddress = InetSocketAddressUtil
.replaceWithResolved(socketAddress);
Expand All @@ -107,7 +107,7 @@ public void shouldResolveUnresolvedAddress() {

@Test
public void shouldNotReplaceIfAlreadyResolved() {
InetSocketAddress socketAddress = new InetSocketAddress("google.com", 80);
InetSocketAddress socketAddress = new InetSocketAddress("example.com", 80);
InetSocketAddress processedAddress = InetSocketAddressUtil
.replaceWithResolved(socketAddress);
assertThat(processedAddress).isSameAs(socketAddress);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/reactor/netty/tcp/TcpClientTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ public void nettyNetChannelAcceptsNettyChannelHandlers() throws InterruptedExcep

final CountDownLatch latch = new CountDownLatch(1);
System.out.println(client.get()
.uri("http://www.google.com/?q=test%20d%20dq")
.uri("http://example.com/?q=test%20d%20dq")
.responseContent()
.asString()
.collectList()
Expand All @@ -575,7 +575,7 @@ public void nettyNetChannelAcceptsNettyChannelHandlers() throws InterruptedExcep

@Test
public void gettingOptionsDuplicates() {
TcpClient client = TcpClient.create().host("foo").port(123);
TcpClient client = TcpClient.create().host("example.com").port(123);
Assertions.assertThat(client.configure())
.isNotSameAs(TcpClient.DEFAULT_BOOTSTRAP)
.isNotSameAs(client.configure());
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/reactor/netty/tcp/TcpServerTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public void wsTest() {

@Test
public void gettingOptionsDuplicates() {
TcpServer server = TcpServer.create().host("foo").port(123);
TcpServer server = TcpServer.create().host("example.com").port(123);
Assertions.assertThat(server.configure())
.isNotSameAs(TcpServerBind.INSTANCE.serverBootstrap)
.isNotSameAs(server.configure());
Expand Down

0 comments on commit 1ad3178

Please sign in to comment.