/** Test of buildSpan method, of class AbstractTracer. */
 @Test
 public void testBuildSpan() {
   System.out.println("buildSpan");
   String operationName = "test-build-span-operation-name";
   AbstractTracer instance = new TestTracerImpl();
   Tracer.SpanBuilder result = instance.buildSpan(operationName);
   AbstractSpan span = (AbstractSpan) result.start();
   assertNotNull("Expected to create a valid Span", span);
   assertEquals("Expected to create a Span with operationName", operationName, span.operationName);
 }
  /** Test of extract method, of class AbstractTracer, with an empty carrier. */
  @Test
  public void testEmptyExtract() {
    System.out.println("empty extract");
    AbstractTracer instance = new TestTracerImpl();
    instance.register(TextMap.class, new TestTextMapExtractorImpl());

    Map<String, String> map = Collections.singletonMap("garbageEntry", "garbageVal");
    TextMap carrier = new TextMapExtractAdapter(map);
    SpanContext emptyResult = instance.extract(Format.Builtin.TEXT_MAP, carrier);
    assertNull("Should be nothing to extract", emptyResult);
  }
  /** Test of extract method, of class AbstractTracer, with a valid carrier. */
  @Test
  public void testNonEmptyExtract() {
    System.out.println("non-empty extract");
    AbstractTracer instance = new TestTracerImpl();
    instance.register(TextMap.class, new TestTextMapExtractorImpl());

    Map<String, String> map = Collections.singletonMap("test-marker", "whatever");
    TextMap carrier = new TextMapExtractAdapter(map);
    SpanContext result = instance.extract(Format.Builtin.TEXT_MAP, carrier);
    assertNotNull("Should be something to extract", result);
    assertEquals("Should find the marker", "whatever", ((TestSpanContextImpl) result).getMarker());
  }
  /** Test of inject method, of class AbstractTracer. */
  @Test
  public void testInject() {
    System.out.println("inject");
    AbstractTracer instance = new TestTracerImpl();
    instance.register(TextMap.class, new TestTextMapInjectorImpl());

    String operationName = "test-inject-span";
    Span span =
        new AbstractSpan(operationName) {
          SpanContext spanContext = new TestSpanContextImpl("whatever");

          @Override
          public SpanContext context() {
            return spanContext;
          }
        };
    Map<String, String> map = new HashMap<>();
    TextMap carrier = new TextMapInjectAdapter(map);
    instance.inject(span.context(), Format.Builtin.TEXT_MAP, carrier);

    assertEquals("marker should have been injected into map", "whatever", map.get("test-marker"));
  }