clean and fix tests
This commit is contained in:
parent
7640e68337
commit
75d66dee21
|
@ -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
|
||||
|
@ -86,55 +86,55 @@ class JaxRsAnnotationsInstrumentationTest extends AgentTestRunner {
|
|||
resourceNames.get(obj.class).size() == 1
|
||||
|
||||
where:
|
||||
name | obj
|
||||
"/a" | new Jax() {
|
||||
name | obj
|
||||
"/a" | new Jax() {
|
||||
@Path("/a")
|
||||
void call() {
|
||||
}
|
||||
}
|
||||
"GET /b" | new Jax() {
|
||||
"GET /b" | new Jax() {
|
||||
@GET
|
||||
@Path("/b")
|
||||
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() {
|
||||
}
|
||||
}
|
||||
"POST /abstract/d" | new AbstractClassWithPath() {
|
||||
"POST /abstract/d" | new AbstractClassWithPath() {
|
||||
@POST
|
||||
@Path("/d")
|
||||
void call() {
|
||||
}
|
||||
}
|
||||
"PUT /abstract" | new AbstractClassWithPath() {
|
||||
"PUT /abstract" | new AbstractClassWithPath() {
|
||||
@PUT
|
||||
void call() {
|
||||
}
|
||||
}
|
||||
"OPTIONS /child/e" | new ChildClassWithPath() {
|
||||
"OPTIONS /child/e" | new ChildClassWithPath() {
|
||||
@OPTIONS
|
||||
@Path("/e")
|
||||
void call() {
|
||||
}
|
||||
}
|
||||
"DELETE /child" | new ChildClassWithPath() {
|
||||
"DELETE /child/call" | new ChildClassWithPath() {
|
||||
@DELETE
|
||||
void call() {
|
||||
}
|
||||
}
|
||||
"POST /child/call" | new ChildClassWithPath()
|
||||
"GET /child/call" | new JavaInterfaces.ChildClassOnInterface()
|
||||
"POST /child/call" | new ChildClassWithPath()
|
||||
"GET /child/call" | new JavaInterfaces.ChildClassOnInterface()
|
||||
// TODO: uncomment when we drop support for Java 7
|
||||
// "GET /child/invoke" | new JavaInterfaces.DefaultChildClassOnInterface()
|
||||
// "GET /child/invoke" | new JavaInterfaces.DefaultChildClassOnInterface()
|
||||
|
||||
className = getName(obj.class)
|
||||
|
||||
|
@ -168,18 +168,6 @@ class JaxRsAnnotationsInstrumentationTest extends AgentTestRunner {
|
|||
void call() {
|
||||
}
|
||||
} | _
|
||||
new InterfaceWithPath() {
|
||||
void call() {
|
||||
}
|
||||
} | _
|
||||
new AbstractClassWithPath() {
|
||||
void call() {
|
||||
}
|
||||
} | _
|
||||
new ChildClassWithPath() {
|
||||
void call() {
|
||||
}
|
||||
} | _
|
||||
}
|
||||
|
||||
interface Jax {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
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!"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue