use of io.opentracing.ScopeManager in project jaeger-client-java by jaegertracing.
the class TracingRequestInterceptorTest method testProcessNullScope.
@Test
public void testProcessNullScope() throws Exception {
ScopeManager mockScopeManager = Mockito.mock(ScopeManager.class);
when(mockScopeManager.active()).thenReturn(null);
Tracer mockTracer = Mockito.mock(Tracer.class);
when(mockTracer.scopeManager()).thenReturn(mockScopeManager);
HttpRequestInterceptor interceptor = new TracingRequestInterceptor(mockTracer);
PowerMockito.spy(interceptor);
HttpRequest mockRequest = Mockito.mock(HttpRequest.class);
HttpContext mockContext = Mockito.mock(HttpContext.class);
interceptor.process(mockRequest, mockContext);
PowerMockito.verifyPrivate(interceptor, times(0)).invoke("onSpanStarted", any(Span.class), mockRequest, mockContext);
}
use of io.opentracing.ScopeManager in project jaeger-client-java by jaegertracing.
the class PropagationTest method testCustomScopeManager.
@Test
public void testCustomScopeManager() {
Scope scope = mock(Scope.class);
Tracer tracer = new Tracer.Builder("test", new InMemoryReporter(), new ConstSampler(true)).withScopeManager(new ScopeManager() {
@Override
public Scope activate(io.opentracing.Span span, boolean finishSpanOnClose) {
return scope;
}
@Override
public Scope active() {
return scope;
}
}).build();
assertEquals(scope, tracer.scopeManager().active());
}
Aggregations