@Test
public void testGetSofaTraceContext() throws Exception {

    SofaTracerSpan pushedSpan = (SofaTracerSpan) this.sofaTracer.buildSpan("span1").start();
    //span
    SofaTracerSpanContext pushedSofaTracerSpanContext = pushedSpan.getSofaTracerSpanContext();
    String traceId = pushedSofaTracerSpanContext.getTraceId();
    String spanId = pushedSofaTracerSpanContext.getSpanId();
    String parentSpanId = pushedSofaTracerSpanContext.getParentId();
    //assert
    assertTrue("\n" + pushedSpan.getSofaTracerSpanContext(), StringUtils.isBlank(parentSpanId));
    SofaTraceContext sofaTraceContext = SofaTraceContextHolder.getSofaTraceContext();
    sofaTraceContext.clear();
    SofaTracerSpan peekTracerSpan = sofaTraceContext.getCurrentSpan();
    SofaTracerSpan popTracerSpan = sofaTraceContext.pop();
    assertNull(peekTracerSpan);
    assertNull(popTracerSpan);
    assertTrue(sofaTraceContext.isEmpty());
    //push
    sofaTraceContext.push(null);
    assertEquals(0, sofaTraceContext.getThreadLocalSpanSize());
    sofaTraceContext.push(pushedSpan);
    assertEquals(1, sofaTraceContext.getThreadLocalSpanSize());
    sofaTraceContext.push(null);
    assertEquals(1, sofaTraceContext.getThreadLocalSpanSize());
    //get
    SofaTracerSpan gettedSpan = sofaTraceContext.getCurrentSpan();
    assertTrue(gettedSpan == pushedSpan);
    assertEquals(1, sofaTraceContext.getThreadLocalSpanSize());
    //pop
    SofaTracerSpan poppedSpan = sofaTraceContext.pop();
    assertEquals(0, sofaTraceContext.getThreadLocalSpanSize());
    assertTrue(poppedSpan == pushedSpan);
    assertTrue(sofaTraceContext.isEmpty());
}