Remove HttpServerTest.testExceptionBody and redirectHasBody
MODIFY
instrumentation/akka-http-10.0/javaagent/src/test/groovy/AkkaHttpServerInstrumentationTest.groovy
instrumentation/akka-http-10.0/javaagent/src/test/groovy/AkkaHttpServerInstrumentationTest.groovy
@@ -8,11 +8,6 @@ import io.opentelemetry.instrumentation.test.base.HttpServerTest
abstract class AkkaHttpServerInstrumentationTest extends HttpServerTest<Object> implements AgentTestTrait {
- @Override
- boolean testExceptionBody() {
- false
- }
-
// FIXME: This doesn't work because we don't support bindAndHandle.
// @Override
// def startServer(int port) {

MODIFY
instrumentation/dropwizard-testing/src/test/groovy/DropwizardTest.groovy
instrumentation/dropwizard-testing/src/test/groovy/DropwizardTest.groovy
@@ -71,10 +71,6 @@ class DropwizardTest extends HttpServerTest<DropwizardTestSupport> implements Ag
true
}
- boolean testExceptionBody() {
- false
- }
-
@Override
void handlerSpan(TraceAssert trace, int index, Object parent, String method = "GET", ServerEndpoint endpoint = SUCCESS) {
trace.span(index) {

MODIFY
instrumentation/grizzly-2.0/javaagent/src/test/groovy/GrizzlyTest.groovy
instrumentation/grizzly-2.0/javaagent/src/test/groovy/GrizzlyTest.groovy
@@ -106,9 +106,4 @@ class GrizzlyTest extends HttpServerTest<HttpServer> implements AgentTestTrait {
}
}
}
-
- @Override
- boolean testExceptionBody() {
- false
- }
}

