Skip to content

Commit

Permalink
Merge #2676 into 1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Jan 27, 2023
2 parents 31b673e + 90b36eb commit b1b8836
Showing 1 changed file with 35 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.security.cert.CertificateException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
Expand Down Expand Up @@ -215,41 +216,24 @@ void testIssue253() {
.bindNow();

HttpClient client = createClient(disposableServer::address);

String value =
client.followRedirect(true)
.get()
.uri("/1")
.responseContent()
.aggregate()
.asString()
.block(Duration.ofSeconds(30));
assertThat(value).isEqualTo("OK");

value = client.get()
.uri("/1")
.responseContent()
.aggregate()
.asString()
.block(Duration.ofSeconds(30));
assertThat(value).isNull();

value = client.followRedirect(true)
.get()
.uri("/2")
.responseContent()
.aggregate()
.asString()
.block(Duration.ofSeconds(30));
assertThat(value).isEqualTo("OK");

value = client.get()
.uri("/2")
.responseContent()
.aggregate()
.asString()
.block(Duration.ofSeconds(30));
assertThat(value).isNull();
HttpClient redirectingClient = client.followRedirect(true);

Flux<String> urls = Flux.just("/1", "/1", "/2", "/2");
Flux<HttpClient> clients = Flux.just(redirectingClient, client, redirectingClient, client);

Flux.zip(urls, clients)
.concatMap(t -> t.getT2()
.get()
.uri(t.getT1())
.responseContent()
.aggregate()
.asString()
.defaultIfEmpty("null"))
.collectList()
.as(StepVerifier::create)
.expectNext(Arrays.asList("OK", "null", "OK", "null"))
.expectComplete()
.verify(Duration.ofSeconds(30));
}

/**
Expand Down Expand Up @@ -358,66 +342,23 @@ void testIssue522() {

HttpClient client = createClient(disposableServer::address);

StepVerifier.create(client.followRedirect(true)
.get()
.uri("/301")
.responseContent()
.aggregate()
.asString())
.expectNextMatches("OK"::equals)
.expectComplete()
.verify(Duration.ofSeconds(30));

StepVerifier.create(client.followRedirect(true)
.get()
.uri("/302")
.responseContent()
.aggregate()
.asString())
.expectNextMatches("OK"::equals)
.expectComplete()
.verify(Duration.ofSeconds(30));
Flux.just("/301", "/302", "/303", "/307", "/308", "/predicate")
.flatMap(s -> {
HttpClient localClient = "/predicate".equals(s) ?
client.followRedirect((req, res) -> res.responseHeaders().contains("test")) :
client.followRedirect(true);
return localClient.get()
.uri(s)
.responseContent()
.aggregate()
.asString();
})
.collectList()
.as(StepVerifier::create)
.assertNext(l -> assertThat(l).allMatch("OK"::equals))
.expectComplete()
.verify(Duration.ofSeconds(30));

StepVerifier.create(client.followRedirect(true)
.post()
.uri("/303")
.responseContent()
.aggregate()
.asString())
.expectNextMatches("OK"::equals)
.expectComplete()
.verify(Duration.ofSeconds(30));

StepVerifier.create(client.followRedirect(true)
.get()
.uri("/307")
.responseContent()
.aggregate()
.asString())
.expectNextMatches("OK"::equals)
.expectComplete()
.verify(Duration.ofSeconds(30));

StepVerifier.create(client.followRedirect(true)
.get()
.uri("/308")
.responseContent()
.aggregate()
.asString())
.expectNextMatches("OK"::equals)
.expectComplete()
.verify(Duration.ofSeconds(30));

StepVerifier.create(client.followRedirect((req, res) -> res.responseHeaders()
.contains("test"))
.get()
.uri("/predicate")
.responseContent()
.aggregate()
.asString())
.expectNextMatches("OK"::equals)
.expectComplete()
.verify(Duration.ofSeconds(30));

StepVerifier.create(client.followRedirect(true)
.get()
Expand Down

0 comments on commit b1b8836

Please sign in to comment.