@After public void afterMethod() { resetTracing(); }
@Before public void beforeMethod() throws Exception { callableMock = mock(Callable.class); throwExceptionDuringCall = false; currentSpanStackWhenCallableWasCalled = new ArrayList<>(); currentMdcInfoWhenCallableWasCalled = new ArrayList<>(); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { currentSpanStackWhenCallableWasCalled.add(Tracer.getInstance().getCurrentSpanStackCopy()); currentMdcInfoWhenCallableWasCalled.add(MDC.getCopyOfContextMap()); if (throwExceptionDuringCall) throw new RuntimeException("kaboom"); return null; } }).when(callableMock).call(); resetTracing(); }
callableMock, spanStack, mdcInfo ); resetTracing(); assertThat(Tracer.getInstance().getCurrentSpanStackCopy()).isNull(); assertThat(MDC.getCopyOfContextMap()).isNullOrEmpty();