Search in sources :

Example 1 with FakeSpan

use of io.opencensus.contrib.http.jaxrs.JaxrsClientFilterTest.FakeSpan in project instrumentation-java by census-instrumentation.

the class JaxrsContainerFilterTest method testResponseFilter.

@Test
public void testResponseFilter() throws Exception {
    Span span = new FakeSpan(SpanContext.INVALID, null);
    TagContext tagContext = mock(TagContext.class);
    HttpRequestContext context = JaxrsClientFilterTest.createHttpRequestContext(span, tagContext);
    UriInfo uriInfo = mock(UriInfo.class);
    when(uriInfo.getMatchedURIs()).thenReturn(Collections.singletonList("/resource/{route}"));
    ContainerRequestContext requestContext = mock(ContainerRequestContext.class);
    when(requestContext.getProperty("opencensus.context")).thenReturn(context);
    when(requestContext.getUriInfo()).thenReturn(uriInfo);
    ContainerResponseContext responseContext = mock(ContainerResponseContext.class);
    filter.filter(requestContext, responseContext);
    verify(requestContext).getProperty("opencensus.context");
    verify(responseContext, times(1)).getStatus();
}
Also used : FakeSpan(io.opencensus.contrib.http.jaxrs.JaxrsClientFilterTest.FakeSpan) ContainerRequestContext(javax.ws.rs.container.ContainerRequestContext) TagContext(io.opencensus.tags.TagContext) ContainerResponseContext(javax.ws.rs.container.ContainerResponseContext) HttpRequestContext(io.opencensus.contrib.http.HttpRequestContext) FakeSpan(io.opencensus.contrib.http.jaxrs.JaxrsClientFilterTest.FakeSpan) Span(io.opencensus.trace.Span) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Aggregations

HttpRequestContext (io.opencensus.contrib.http.HttpRequestContext)1 FakeSpan (io.opencensus.contrib.http.jaxrs.JaxrsClientFilterTest.FakeSpan)1 TagContext (io.opencensus.tags.TagContext)1 Span (io.opencensus.trace.Span)1 ContainerRequestContext (javax.ws.rs.container.ContainerRequestContext)1 ContainerResponseContext (javax.ws.rs.container.ContainerResponseContext)1 UriInfo (javax.ws.rs.core.UriInfo)1 Test (org.junit.Test)1