use of com.navercorp.pinpoint.plugin.tomcat.interceptor.StandardHostValveInvokeInterceptor in project pinpoint by naver.
the class InvokeMethodInterceptorTest method testValidHeaderExists.
@Test
public void testValidHeaderExists() {
when(request.getRequestURI()).thenReturn("/hellotest.nhn");
when(request.getRemoteAddr()).thenReturn("10.0.0.1");
TraceId traceId = new DefaultTraceId("agentTest", System.currentTimeMillis(), 1);
when(request.getHeader(Header.HTTP_TRACE_ID.toString())).thenReturn(traceId.getTransactionId());
when(request.getHeader(Header.HTTP_PARENT_SPAN_ID.toString())).thenReturn("PARENTSPANID");
when(request.getHeader(Header.HTTP_SPAN_ID.toString())).thenReturn("SPANID");
when(request.getHeader(Header.HTTP_SAMPLED.toString())).thenReturn("false");
when(request.getHeader(Header.HTTP_FLAGS.toString())).thenReturn("0");
Enumeration<?> enumeration = mock(Enumeration.class);
when(request.getParameterNames()).thenReturn(enumeration);
TraceContext traceContext = spyTraceContext();
StandardHostValveInvokeInterceptor interceptor = new StandardHostValveInvokeInterceptor(traceContext, descriptor);
interceptor.before("target", new Object[] { request, response });
interceptor.after("target", new Object[] { request, response }, new Object(), null);
verify(traceContext, times(1)).continueTraceObject(any(TraceId.class));
interceptor.before("target", new Object[] { request, response });
interceptor.after("target", new Object[] { request, response }, new Object(), null);
verify(traceContext, times(2)).continueTraceObject(any(TraceId.class));
}
use of com.navercorp.pinpoint.plugin.tomcat.interceptor.StandardHostValveInvokeInterceptor in project pinpoint by naver.
the class InvokeMethodInterceptorTest method testInvalidHeaderExists.
@Test
public void testInvalidHeaderExists() {
when(request.getRequestURI()).thenReturn("/hellotest.nhn");
when(request.getRemoteAddr()).thenReturn("10.0.0.1");
when(request.getHeader(Header.HTTP_TRACE_ID.toString())).thenReturn("TRACEID");
when(request.getHeader(Header.HTTP_PARENT_SPAN_ID.toString())).thenReturn("PARENTSPANID");
when(request.getHeader(Header.HTTP_SPAN_ID.toString())).thenReturn("SPANID");
when(request.getHeader(Header.HTTP_SAMPLED.toString())).thenReturn("false");
when(request.getHeader(Header.HTTP_FLAGS.toString())).thenReturn("0");
Enumeration<?> enumeration = mock(Enumeration.class);
when(request.getParameterNames()).thenReturn(enumeration);
TraceContext traceContext = spyTraceContext();
StandardHostValveInvokeInterceptor interceptor = new StandardHostValveInvokeInterceptor(traceContext, descriptor);
interceptor.before("target", new Object[] { request, response });
interceptor.after("target", new Object[] { request, response }, new Object(), null);
verify(traceContext, never()).newTraceObject();
verify(traceContext, never()).disableSampling();
verify(traceContext, never()).continueTraceObject(any(TraceId.class));
interceptor.before("target", new Object[] { request, response });
interceptor.after("target", new Object[] { request, response }, new Object(), null);
verify(traceContext, never()).newTraceObject();
verify(traceContext, never()).disableSampling();
verify(traceContext, never()).continueTraceObject(any(TraceId.class));
}
use of com.navercorp.pinpoint.plugin.tomcat.interceptor.StandardHostValveInvokeInterceptor in project pinpoint by naver.
the class InvokeMethodInterceptorTest method testHeaderNOTExists.
@Test
public void testHeaderNOTExists() {
when(request.getRequestURI()).thenReturn("/hellotest.nhn");
when(request.getRemoteAddr()).thenReturn("10.0.0.1");
when(request.getHeader(Header.HTTP_TRACE_ID.toString())).thenReturn(null);
when(request.getHeader(Header.HTTP_PARENT_SPAN_ID.toString())).thenReturn(null);
when(request.getHeader(Header.HTTP_SPAN_ID.toString())).thenReturn(null);
when(request.getHeader(Header.HTTP_SAMPLED.toString())).thenReturn(null);
when(request.getHeader(Header.HTTP_FLAGS.toString())).thenReturn(null);
Enumeration<?> enumeration = mock(Enumeration.class);
when(request.getParameterNames()).thenReturn(enumeration);
TraceContext traceContext = spyTraceContext();
StandardHostValveInvokeInterceptor interceptor = new StandardHostValveInvokeInterceptor(traceContext, descriptor);
interceptor.before("target", new Object[] { request, response });
interceptor.after("target", new Object[] { request, response }, new Object(), null);
verify(traceContext, times(1)).newTraceObject();
interceptor.before("target", new Object[] { request, response });
interceptor.after("target", new Object[] { request, response }, new Object(), null);
verify(traceContext, times(2)).newTraceObject();
}
Aggregations