Skip to content

Commit

Permalink
fix latest spring webmvc
Browse files Browse the repository at this point in the history
  • Loading branch information
amarziali committed Nov 26, 2024
1 parent 43fae3e commit 26ff4a9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dependencies {
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '3.0.0'
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '3.0.0'
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '3.0.0'
testImplementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
testImplementation group: 'com.google.code.gson', name: 'gson', version: '+'

latestDepTestImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '3.+'
latestDepTestImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '3.+'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ com.google.auto.service:auto-service-annotations:1.0-rc7=annotationProcessor,com
com.google.auto.service:auto-service:1.0-rc7=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor
com.google.auto:auto-common:0.10=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor
com.google.code.findbugs:jsr305:3.0.2=annotationProcessor,compileClasspath,latestDepTestAnnotationProcessor,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,spotbugs,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.code.gson:gson:2.10.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.code.gson:gson:2.11.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.code.gson:gson:2.9.1=spotbugs
com.google.errorprone:error_prone_annotations:2.2.0=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor
com.google.guava:failureaccess:1.0.1=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import datadog.trace.agent.test.base.HttpServer
import datadog.trace.agent.test.base.HttpServerTest
import datadog.trace.api.ConfigDefaults
import datadog.trace.api.DDSpanTypes
import datadog.trace.api.DDTags
import datadog.trace.api.iast.IastContext
import datadog.trace.api.iast.InstrumentationBridge
import datadog.trace.api.iast.SourceTypes
Expand Down Expand Up @@ -152,6 +153,18 @@ class SpringBootBasedTest extends HttpServerTest<ConfigurableApplicationContext>
true
}

@Override
Map<String, Serializable> expectedExtraErrorInformation(ServerEndpoint endpoint) {
System.err.println("CALLED")
// latest DispatcherServlet throws if no handlers have been found
if (endpoint == NOT_FOUND && isLatestDepTest) {
return [(DDTags.ERROR_STACK): { String },
(DDTags.ERROR_MSG) : {String},
(DDTags.ERROR_TYPE) :{String}]
}
return super.expectedExtraErrorInformation(endpoint)
}

@Override
Serializable expectedServerSpanRoute(ServerEndpoint endpoint) {
switch (endpoint) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package datadog.trace.instrumentation.springweb6.urlhandlermapping

import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM
import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.SUCCESS
import static java.util.Collections.singletonMap

import datadog.trace.agent.test.asserts.TraceAssert
import datadog.trace.agent.test.base.HttpServer
import datadog.trace.agent.test.base.HttpServerTest
import datadog.trace.api.ConfigDefaults
import datadog.trace.api.DDSpanTypes
import datadog.trace.api.DDTags
import datadog.trace.api.iast.InstrumentationBridge
import datadog.trace.api.iast.SourceTypes
import datadog.trace.api.iast.propagation.PropagationModule
Expand All @@ -19,13 +26,6 @@ import org.springframework.boot.SpringApplication
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext
import org.springframework.context.ConfigurableApplicationContext

import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.LOGIN
import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM
import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.SUCCESS
import static java.util.Collections.singletonMap

/**
* Test instrumentation of UriTemplateVariablesHandlerInterceptor
* (used by AbstractUrlHandlerMapping).
Expand Down Expand Up @@ -135,12 +135,20 @@ class UrlHandlerMappingTest extends HttpServerTest<ConfigurableApplicationContex
return ConfigDefaults.DEFAULT_SERVLET_ROOT_CONTEXT_SERVICE_NAME
}

@Override
Map<String, Serializable> expectedExtraErrorInformation(ServerEndpoint endpoint) {
// latest DispatcherServlet throws if no handlers have been found
if (endpoint == NOT_FOUND && isLatestDepTest) {
return [(DDTags.ERROR_STACK): { String },
(DDTags.ERROR_MSG): {String},
(DDTags.ERROR_TYPE):{String}]
}
return super.expectedExtraErrorInformation(endpoint)
}

@Override
Serializable expectedServerSpanRoute(ServerEndpoint endpoint) {
switch (endpoint) {
case LOGIN:
case NOT_FOUND:
return null
case PATH_PARAM:
return testPathParam()
default:
Expand Down

0 comments on commit 26ff4a9

Please sign in to comment.