use of brave.http.HttpRequestParserAdapters.ClientAdapter in project brave by openzipkin.
the class HttpRequestParserAdaptersTest method parse_HttpClientParse_unwrapNull.
@Test
public void parse_HttpClientParse_unwrapNull() {
ClientAdapter parserAdapter = new ClientAdapter(currentTraceContext, parser);
HttpClientRequest request = mock(HttpClientRequest.class);
// to avoid old parsers seeing null
Object req = NULL_SENTINEL;
parserAdapter.parse(request, context, span);
HttpClientAdapters.ToRequestAdapter a = new HttpClientAdapters.ToRequestAdapter(request, req);
verify(parser).request(refEq(a), eq(req), eq(span));
}
use of brave.http.HttpRequestParserAdapters.ClientAdapter in project brave by openzipkin.
the class HttpRequestParserAdaptersTest method parse_parsesInScope.
/**
* The old http handler always parsed in scope because the parser had no argument for a trace
* context.
*/
@Test
public void parse_parsesInScope() {
AtomicBoolean parsed = new AtomicBoolean();
ClientAdapter parserAdapter = new ClientAdapter(currentTraceContext, new HttpParser() {
@Override
public <Req> void request(HttpAdapter<Req, ?> adapter, Req req, SpanCustomizer span) {
parsed.set(true);
assertThat(currentTraceContext.get()).isSameAs(context);
}
});
parserAdapter.parse(mock(HttpClientRequest.class), context, span);
assertThat(parsed).isTrue();
}
use of brave.http.HttpRequestParserAdapters.ClientAdapter in project brave by openzipkin.
the class HttpRequestParserAdaptersTest method parse_HttpClientRequestAdapter.
@Test
public void parse_HttpClientRequestAdapter() {
ClientAdapter parserAdapter = new ClientAdapter(currentTraceContext, parser);
HttpClientAdapter adapter = mock(HttpClientAdapter.class);
Object req = new Object();
parserAdapter.parse(new HttpClientAdapters.FromRequestAdapter(adapter, req), context, span);
verify(parser).request(adapter, req, span);
}
use of brave.http.HttpRequestParserAdapters.ClientAdapter in project brave by openzipkin.
the class HttpRequestParserAdaptersTest method parse_HttpClientRequest.
@Test
public void parse_HttpClientRequest() {
ClientAdapter parserAdapter = new ClientAdapter(currentTraceContext, parser);
HttpClientRequest request = mock(HttpClientRequest.class);
Object req = new Object();
when(request.unwrap()).thenReturn(req);
parserAdapter.parse(request, context, span);
HttpClientAdapters.ToRequestAdapter a = new HttpClientAdapters.ToRequestAdapter(request, req);
verify(parser).request(refEq(a), eq(req), eq(span));
}
Aggregations