use of brave.http.HttpResponseParserAdapters.ClientAdapter in project brave by openzipkin.
the class HttpResponseParserAdaptersTest method parse_HttpClientResponse.
@Test
public void parse_HttpClientResponse() {
ClientAdapter parserAdapter = new ClientAdapter(currentTraceContext, parser);
HttpClientResponse response = mock(HttpClientResponse.class);
Object res = new Object();
when(response.unwrap()).thenReturn(res);
parserAdapter.parse(response, context, span);
HttpClientAdapters.ToResponseAdapter a = new HttpClientAdapters.ToResponseAdapter(response, res);
verify(parser).response(refEq(a), eq(res), eq(null), eq(span));
}
use of brave.http.HttpResponseParserAdapters.ClientAdapter in project brave by openzipkin.
the class HttpResponseParserAdaptersTest 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 <Res> void response(HttpAdapter<?, Res> adapter, Res res, Throwable error, SpanCustomizer customizer) {
parsed.set(true);
assertThat(currentTraceContext.get()).isSameAs(context);
}
});
parserAdapter.parse(mock(HttpClientResponse.class), context, span);
assertThat(parsed).isTrue();
}
use of brave.http.HttpResponseParserAdapters.ClientAdapter in project brave by openzipkin.
the class HttpResponseParserAdaptersTest method parse_HttpClientParse_unwrapNull.
@Test
public void parse_HttpClientParse_unwrapNull() {
ClientAdapter parserAdapter = new ClientAdapter(currentTraceContext, parser);
HttpClientResponse response = mock(HttpClientResponse.class);
// to avoid old parsers seeing null
Object res = NULL_SENTINEL;
parserAdapter.parse(response, context, span);
HttpClientAdapters.ToResponseAdapter a = new HttpClientAdapters.ToResponseAdapter(response, res);
verify(parser).response(refEq(a), eq(res), eq(null), eq(span));
}
use of brave.http.HttpResponseParserAdapters.ClientAdapter in project brave by openzipkin.
the class HttpResponseParserAdaptersTest method parse_HttpClientResponseAdapter.
@Test
public void parse_HttpClientResponseAdapter() {
ClientAdapter parserAdapter = new ClientAdapter(currentTraceContext, parser);
HttpClientAdapter adapter = mock(HttpClientAdapter.class);
Object res = new Object();
parserAdapter.parse(new HttpClientAdapters.FromResponseAdapter(adapter, res, null), context, span);
verify(parser).response(adapter, res, null, span);
}
use of brave.http.HttpResponseParserAdapters.ClientAdapter in project brave by openzipkin.
the class HttpResponseParserAdaptersTest method parse_HttpClientParse_error.
@Test
public void parse_HttpClientParse_error() {
ClientAdapter parserAdapter = new ClientAdapter(currentTraceContext, parser);
HttpClientResponse response = mock(HttpClientResponse.class);
Object res = new Object();
Throwable error = new Throwable();
when(response.unwrap()).thenReturn(res);
when(response.error()).thenReturn(error);
parserAdapter.parse(response, context, span);
HttpClientAdapters.ToResponseAdapter a = new HttpClientAdapters.ToResponseAdapter(response, res);
verify(parser).response(refEq(a), eq(res), eq(error), eq(span));
}
Aggregations