コード例 #1
0
  /** 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);
  }
コード例 #2
0
  /** 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());
  }