use of com.nike.riposte.server.http.HttpProcessingState in project riposte by Nike-Inc.
the class SupplierWithTracingAndMdcSupportTest method beforeMethod.
@Before
public void beforeMethod() {
channelMock = mock(Channel.class);
ctxMock = mock(ChannelHandlerContext.class);
stateAttributeMock = mock(Attribute.class);
state = new HttpProcessingState();
doReturn(channelMock).when(ctxMock).channel();
doReturn(stateAttributeMock).when(channelMock).attr(ChannelAttributes.HTTP_PROCESSING_STATE_ATTRIBUTE_KEY);
doReturn(state).when(stateAttributeMock).get();
supplierMock = mock(Supplier.class);
outObj = new Object();
throwExceptionDuringCall = false;
currentSpanStackWhenSupplierWasCalled = new ArrayList<>();
currentMdcInfoWhenSupplierWasCalled = new ArrayList<>();
doAnswer(invocation -> {
currentSpanStackWhenSupplierWasCalled.add(Tracer.getInstance().getCurrentSpanStackCopy());
currentMdcInfoWhenSupplierWasCalled.add(MDC.getCopyOfContextMap());
if (throwExceptionDuringCall)
throw new RuntimeException("kaboom");
return outObj;
}).when(supplierMock).get();
resetTracingAndMdc();
}
use of com.nike.riposte.server.http.HttpProcessingState in project riposte by Nike-Inc.
the class BiConsumerWithTracingAndMdcSupportTest method beforeMethod.
@Before
public void beforeMethod() {
channelMock = mock(Channel.class);
ctxMock = mock(ChannelHandlerContext.class);
stateAttributeMock = mock(Attribute.class);
state = new HttpProcessingState();
doReturn(channelMock).when(ctxMock).channel();
doReturn(stateAttributeMock).when(channelMock).attr(ChannelAttributes.HTTP_PROCESSING_STATE_ATTRIBUTE_KEY);
doReturn(state).when(stateAttributeMock).get();
consumerMock = mock(BiConsumer.class);
inObj1 = new Object();
inObj2 = new Object();
throwExceptionDuringCall = false;
currentSpanStackWhenBiConsumerWasCalled = new ArrayList<>();
currentMdcInfoWhenBiConsumerWasCalled = new ArrayList<>();
doAnswer(invocation -> {
currentSpanStackWhenBiConsumerWasCalled.add(Tracer.getInstance().getCurrentSpanStackCopy());
currentMdcInfoWhenBiConsumerWasCalled.add(MDC.getCopyOfContextMap());
if (throwExceptionDuringCall)
throw new RuntimeException("kaboom");
return null;
}).when(consumerMock).accept(inObj1, inObj2);
resetTracingAndMdc();
}
use of com.nike.riposte.server.http.HttpProcessingState in project riposte by Nike-Inc.
the class CallableWithTracingAndMdcSupportTest method beforeMethod.
@Before
public void beforeMethod() throws Exception {
channelMock = mock(Channel.class);
ctxMock = mock(ChannelHandlerContext.class);
stateAttributeMock = mock(Attribute.class);
state = new HttpProcessingState();
doReturn(channelMock).when(ctxMock).channel();
doReturn(stateAttributeMock).when(channelMock).attr(ChannelAttributes.HTTP_PROCESSING_STATE_ATTRIBUTE_KEY);
doReturn(state).when(stateAttributeMock).get();
callableMock = mock(Callable.class);
throwExceptionDuringCall = false;
currentSpanStackWhenCallableWasCalled = new ArrayList<>();
currentMdcInfoWhenCallableWasCalled = new ArrayList<>();
doAnswer(invocation -> {
currentSpanStackWhenCallableWasCalled.add(Tracer.getInstance().getCurrentSpanStackCopy());
currentMdcInfoWhenCallableWasCalled.add(MDC.getCopyOfContextMap());
if (throwExceptionDuringCall)
throw new RuntimeException("kaboom");
return null;
}).when(callableMock).call();
resetTracingAndMdc();
}
use of com.nike.riposte.server.http.HttpProcessingState in project riposte by Nike-Inc.
the class ChannelFutureListenerWithTracingAndMdcTest method beforeMethod.
@Before
public void beforeMethod() {
channelMock = mock(Channel.class);
ctxMock = mock(ChannelHandlerContext.class);
stateAttributeMock = mock(Attribute.class);
state = new HttpProcessingState();
doReturn(channelMock).when(ctxMock).channel();
doReturn(stateAttributeMock).when(channelMock).attr(ChannelAttributes.HTTP_PROCESSING_STATE_ATTRIBUTE_KEY);
doReturn(state).when(stateAttributeMock).get();
consumerMock = mock(Consumer.class);
inObj = mock(ChannelFuture.class);
throwExceptionDuringCall = false;
currentSpanStackWhenChannelFutureWasCalled = new ArrayList<>();
currentMdcInfoWhenChannelFutureWasCalled = new ArrayList<>();
doAnswer(invocation -> {
currentSpanStackWhenChannelFutureWasCalled.add(Tracer.getInstance().getCurrentSpanStackCopy());
currentMdcInfoWhenChannelFutureWasCalled.add(MDC.getCopyOfContextMap());
if (throwExceptionDuringCall)
throw new RuntimeException("kaboom");
return null;
}).when(consumerMock).accept(inObj);
resetTracingAndMdc();
}
use of com.nike.riposte.server.http.HttpProcessingState in project riposte by Nike-Inc.
the class FunctionWithTracingAndMdcSupportTest method beforeMethod.
@Before
public void beforeMethod() {
channelMock = mock(Channel.class);
ctxMock = mock(ChannelHandlerContext.class);
stateAttributeMock = mock(Attribute.class);
state = new HttpProcessingState();
doReturn(channelMock).when(ctxMock).channel();
doReturn(stateAttributeMock).when(channelMock).attr(ChannelAttributes.HTTP_PROCESSING_STATE_ATTRIBUTE_KEY);
doReturn(state).when(stateAttributeMock).get();
functionMock = mock(Function.class);
inObj = new Object();
outObj = new Object();
throwExceptionDuringCall = false;
currentSpanStackWhenFunctionWasCalled = new ArrayList<>();
currentMdcInfoWhenFunctionWasCalled = new ArrayList<>();
doAnswer(invocation -> {
currentSpanStackWhenFunctionWasCalled.add(Tracer.getInstance().getCurrentSpanStackCopy());
currentMdcInfoWhenFunctionWasCalled.add(MDC.getCopyOfContextMap());
if (throwExceptionDuringCall)
throw new RuntimeException("kaboom");
return outObj;
}).when(functionMock).apply(inObj);
resetTracingAndMdc();
}
Aggregations