Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import static org.junit.jupiter.api.Assumptions.assumeTrue;

import datadog.trace.agent.test.AbstractInstrumentationTest;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpClientResponse;
Expand All @@ -23,6 +23,8 @@
import java.net.ServerSocket;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.AbstractMap.SimpleEntry;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.AfterAll;
Expand Down Expand Up @@ -113,22 +115,28 @@ void wrapsApplicationEndHandlerOnVertx51Http2Response() throws Exception {
.setProtocolVersion(HttpVersion.HTTP_2)
.setHttp2ClearTextUpgrade(false));
try {
HttpClientResponse response =
Map.Entry<Integer, String> response =
client
.request(HttpMethod.GET, port, "localhost", "/end-handler-wrapper")
.compose(request -> request.send())
// Subscribe on the event loop before response data can be discarded.
.compose(request -> request.send().compose(this::collectResponse))
.toCompletionStage()
.toCompletableFuture()
.get(10, TimeUnit.SECONDS);
Buffer body =
response.body().toCompletionStage().toCompletableFuture().get(10, TimeUnit.SECONDS);

assertWrapped(response.statusCode(), body.toString(StandardCharsets.UTF_8), HTTP2_RESPONSE);
assertWrapped(response.getKey(), response.getValue(), HTTP2_RESPONSE);
Comment thread
cgcote marked this conversation as resolved.
} finally {
client.close().toCompletionStage().toCompletableFuture().get(10, TimeUnit.SECONDS);
}
}

private Future<Map.Entry<Integer, String>> collectResponse(HttpClientResponse response) {
return response
.body()
.map(
body ->
new SimpleEntry<>(response.statusCode(), body.toString(StandardCharsets.UTF_8)));
}

private static boolean hasVertx51Http1Response() {
return hasClass(HTTP1_RESPONSE);
}
Expand Down
Loading