use of io.opentracing.mock.MockSpan.MockContext in project batfish by batfish.
the class WorkItemTest method testInjectExtract.
@Test
public void testInjectExtract() {
MockContext sourceContext;
try (ActiveSpan activeSpan = _mockTracer.buildSpan("test span").startActive()) {
SpanContext sourceContextTmp = activeSpan.context();
assertThat(sourceContextTmp, instanceOf(MockContext.class));
sourceContext = (MockContext) sourceContextTmp;
_workItem.setSourceSpan(activeSpan, _mockTracer);
}
SpanContext extractedContextTmp = _workItem.getSourceSpan(_mockTracer);
assertThat(extractedContextTmp, notNullValue());
assertThat(extractedContextTmp, instanceOf(MockContext.class));
MockContext extractedContext = (MockContext) extractedContextTmp;
// test that injected and extracted spans have same span context data
assertThat(extractedContext.traceId(), equalTo(sourceContext.traceId()));
assertThat(extractedContext.spanId(), equalTo(sourceContext.spanId()));
}
Aggregations