Skip to content

Commit

Permalink
Add test for null httpcontext (open-telemetry#6823)
Browse files Browse the repository at this point in the history
follow-up to open-telemetry#6792
  • Loading branch information
trask authored and LironKS committed Oct 23, 2022
1 parent df2c26e commit cd1760f
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
import org.apache.hc.core5.concurrent.FutureCallback;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.http2.HttpVersionPolicy;
import org.apache.hc.core5.io.CloseMode;
import org.junit.jupiter.api.AfterAll;
Expand Down Expand Up @@ -72,6 +73,19 @@ SimpleHttpRequest createRequest(String method, URI uri) {
}
}

@Nested
class ApacheClientNullContextTest extends AbstractTest {
@Override
SimpleHttpRequest createRequest(String method, URI uri) {
return new SimpleHttpRequest(method, uri);
}

@Override
protected HttpContext getContext() {
return null;
}
}

abstract class AbstractTest extends AbstractApacheHttpClientTest<SimpleHttpRequest> {
@Override
protected SimpleHttpRequest buildRequest(String method, URI uri, Map<String, String> headers) {
Expand All @@ -88,12 +102,12 @@ protected SimpleHttpRequest buildRequest(String method, URI uri, Map<String, Str

@Override
HttpResponse executeRequest(SimpleHttpRequest request, URI uri) throws Exception {
return client.execute(request, null).get();
return client.execute(request, getContext(), null).get();
}

@Override
void executeRequestWithCallback(SimpleHttpRequest request, URI uri, RequestResult result) {
client.execute(request, new ResponseCallback(result));
client.execute(request, getContext(), new ResponseCallback(result));
}

@Override
Expand Down

0 comments on commit cd1760f

Please sign in to comment.