Search in sources :

Example 1 with ClientAdapter

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));
}
Also used : ClientAdapter(brave.http.HttpRequestParserAdapters.ClientAdapter) Test(org.junit.Test)

Example 2 with ClientAdapter

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();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ClientAdapter(brave.http.HttpRequestParserAdapters.ClientAdapter) SpanCustomizer(brave.SpanCustomizer) Test(org.junit.Test)

Example 3 with ClientAdapter

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);
}
Also used : ClientAdapter(brave.http.HttpRequestParserAdapters.ClientAdapter) Test(org.junit.Test)

Example 4 with ClientAdapter

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));
}
Also used : ClientAdapter(brave.http.HttpRequestParserAdapters.ClientAdapter) Test(org.junit.Test)

Aggregations

ClientAdapter (brave.http.HttpRequestParserAdapters.ClientAdapter)4 Test (org.junit.Test)4 SpanCustomizer (brave.SpanCustomizer)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1