TraceRequestInterceptor implements HttpRequestInterceptor { public void process(org.apache.http.HttpRequest request, HttpContext context) throws HttpException, IOException { TraceContext traceContext = interceptor.process(new RequestAdapter(request)); request.addHeader(SpanContextFactory.headerKey(), SpanContextFactory.toHeader(traceContext.getHandle().getCurrentSpanContext())); context.setAttribute(TraceInterceptorUtil.TRACE_CONTEXT_KEY, traceContext); } TraceRequestInterceptor();  TraceRequestInterceptor(TraceHttpRequestInterceptor interceptor); void process(org.apache.http.HttpRequest request, HttpContext context);  }
@Test public void testProcess() throws Exception { HttpContext context = new BasicHttpContext(); requestInterceptor.process(requestWithHeaders, context); assertThat(context.getAttribute("TRACE-CONTEXT")).isEqualTo(testContext); ArgumentCaptor<HttpRequest> captor = ArgumentCaptor.forClass(HttpRequest.class); verify(mockDelegate).process(captor.capture()); HttpRequest request = captor.getValue(); assertThat(request.getMethod()).isEqualTo("GET"); assertThat(request.getProtocol()).isEqualTo("HTTP"); assertThat(request.getURI()).isEqualTo(URI.create("http: assertThat(request.getHeader("User-Agent")).isEqualTo("test-user-agent"); }