Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
Increase test coverage for jaeger-jaxrs2 (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinearls authored and yurishkuro committed May 14, 2017
1 parent ac126f0 commit 797ef4f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@

package com.uber.jaeger.filters.jaxrs2;

import static com.uber.jaeger.filters.jaxrs2.Constants.CURRENT_SPAN_CONTEXT_KEY;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.when;

import com.uber.jaeger.Span;
Expand Down Expand Up @@ -84,6 +87,8 @@ public void testFilter() throws Exception {

undertest.filter(clientRequestContext);

assertNull(clientRequestContext.getProperty(CURRENT_SPAN_CONTEXT_KEY));

ArgumentCaptor<String> stringCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<Object> objectCaptor = ArgumentCaptor.forClass(Object.class);

Expand All @@ -94,6 +99,8 @@ public void testFilter() throws Exception {

undertest.filter(clientRequestContext, clientResponseContext);

assertNotNull(clientRequestContext.getProperty(CURRENT_SPAN_CONTEXT_KEY));

List<Span> spans = reporter.getSpans();
Map<String, Object> tags = spans.get(0).getTags();
assertEquals(200, tags.get(Tags.HTTP_STATUS.getKey()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,13 @@ public void filter() throws Exception {
assertEquals(Tags.SPAN_KIND_SERVER, tags.get(Tags.SPAN_KIND.getKey()));
assertEquals(uri.toString(), tags.get(Tags.HTTP_URL.getKey()));
assertEquals("localhost", tags.get(Tags.PEER_HOSTNAME.getKey()));


// Exercise catch blocks on filter methods for code coverage
undertest.filter(null);

// For filter(requestContext, responseContext) we first need to make sure there's something in the traceContext
undertest.filter(containerRequestContext);
undertest.filter(containerRequestContext, null);
}
}

0 comments on commit 797ef4f

Please sign in to comment.