MODIFY
instrumentation/jetty-8.0/javaagent/src/test/groovy/JettyHandlerTest.groovy
instrumentation/jetty-8.0/javaagent/src/test/groovy/JettyHandlerTest.groovy
@@ -59,11 +59,6 @@ class JettyHandlerTest extends HttpServerTest<Server> implements AgentTestTrait
server.stop()
}
- @Override
- boolean testExceptionBody() {
- false
- }
-
@Override
boolean hasResponseSpan(ServerEndpoint endpoint) {
endpoint == REDIRECT || endpoint == ERROR

MODIFY
instrumentation/play/play-2.4/javaagent/src/test/groovy/server/PlayServerTest.groovy
instrumentation/play/play-2.4/javaagent/src/test/groovy/server/PlayServerTest.groovy
@@ -65,11 +65,6 @@ class PlayServerTest extends HttpServerTest<Server> implements AgentTestTrait {
true
}
- boolean testExceptionBody() {
- // I can't figure out how to set a proper exception handler to customize the response body.
- false
- }
-
@Override
void handlerSpan(TraceAssert trace, int index, Object parent, String method = "GET", ServerEndpoint endpoint = SUCCESS) {
trace.span(index) {

MODIFY
instrumentation/play/play-2.6/javaagent/src/test/groovy/server/PlayServerTest.groovy
instrumentation/play/play-2.6/javaagent/src/test/groovy/server/PlayServerTest.groovy
@@ -67,11 +67,6 @@ class PlayServerTest extends HttpServerTest<Server> implements AgentTestTrait {
true
}
- boolean testExceptionBody() {
- // I can't figure out how to set a proper exception handler to customize the response body.
- false
- }
-
@Override
void handlerSpan(TraceAssert trace, int index, Object parent, String method = "GET", ServerEndpoint endpoint = SUCCESS) {
trace.span(index) {

MODIFY
instrumentation/servlet/glassfish-testing/src/test/groovy/GlassFishServerTest.groovy
instrumentation/servlet/glassfish-testing/src/test/groovy/GlassFishServerTest.groovy
@@ -65,11 +65,6 @@ class GlassFishServerTest extends HttpServerTest<GlassFish> implements AgentTest
server.stop()
}
- @Override
- boolean redirectHasBody() {
- true
- }
-
@Override
boolean hasResponseSpan(ServerEndpoint endpoint) {
endpoint == REDIRECT || endpoint == ERROR || endpoint == NOT_FOUND

MODIFY
instrumentation/servlet/servlet-3.0/javaagent/src/test/groovy/TomcatServlet3Test.groovy
instrumentation/servlet/servlet-3.0/javaagent/src/test/groovy/TomcatServlet3Test.groovy
@@ -32,11 +32,6 @@ import spock.lang.Unroll
@Unroll
abstract class TomcatServlet3Test extends AbstractServlet3Test<Tomcat, Context> {
- @Override
- boolean testExceptionBody() {
- return false
- }
-
@Override
Class<?> expectedExceptionClass() {
ServletException

MODIFY
instrumentation/spring/spring-webmvc-3.1/javaagent/src/test/groovy/test/filter/ServletFilterTest.groovy
instrumentation/spring/spring-webmvc-3.1/javaagent/src/test/groovy/test/filter/ServletFilterTest.groovy
@@ -72,11 +72,6 @@ class ServletFilterTest extends HttpServerTest<ConfigurableApplicationContext> i
true
}
- @Override
- boolean testExceptionBody() {
- false
- }
-
@Override
boolean testNotFound() {
// FIXME: the instrumentation adds an extra controller span which is not consistent.

MODIFY
instrumentation/struts-2.3/javaagent/src/test/groovy/Struts2ActionSpanTest.groovy
instrumentation/struts-2.3/javaagent/src/test/groovy/Struts2ActionSpanTest.groovy
@@ -33,11 +33,6 @@ class Struts2ActionSpanTest extends HttpServerTest<Server> implements AgentTestT
return true
}
- @Override
- boolean testExceptionBody() {
- return false
- }
-
@Override
boolean testErrorBody() {
return false

MODIFY
instrumentation/tomcat-7.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat7/TestServlet.java
instrumentation/tomcat-7.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat7/TestServlet.java
@@ -35,9 +35,6 @@ public class TestServlet extends HttpServlet {
}
return null;
});
- } else if ("/errorPage".equals(path)) {
- resp.getWriter().print(HttpServerTest.ServerEndpoint.EXCEPTION.getBody());
- resp.setStatus(500);
} else {
resp.getWriter().println("No cookie for you: " + path);
resp.setStatus(400);

MODIFY
instrumentation/tomcat-7.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat7/TomcatHandlerTest.groovy
instrumentation/tomcat-7.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat7/TomcatHandlerTest.groovy
package io.opentelemetry.javaagent.instrumentation.tomcat7
-import static io.opentelemetry.api.trace.SpanKind.INTERNAL
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
-import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT
-import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS
import io.opentelemetry.instrumentation.test.AgentTestTrait
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
import io.opentelemetry.instrumentation.test.base.HttpServerTest
-import io.opentelemetry.sdk.trace.data.SpanData
import org.apache.catalina.Context
import org.apache.catalina.startup.Tomcat
-import org.apache.tomcat.util.descriptor.web.ErrorPage
class TomcatHandlerTest extends HttpServerTest<Tomcat> implements AgentTestTrait {
@@ -42,12 +37,6 @@ class TomcatHandlerTest extends HttpServerTest<Tomcat> implements AgentTestTrait
Tomcat.addServlet(ctx, "testServlet", new TestServlet())
- def errorPage = new ErrorPage()
- errorPage.setLocation("/errorPage")
- errorPage.setErrorCode(500)
- ctx.addErrorPage(errorPage)
- ctx.addServletMappingDecoded("/errorPage", "testServlet")
-
// Mapping servlet to /* will result in all requests have a name of just a context.
ServerEndpoint.values().each {
ctx.addServletMappingDecoded(it.path, "testServlet")
@@ -62,28 +51,6 @@ class TomcatHandlerTest extends HttpServerTest<Tomcat> implements AgentTestTrait
tomcat.getServer().stop()
}
- @Override
- boolean testExceptionBody() {
- false
- }
-
- @Override
- boolean hasErrorPageSpans(ServerEndpoint endpoint) {
- endpoint == ERROR || endpoint == EXCEPTION
- }
-
- @Override
- void errorPageSpans(TraceAssert trace, int index, Object parent, String method = "GET", ServerEndpoint endpoint = SUCCESS) {
- trace.span(index) {
- name "ApplicationDispatcher.forward"
- kind INTERNAL
- errored false
- childOf((SpanData) parent)
- attributes {
- }
- }
- }
-
@Override
boolean hasResponseSpan(ServerEndpoint endpoint) {
endpoint == REDIRECT || endpoint == ERROR

MODIFY
instrumentation/undertow/javaagent/src/test/groovy/UndertowServerTest.groovy
instrumentation/undertow/javaagent/src/test/groovy/UndertowServerTest.groovy
@@ -66,9 +66,4 @@ class UndertowServerTest extends HttpServerTest<Undertow> implements AgentTestTr
String expectedServerSpanName(ServerEndpoint endpoint) {
return "PathHandler.handleRequest"
}
-
- @Override
- boolean testExceptionBody() {
- false
- }
}

MODIFY
instrumentation/vertx-reactive-3.5/javaagent/src/test/groovy/server/VertxRxHttpServerTest.groovy
instrumentation/vertx-reactive-3.5/javaagent/src/test/groovy/server/VertxRxHttpServerTest.groovy
@@ -53,11 +53,6 @@ class VertxRxHttpServerTest extends HttpServerTest<Vertx> implements AgentTestTr
server.close()
}
- @Override
- boolean testExceptionBody() {
- return false
- }
-
@Override
boolean testException() {
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/807

MODIFY
instrumentation/vertx-web-3.0/src/test/groovy/server/VertxHttpServerTest.groovy
instrumentation/vertx-web-3.0/src/test/groovy/server/VertxHttpServerTest.groovy
@@ -48,11 +48,6 @@ class VertxHttpServerTest extends HttpServerTest<Vertx> implements AgentTestTrai
server.close()
}
- @Override
- boolean testExceptionBody() {
- return false
- }
-
@Override
boolean testException() {
// TODO(anuraaga): https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/807

MODIFY
testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy
testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy
@@ -67,10 +67,6 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
false
}
- boolean redirectHasBody() {
- false
- }
-
boolean testNotFound() {
true
}
@@ -83,10 +79,6 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
true
}
- boolean testExceptionBody() {
- true
- }
-
boolean testException() {
true
}
@@ -261,7 +253,6 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
response.code() == REDIRECT.status
response.header("location") == REDIRECT.body ||
response.header("location") == "${address.resolve(REDIRECT.body)}"
- response.body().contentLength() < 1 || redirectHasBody()
and:
assertTheTraces(1, null, null, method, REDIRECT, null, response)
@@ -299,9 +290,6 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
expect:
response.code() == EXCEPTION.status
- if (testExceptionBody()) {
- assert response.body().string() == EXCEPTION.body
- }
and:
assertTheTraces(1, null, null, method, EXCEPTION, EXCEPTION.body, response)

Remove HttpServerTest.testExceptionBody and redirectHasBody (#2346)