Add more complexity to jersey resource test
This demonstrates a matching failure in our current instrumentation.
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
@@ -9,7 +9,11 @@ class JerseyTest extends AgentTestRunner {
@Shared
@ClassRule
- ResourceTestRule resources = ResourceTestRule.builder().addResource(new Resource.Test()).build()
+ ResourceTestRule resources = ResourceTestRule.builder()
+ .addResource(new Resource.Test1())
+ .addResource(new Resource.Test2())
+ .addResource(new Resource.Test3())
+ .build()
def "test resource"() {
setup:
@@ -19,11 +23,12 @@ class JerseyTest extends AgentTestRunner {
}
expect:
- response == "Hello bob!"
+ response == "Test1 bob!"
TEST_WRITER.waitForTraces(1)
TEST_WRITER.size() == 1
def trace = TEST_WRITER.firstTrace()
+ assert trace.size() == 2
def span = trace[0]
span.resourceName == "POST /test/hello/{name}"
span.tags["component"] == "jax-rs"

MODIFY
dd-java-agent/instrumentation/jax-rs-annotations-1/src/test/java/Resource.java
dd-java-agent/instrumentation/jax-rs-annotations-1/src/test/java/Resource.java
@@ -5,13 +5,32 @@ import javax.ws.rs.PathParam;
// Originally had this as a groovy class but was getting some weird errors.
@Path("/ignored")
public interface Resource {
+ @Path("ignored")
+ String hello(final String name);
@Path("/test")
- class Test implements Resource {
+ interface SubResource {
@POST
@Path("/hello/{name}")
- public String addBook(@PathParam("name") final String name) {
- return "Hello " + name + "!";
+ String hello(@PathParam("name") final String name);
+ }
+
+ class Test1 implements SubResource {
+ public String hello(final String name) {
+ return "Test1 " + name + "!";
+ }
+ }
+
+ @Path("/test2")
+ class Test2 implements SubResource {
+ public String hello(final String name) {
+ return "Test2 " + name + "!";
+ }
+ }
+
+ class Test3 extends Test1 {
+ public String hello(final String name) {
+ return "Test3 " + name + "!";
}
}
}

Add more complexity to jersey resource test

This demonstrates a matching failure in our current instrumentation.