use of com.nike.riposte.client.asynchttp.ning.RequestBuilderWrapper in project riposte by Nike-Inc.
the class VerifyAsyncHttpClientHelperComponentTest method verify_basic_functionality.
@Test
public void verify_basic_functionality() throws Exception {
// given
RequestBuilderWrapper rbw = asyncClient.getRequestBuilder("http://localhost:" + serverPort + TestEndpoint.MATCHING_PATH, HttpMethod.GET);
rbw.requestBuilder.setHeader(TestEndpoint.EXPECTED_HEADER_KEY, TestEndpoint.EXPECTED_HEADER_VAL);
rbw.requestBuilder.setBody(TestEndpoint.EXPECTED_REQUEST_PAYLOAD);
Span origSpan = Tracer.getInstance().startRequestWithRootSpan("overallReqSpan");
Deque<Span> distributedTraceStackForCall = Tracer.getInstance().getCurrentSpanStackCopy();
Map<String, String> mdcContextForCall = MDC.getCopyOfContextMap();
resetTracingAndMdc();
// when
Response result = asyncClient.executeAsyncHttpRequest(rbw, response -> response, distributedTraceStackForCall, mdcContextForCall).join();
// then
assertThat(result.getStatusCode()).isEqualTo(200);
assertThat(result.getResponseBody()).isEqualTo(TestEndpoint.RESPONSE_PAYLOAD);
assertThat(result.getHeader(TraceHeaders.TRACE_ID)).isEqualTo(origSpan.getTraceId());
// The async client should have surrounded the request in a subspan,
// so the parent ID sent to the downstream service should be the original span's span ID.
assertThat(result.getHeader(TraceHeaders.PARENT_SPAN_ID)).isEqualTo(origSpan.getSpanId());
}
Aggregations