TraceResponseInterceptor implements HttpResponseInterceptor { public void process(org.apache.http.HttpResponse response, HttpContext context) throws HttpException, IOException { TraceContext traceContext = (TraceContext) context .getAttribute(TraceInterceptorUtil.TRACE_CONTEXT_KEY); interceptor.process(new ResponseAdapter(response), traceContext); } TraceResponseInterceptor();  TraceResponseInterceptor(TraceHttpResponseInterceptor interceptor); void process(org.apache.http.HttpResponse response, HttpContext context);  }
@Test public void testProcess_WithContext() throws IOException, HttpException { HttpContext httpContext = new BasicHttpContext(); httpContext.setAttribute("TRACE-CONTEXT", testContext); responseInterceptor.process(response, httpContext); ArgumentCaptor<HttpResponse> responseCaptor = ArgumentCaptor.forClass(HttpResponse.class); ArgumentCaptor<TraceContext> contextCaptor = ArgumentCaptor.forClass(TraceContext.class); verify(mockDelegate).process(responseCaptor.capture(), contextCaptor.capture()); HttpResponse response = responseCaptor.getValue(); TraceContext traceContext = contextCaptor.getValue(); assertThat(traceContext).isEqualTo(testContext); assertThat(response.getHeader("Content-Length")).isEqualTo("123"); assertThat(response.getStatus()).isEqualTo(200); }
@Test public void testProcess_WithoutContext() throws IOException, HttpException { HttpContext httpContext = new BasicHttpContext(); responseInterceptor.process(response, httpContext); verify(mockDelegate).process(any(HttpResponse.class), (TraceContext) isNull()); }