clean and fix tests
MODIFY
dd-java-agent/instrumentation/jax-rs-annotations-1/src/test/groovy/JaxRsAnnotationsInstrumentationTest.groovy
dd-java-agent/instrumentation/jax-rs-annotations-1/src/test/groovy/JaxRsAnnotationsInstrumentationTest.groovy
@@ -2,6 +2,7 @@ import datadog.trace.agent.test.AgentTestRunner
import datadog.trace.bootstrap.WeakMap
import datadog.trace.instrumentation.api.Tags
import datadog.trace.instrumentation.jaxrs1.JaxRsAnnotationsDecorator
+
import javax.ws.rs.DELETE
import javax.ws.rs.GET
import javax.ws.rs.HEAD
@@ -9,7 +10,6 @@ import javax.ws.rs.OPTIONS
import javax.ws.rs.POST
import javax.ws.rs.PUT
import javax.ws.rs.Path
-
import java.lang.reflect.Method
import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
@@ -98,13 +98,13 @@ class JaxRsAnnotationsInstrumentationTest extends AgentTestRunner {
void call() {
}
}
- "POST /c" | new InterfaceWithPath() {
+ "POST /interface/c" | new InterfaceWithPath() {
@POST
@Path("/c")
void call() {
}
}
- "HEAD" | new InterfaceWithPath() {
+ "HEAD /interface" | new InterfaceWithPath() {
@HEAD
void call() {
}
@@ -126,7 +126,7 @@ class JaxRsAnnotationsInstrumentationTest extends AgentTestRunner {
void call() {
}
}
- "DELETE /child" | new ChildClassWithPath() {
+ "DELETE /child/call" | new ChildClassWithPath() {
@DELETE
void call() {
}
@@ -168,18 +168,6 @@ class JaxRsAnnotationsInstrumentationTest extends AgentTestRunner {
void call() {
}
} | _
- new InterfaceWithPath() {
- void call() {
- }
- } | _
- new AbstractClassWithPath() {
- void call() {
- }
- } | _
- new ChildClassWithPath() {
- void call() {
- }
- } | _
}
interface Jax {

MODIFY
dd-java-agent/instrumentation/jax-rs-annotations-1/src/test/groovy/JerseyTest.groovy
dd-java-agent/instrumentation/jax-rs-annotations-1/src/test/groovy/JerseyTest.groovy
import datadog.trace.agent.test.AgentTestRunner
+import datadog.trace.api.DDSpanTypes
+import datadog.trace.instrumentation.api.Tags
import io.dropwizard.testing.junit.ResourceTestRule
import org.junit.ClassRule
import spock.lang.Shared
@@ -15,22 +17,44 @@ class JerseyTest extends AgentTestRunner {
.addResource(new Resource.Test3())
.build()
- def "test resource"() {
- setup:
+ def "test #resource"() {
+ when:
// start a trace because the test doesn't go through any servlet or other instrumentation.
def response = runUnderTrace("test.span") {
- resources.client().resource("/test/hello/bob").post(String)
+ resources.client().resource(resource).post(String)
}
- expect:
- response == "Test1 bob!"
- TEST_WRITER.waitForTraces(1)
- TEST_WRITER.size() == 1
+ then:
+ response == expectedResponse
- def trace = TEST_WRITER.firstTrace()
- assert trace.size() == 2
- def span = trace[0]
- span.resourceName == "POST /test/hello/{name}"
- span.tags["component"] == "jax-rs"
+ assertTraces(1) {
+ trace(0, 2) {
+ span(0) {
+ operationName "test.span"
+ resourceName expectedResourceName
+ tags {
+ "$Tags.COMPONENT" "jax-rs"
+ defaultTags()
+ }
+ }
+
+ span(1) {
+ childOf span(0)
+ operationName "jax-rs.request"
+ resourceName controllerName
+ spanType DDSpanTypes.HTTP_SERVER
+ tags {
+ "$Tags.COMPONENT" "jax-rs-controller"
+ defaultTags()
+ }
+ }
+ }
+ }
+
+ where:
+ resource | expectedResourceName | controllerName | expectedResponse
+ "/test/hello/bob" | "POST /test/hello/{name}" | "Test1.hello" | "Test1 bob!"
+ "/test2/hello/bob" | "POST /test2/hello/{name}" | "Test2.hello" | "Test2 bob!"
+ "/test3/hi/bob" | "POST /test3/hi/{name}" | "Test3.hello" | "Test3 bob!"
}
}

clean and fix tests