From 7bc23f923c3c4eb99b839624f237b2ae4bd81cc2 Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Wed, 12 Apr 2023 14:26:45 +0200 Subject: [PATCH 1/7] Cleaned up spring boot integration test dependency management --- integration-tests/spring-boot-2/pom.xml | 28 +++++++++++++++++++ .../spring-boot-2/spring-boot-2-base/pom.xml | 19 ------------- .../spring/boot/AbstractSpringBootTest.java | 13 ++++++--- .../spring-boot-2/spring-boot-2-jetty/pom.xml | 1 - .../spring-boot-2-undertow/pom.xml | 1 - 5 files changed, 37 insertions(+), 25 deletions(-) diff --git a/integration-tests/spring-boot-2/pom.xml b/integration-tests/spring-boot-2/pom.xml index f251a9764e..a2fc381ba4 100644 --- a/integration-tests/spring-boot-2/pom.xml +++ b/integration-tests/spring-boot-2/pom.xml @@ -25,6 +25,19 @@ ${project.basedir}/../.. + + + + + org.springframework.boot + spring-boot-dependencies + 2.7.10 + pom + import + + + + ${project.groupId} @@ -57,4 +70,19 @@ + + + + maven-jar-plugin + + + + test-jar + + + + + + + diff --git a/integration-tests/spring-boot-2/spring-boot-2-base/pom.xml b/integration-tests/spring-boot-2/spring-boot-2-base/pom.xml index d6fbbd83ea..c448304a56 100644 --- a/integration-tests/spring-boot-2/spring-boot-2-base/pom.xml +++ b/integration-tests/spring-boot-2/spring-boot-2-base/pom.xml @@ -16,26 +16,10 @@ ${project.basedir}/../../.. - - - - maven-jar-plugin - - - - test-jar - - - - - - - org.springframework.boot spring-boot-starter-web - ${version.spring-boot} @@ -47,17 +31,14 @@ org.springframework.boot spring-boot-starter-log4j2 - ${version.spring-boot} org.springframework.boot spring-boot-starter-security - ${version.spring-boot} org.springframework.boot spring-boot-starter-test - ${version.spring-boot} diff --git a/integration-tests/spring-boot-2/spring-boot-2-base/src/test/java/co/elastic/apm/spring/boot/AbstractSpringBootTest.java b/integration-tests/spring-boot-2/spring-boot-2-base/src/test/java/co/elastic/apm/spring/boot/AbstractSpringBootTest.java index a5b5a7e5cd..b7d71436b2 100644 --- a/integration-tests/spring-boot-2/spring-boot-2-base/src/test/java/co/elastic/apm/spring/boot/AbstractSpringBootTest.java +++ b/integration-tests/spring-boot-2/spring-boot-2-base/src/test/java/co/elastic/apm/spring/boot/AbstractSpringBootTest.java @@ -50,6 +50,7 @@ import org.springframework.web.bind.annotation.RestController; import org.stagemonitor.configuration.ConfigurationRegistry; +import java.time.Duration; import java.util.Collections; import static org.assertj.core.api.Java6Assertions.assertThat; @@ -78,9 +79,9 @@ public static void beforeClass() { public void setUp() { doReturn(true).when(config.getConfig(ReporterConfiguration.class)).isReportSynchronously(); restTemplate = new TestRestTemplate(new RestTemplateBuilder() - .setConnectTimeout(0) - .setReadTimeout(0) - .basicAuthorization("username", "password")); + .setConnectTimeout(Duration.ZERO) + .setReadTimeout(Duration.ZERO) + .basicAuthentication("username", "password")); reporter.reset(); } @@ -106,7 +107,11 @@ public void greetingShouldReturnDefaultMessage() throws Exception { // the service.name will not be overwritten for the webapp class loader based on spring.application.name assertThat(transaction.getTraceContext().getServiceName()).isNull(); assertThat(transaction.getFrameworkName()).isEqualTo("Spring Web MVC"); - assertThat(transaction.getFrameworkVersion()).isEqualTo("5.1.9.RELEASE"); + assertThat(transaction.getFrameworkVersion()).matches(getExpectedSpringVersionRegex()); + } + + protected String getExpectedSpringVersionRegex() { + return "5\\.[0-9]+\\.[0-9]+"; } @Test diff --git a/integration-tests/spring-boot-2/spring-boot-2-jetty/pom.xml b/integration-tests/spring-boot-2/spring-boot-2-jetty/pom.xml index 5e6c39c2f4..4a0f2ddf23 100644 --- a/integration-tests/spring-boot-2/spring-boot-2-jetty/pom.xml +++ b/integration-tests/spring-boot-2/spring-boot-2-jetty/pom.xml @@ -34,7 +34,6 @@ org.springframework.boot spring-boot-starter-jetty - ${version.spring-boot} diff --git a/integration-tests/spring-boot-2/spring-boot-2-undertow/pom.xml b/integration-tests/spring-boot-2/spring-boot-2-undertow/pom.xml index b292e1542b..b532ca93b0 100644 --- a/integration-tests/spring-boot-2/spring-boot-2-undertow/pom.xml +++ b/integration-tests/spring-boot-2/spring-boot-2-undertow/pom.xml @@ -34,7 +34,6 @@ org.springframework.boot spring-boot-starter-undertow - ${version.spring-boot} From 7f7e6ff4268f2b444b556a4c22e6a2f35dca2ccd Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Wed, 12 Apr 2023 14:29:19 +0200 Subject: [PATCH 2/7] Added spring-boot-3 IT parent --- integration-tests/pom.xml | 1 + integration-tests/spring-boot-3/pom.xml | 85 +++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 integration-tests/spring-boot-3/pom.xml diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index bf4df98240..4b83c0ac4b 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -28,6 +28,7 @@ runtime-attach jakartaee-jsf-app main-app-test + spring-boot-3 diff --git a/integration-tests/spring-boot-3/pom.xml b/integration-tests/spring-boot-3/pom.xml new file mode 100644 index 0000000000..b15f31c85b --- /dev/null +++ b/integration-tests/spring-boot-3/pom.xml @@ -0,0 +1,85 @@ + + + 4.0.0 + + + integration-tests + co.elastic.apm + 1.36.1-SNAPSHOT + + + spring-boot-3 + pom + + ${project.groupId}:${project.artifactId} + + + + + + 2.1.8.RELEASE + ${project.basedir}/../.. + + + + + + + org.springframework.boot + spring-boot-dependencies + 3.0.5 + pom + import + + + + + + + ${project.groupId} + apm-agent-core + test-jar + ${project.version} + test + + + + ${project.groupId} + apm-spring-webmvc-plugin + ${project.version} + + + ${project.groupId} + apm-servlet-plugin + ${project.version} + + + ${project.groupId} + apm-api-plugin + ${project.version} + + + ${project.groupId} + apm-agent-api + ${project.version} + test + + + + + + + maven-jar-plugin + + + + test-jar + + + + + + + + From d8c6e71e34f4c9fcbff721eb3b1603fda79f45dc Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Wed, 12 Apr 2023 15:17:17 +0200 Subject: [PATCH 3/7] Added spring boot 3 integration tests --- integration-tests/spring-boot-2/pom.xml | 1 - .../spring/boot/AbstractSpringBootTest.java | 42 +++++++++---------- .../spring-boot-2/spring-boot-2-jetty/pom.xml | 1 - .../spring-boot-2-tomcat/pom.xml | 1 - .../spring-boot-2-undertow/pom.xml | 1 - integration-tests/spring-boot-3/pom.xml | 8 ++-- .../spring-boot-3/spring-boot-3-jetty/pom.xml | 35 ++++++++++++++++ .../apm/spring/boot/SpringBoot3JettyIT.java | 9 ++++ .../spring-boot-3-tomcat/pom.xml | 30 +++++++++++++ .../apm/spring/boot/SpringBoot3TomcatIT.java | 9 ++++ .../spring-boot-3-undertow/pom.xml | 30 +++++++++++++ .../spring/boot/SpringBoot3UndertowIT.java | 9 ++++ 12 files changed, 146 insertions(+), 30 deletions(-) create mode 100644 integration-tests/spring-boot-3/spring-boot-3-jetty/pom.xml create mode 100644 integration-tests/spring-boot-3/spring-boot-3-jetty/src/test/java/co/elastic/apm/spring/boot/SpringBoot3JettyIT.java create mode 100644 integration-tests/spring-boot-3/spring-boot-3-tomcat/pom.xml create mode 100644 integration-tests/spring-boot-3/spring-boot-3-tomcat/src/test/java/co/elastic/apm/spring/boot/SpringBoot3TomcatIT.java create mode 100644 integration-tests/spring-boot-3/spring-boot-3-undertow/pom.xml create mode 100644 integration-tests/spring-boot-3/spring-boot-3-undertow/src/test/java/co/elastic/apm/spring/boot/SpringBoot3UndertowIT.java diff --git a/integration-tests/spring-boot-2/pom.xml b/integration-tests/spring-boot-2/pom.xml index a2fc381ba4..65f016c6e7 100644 --- a/integration-tests/spring-boot-2/pom.xml +++ b/integration-tests/spring-boot-2/pom.xml @@ -21,7 +21,6 @@ - 2.1.8.RELEASE ${project.basedir}/../.. diff --git a/integration-tests/spring-boot-2/spring-boot-2-base/src/test/java/co/elastic/apm/spring/boot/AbstractSpringBootTest.java b/integration-tests/spring-boot-2/spring-boot-2-base/src/test/java/co/elastic/apm/spring/boot/AbstractSpringBootTest.java index b7d71436b2..3551cf1957 100644 --- a/integration-tests/spring-boot-2/spring-boot-2-base/src/test/java/co/elastic/apm/spring/boot/AbstractSpringBootTest.java +++ b/integration-tests/spring-boot-2/spring-boot-2-base/src/test/java/co/elastic/apm/spring/boot/AbstractSpringBootTest.java @@ -35,16 +35,15 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.boot.web.server.LocalServerPort; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.provisioning.InMemoryUserDetailsManager; +import org.springframework.security.web.SecurityFilterChain; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -127,6 +126,7 @@ public void testStaticFile() { @RestController @SpringBootApplication + @EnableWebSecurity public static class TestApp { public static void main(String[] args) { @@ -139,26 +139,22 @@ public String greeting() { return "Hello World"; } - @Configuration - @EnableWebSecurity - public class WebSecurityConfig extends WebSecurityConfigurerAdapter { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests() - .anyRequest().authenticated() - .and() - .httpBasic(); - } - - @Bean - @Override - public UserDetailsService userDetailsService() { - return new InMemoryUserDetailsManager(User.withDefaultPasswordEncoder() - .username("username") - .password("password") - .roles("USER") - .build()); - } + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + http.authorizeRequests() + .anyRequest().authenticated() + .and() + .httpBasic(); + return http.build(); + } + + @Bean + public UserDetailsService userDetailsService() { + return new InMemoryUserDetailsManager(User.withDefaultPasswordEncoder() + .username("username") + .password("password") + .roles("USER") + .build()); } } diff --git a/integration-tests/spring-boot-2/spring-boot-2-jetty/pom.xml b/integration-tests/spring-boot-2/spring-boot-2-jetty/pom.xml index 4a0f2ddf23..57df03471b 100644 --- a/integration-tests/spring-boot-2/spring-boot-2-jetty/pom.xml +++ b/integration-tests/spring-boot-2/spring-boot-2-jetty/pom.xml @@ -22,7 +22,6 @@ spring-boot-2-base ${project.version} test-jar - test diff --git a/integration-tests/spring-boot-2/spring-boot-2-tomcat/pom.xml b/integration-tests/spring-boot-2/spring-boot-2-tomcat/pom.xml index ac72bed2ac..1f93dc3fad 100644 --- a/integration-tests/spring-boot-2/spring-boot-2-tomcat/pom.xml +++ b/integration-tests/spring-boot-2/spring-boot-2-tomcat/pom.xml @@ -22,7 +22,6 @@ spring-boot-2-base ${project.version} test-jar - test diff --git a/integration-tests/spring-boot-2/spring-boot-2-undertow/pom.xml b/integration-tests/spring-boot-2/spring-boot-2-undertow/pom.xml index b532ca93b0..5a70868ac9 100644 --- a/integration-tests/spring-boot-2/spring-boot-2-undertow/pom.xml +++ b/integration-tests/spring-boot-2/spring-boot-2-undertow/pom.xml @@ -22,7 +22,6 @@ spring-boot-2-base ${project.version} test-jar - test diff --git a/integration-tests/spring-boot-3/pom.xml b/integration-tests/spring-boot-3/pom.xml index b15f31c85b..459ac5ba7e 100644 --- a/integration-tests/spring-boot-3/pom.xml +++ b/integration-tests/spring-boot-3/pom.xml @@ -6,7 +6,7 @@ integration-tests co.elastic.apm - 1.36.1-SNAPSHOT + 1.37.1-SNAPSHOT spring-boot-3 @@ -15,16 +15,18 @@ ${project.groupId}:${project.artifactId} + spring-boot-3-jetty + spring-boot-3-tomcat + spring-boot-3-undertow - 2.1.8.RELEASE ${project.basedir}/../.. - + org.springframework.boot spring-boot-dependencies diff --git a/integration-tests/spring-boot-3/spring-boot-3-jetty/pom.xml b/integration-tests/spring-boot-3/spring-boot-3-jetty/pom.xml new file mode 100644 index 0000000000..9af8908583 --- /dev/null +++ b/integration-tests/spring-boot-3/spring-boot-3-jetty/pom.xml @@ -0,0 +1,35 @@ + + + + spring-boot-3 + co.elastic.apm + 1.37.1-SNAPSHOT + + 4.0.0 + + spring-boot-3-jetty + + ${project.groupId}:${project.artifactId} + + + ${project.basedir}/../../.. + + + + + jakarta.servlet + jakarta.servlet-api + 5.0.0 + + + ${project.groupId} + spring-boot-2-jetty + ${project.version} + test-jar + test + + + + diff --git a/integration-tests/spring-boot-3/spring-boot-3-jetty/src/test/java/co/elastic/apm/spring/boot/SpringBoot3JettyIT.java b/integration-tests/spring-boot-3/spring-boot-3-jetty/src/test/java/co/elastic/apm/spring/boot/SpringBoot3JettyIT.java new file mode 100644 index 0000000000..37932c313d --- /dev/null +++ b/integration-tests/spring-boot-3/spring-boot-3-jetty/src/test/java/co/elastic/apm/spring/boot/SpringBoot3JettyIT.java @@ -0,0 +1,9 @@ +package co.elastic.apm.spring.boot; + +public class SpringBoot3JettyIT extends SpringBootJettyIT { + + @Override + protected String getExpectedSpringVersionRegex() { + return "6\\.[0-9]+\\.[0-9]+"; + } +} diff --git a/integration-tests/spring-boot-3/spring-boot-3-tomcat/pom.xml b/integration-tests/spring-boot-3/spring-boot-3-tomcat/pom.xml new file mode 100644 index 0000000000..85a13be47b --- /dev/null +++ b/integration-tests/spring-boot-3/spring-boot-3-tomcat/pom.xml @@ -0,0 +1,30 @@ + + + + spring-boot-3 + co.elastic.apm + 1.37.1-SNAPSHOT + + 4.0.0 + + spring-boot-3-tomcat + + ${project.groupId}:${project.artifactId} + + + ${project.basedir}/../../.. + + + + + ${project.groupId} + spring-boot-2-tomcat + ${project.version} + test-jar + test + + + + diff --git a/integration-tests/spring-boot-3/spring-boot-3-tomcat/src/test/java/co/elastic/apm/spring/boot/SpringBoot3TomcatIT.java b/integration-tests/spring-boot-3/spring-boot-3-tomcat/src/test/java/co/elastic/apm/spring/boot/SpringBoot3TomcatIT.java new file mode 100644 index 0000000000..1396d57e2a --- /dev/null +++ b/integration-tests/spring-boot-3/spring-boot-3-tomcat/src/test/java/co/elastic/apm/spring/boot/SpringBoot3TomcatIT.java @@ -0,0 +1,9 @@ +package co.elastic.apm.spring.boot; + +public class SpringBoot3TomcatIT extends SpringBootTomcatIT { + + @Override + protected String getExpectedSpringVersionRegex() { + return "6\\.[0-9]+\\.[0-9]+"; + } +} diff --git a/integration-tests/spring-boot-3/spring-boot-3-undertow/pom.xml b/integration-tests/spring-boot-3/spring-boot-3-undertow/pom.xml new file mode 100644 index 0000000000..442701f8a3 --- /dev/null +++ b/integration-tests/spring-boot-3/spring-boot-3-undertow/pom.xml @@ -0,0 +1,30 @@ + + + + spring-boot-3 + co.elastic.apm + 1.37.1-SNAPSHOT + + 4.0.0 + + spring-boot-3-undertow + + ${project.groupId}:${project.artifactId} + + + ${project.basedir}/../../.. + + + + + ${project.groupId} + spring-boot-2-undertow + ${project.version} + test-jar + test + + + + diff --git a/integration-tests/spring-boot-3/spring-boot-3-undertow/src/test/java/co/elastic/apm/spring/boot/SpringBoot3UndertowIT.java b/integration-tests/spring-boot-3/spring-boot-3-undertow/src/test/java/co/elastic/apm/spring/boot/SpringBoot3UndertowIT.java new file mode 100644 index 0000000000..7acb5b575f --- /dev/null +++ b/integration-tests/spring-boot-3/spring-boot-3-undertow/src/test/java/co/elastic/apm/spring/boot/SpringBoot3UndertowIT.java @@ -0,0 +1,9 @@ +package co.elastic.apm.spring.boot; + +public class SpringBoot3UndertowIT extends SpringBootUndertowIT { + + @Override + protected String getExpectedSpringVersionRegex() { + return "6\\.[0-9]+\\.[0-9]+"; + } +} From 49456a394b7e5fee61391fd2c085c31f5aa390a4 Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Wed, 12 Apr 2023 15:35:31 +0200 Subject: [PATCH 4/7] Upgraded RestTemplate tests --- .../apm-spring-resttemplate-plugin/pom.xml | 20 ++++++--- ...SpringRestTemplateInstrumentationTest.java | 45 ++++++++++++++----- .../SpringRestTemplateVersionsIT.java | 2 +- 3 files changed, 50 insertions(+), 17 deletions(-) diff --git a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/pom.xml b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/pom.xml index 93414f7823..57ca0db75d 100644 --- a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/pom.xml +++ b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/pom.xml @@ -15,11 +15,23 @@ ${project.basedir}/../../.. + + + + + org.springframework.boot + spring-boot-dependencies + 3.0.5 + pom + import + + + + org.springframework spring-webmvc - ${version.spring} provided @@ -38,7 +50,6 @@ com.squareup.okhttp3 okhttp - ${version.okhttp} test @@ -48,9 +59,8 @@ test - org.apache.httpcomponents - httpclient - 4.3.6 + org.apache.httpcomponents.client5 + httpclient5 test diff --git a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/src/test/java/co/elastic/apm/agent/resttemplate/SpringRestTemplateInstrumentationTest.java b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/src/test/java/co/elastic/apm/agent/resttemplate/SpringRestTemplateInstrumentationTest.java index 9bc79292ad..cab58a62da 100644 --- a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/src/test/java/co/elastic/apm/agent/resttemplate/SpringRestTemplateInstrumentationTest.java +++ b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/src/test/java/co/elastic/apm/agent/resttemplate/SpringRestTemplateInstrumentationTest.java @@ -18,6 +18,7 @@ */ package co.elastic.apm.agent.resttemplate; +import co.elastic.apm.agent.common.JvmRuntimeInfo; import co.elastic.apm.agent.httpclient.AbstractHttpClientInstrumentationTest; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -27,29 +28,51 @@ import org.springframework.http.client.SimpleClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; -import java.util.Arrays; +import java.util.List; import java.util.function.Supplier; +import java.util.stream.Collectors; +import java.util.stream.Stream; @RunWith(Parameterized.class) public class SpringRestTemplateInstrumentationTest extends AbstractHttpClientInstrumentationTest { - private final RestTemplate restTemplate; + private final Object restTemplate; - public SpringRestTemplateInstrumentationTest(Supplier supplier) { - restTemplate = new RestTemplate(supplier.get()); + public SpringRestTemplateInstrumentationTest(Supplier supplier) { + restTemplate = supplier.get(); } @Parameterized.Parameters() - public static Iterable> data() { - return Arrays.asList( - SimpleClientHttpRequestFactory::new, - OkHttp3ClientHttpRequestFactory::new, - HttpComponentsClientHttpRequestFactory::new); + public static Iterable> data() { + if (JvmRuntimeInfo.ofCurrentVM().getMajorVersion() >= 17) { + return Java17Code.getRestTemplateFactories(); + } else { + return List.of(); + } } @Override protected void performGet(String path) { - // note: getForEntity is only available as of Spring-web 3.0.2 - restTemplate.getForEntity(path, String.class); + Java17Code.performGet(restTemplate, path); + } + + /** + * The code is compiled with java 17 but potentially run with java 11. + * JUnit will inspect the test class, therefore it must not contain any references to java 17 code. + */ + private static class Java17Code { + public static void performGet(Object restTemplate, String path) { + // note: getForEntity is only available as of Spring-web 3.0.2 + ((RestTemplate) restTemplate).getForEntity(path, String.class); + } + + public static Iterable> getRestTemplateFactories() { + return Stream.>of( + SimpleClientHttpRequestFactory::new, + OkHttp3ClientHttpRequestFactory::new, + HttpComponentsClientHttpRequestFactory::new) + .map(fac -> (Supplier) (() -> new RestTemplate(fac.get()))) + .collect(Collectors.toList()); + } } } diff --git a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-test/src/test/java/co/elastic/apm/agent/resttemplate/SpringRestTemplateVersionsIT.java b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-test/src/test/java/co/elastic/apm/agent/resttemplate/SpringRestTemplateVersionsIT.java index c26a569233..cbbf5dc06c 100644 --- a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-test/src/test/java/co/elastic/apm/agent/resttemplate/SpringRestTemplateVersionsIT.java +++ b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-test/src/test/java/co/elastic/apm/agent/resttemplate/SpringRestTemplateVersionsIT.java @@ -83,7 +83,7 @@ void testVersion5(String version) throws Exception { @ParameterizedTest @ValueSource(strings = { - "[6.0.0,7.0.0)" // using ivy range specifier to make test against later versions + "6.0.5" }) @EnabledForJreRange(min = JRE.JAVA_17, disabledReason = "Spring 6 requires JDK 17") void testVersion6(String version) throws Exception { From 0f1972acb53cbf17989170456b8adebb9c96670b Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Fri, 28 Apr 2023 12:49:17 +0200 Subject: [PATCH 5/7] Added a few comments --- .../apm-spring-resttemplate-plugin/pom.xml | 2 +- .../resttemplate/SpringRestTemplateInstrumentationTest.java | 1 + integration-tests/spring-boot-2/pom.xml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/pom.xml b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/pom.xml index 57ca0db75d..4f23f756ca 100644 --- a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/pom.xml +++ b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/pom.xml @@ -21,7 +21,7 @@ org.springframework.boot spring-boot-dependencies - 3.0.5 + 3.0.5 pom import diff --git a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/src/test/java/co/elastic/apm/agent/resttemplate/SpringRestTemplateInstrumentationTest.java b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/src/test/java/co/elastic/apm/agent/resttemplate/SpringRestTemplateInstrumentationTest.java index cab58a62da..29bc51f423 100644 --- a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/src/test/java/co/elastic/apm/agent/resttemplate/SpringRestTemplateInstrumentationTest.java +++ b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/src/test/java/co/elastic/apm/agent/resttemplate/SpringRestTemplateInstrumentationTest.java @@ -36,6 +36,7 @@ @RunWith(Parameterized.class) public class SpringRestTemplateInstrumentationTest extends AbstractHttpClientInstrumentationTest { + // Cannot directly reference RestTemplate here because it is compiled with Java 17 private final Object restTemplate; public SpringRestTemplateInstrumentationTest(Supplier supplier) { diff --git a/integration-tests/spring-boot-2/pom.xml b/integration-tests/spring-boot-2/pom.xml index 65f016c6e7..248ce7bf21 100644 --- a/integration-tests/spring-boot-2/pom.xml +++ b/integration-tests/spring-boot-2/pom.xml @@ -30,7 +30,7 @@ org.springframework.boot spring-boot-dependencies - 2.7.10 + 2.7.10 pom import From f7390d6c81676ef2f0ba3eb3481137ee17930b9c Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Fri, 28 Apr 2023 13:17:29 +0200 Subject: [PATCH 6/7] Skip animal sniffer for integration tests --- .../apm-spring-resttemplate-plugin/pom.xml | 1 + integration-tests/spring-boot-2/pom.xml | 1 + integration-tests/spring-boot-3/pom.xml | 1 + .../apm/spring/boot/SpringBoot3JettyIT.java | 18 ++++++++++++++++++ .../apm/spring/boot/SpringBoot3TomcatIT.java | 18 ++++++++++++++++++ .../apm/spring/boot/SpringBoot3UndertowIT.java | 18 ++++++++++++++++++ 6 files changed, 57 insertions(+) diff --git a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/pom.xml b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/pom.xml index 4f23f756ca..86fb327483 100644 --- a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/pom.xml +++ b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/pom.xml @@ -13,6 +13,7 @@ ${project.basedir}/../../.. + true diff --git a/integration-tests/spring-boot-2/pom.xml b/integration-tests/spring-boot-2/pom.xml index 248ce7bf21..4914bb5332 100644 --- a/integration-tests/spring-boot-2/pom.xml +++ b/integration-tests/spring-boot-2/pom.xml @@ -22,6 +22,7 @@ ${project.basedir}/../.. + true diff --git a/integration-tests/spring-boot-3/pom.xml b/integration-tests/spring-boot-3/pom.xml index 459ac5ba7e..b5a653be8d 100644 --- a/integration-tests/spring-boot-3/pom.xml +++ b/integration-tests/spring-boot-3/pom.xml @@ -22,6 +22,7 @@ ${project.basedir}/../.. + true diff --git a/integration-tests/spring-boot-3/spring-boot-3-jetty/src/test/java/co/elastic/apm/spring/boot/SpringBoot3JettyIT.java b/integration-tests/spring-boot-3/spring-boot-3-jetty/src/test/java/co/elastic/apm/spring/boot/SpringBoot3JettyIT.java index 37932c313d..fb5fdc0c30 100644 --- a/integration-tests/spring-boot-3/spring-boot-3-jetty/src/test/java/co/elastic/apm/spring/boot/SpringBoot3JettyIT.java +++ b/integration-tests/spring-boot-3/spring-boot-3-jetty/src/test/java/co/elastic/apm/spring/boot/SpringBoot3JettyIT.java @@ -1,3 +1,21 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package co.elastic.apm.spring.boot; public class SpringBoot3JettyIT extends SpringBootJettyIT { diff --git a/integration-tests/spring-boot-3/spring-boot-3-tomcat/src/test/java/co/elastic/apm/spring/boot/SpringBoot3TomcatIT.java b/integration-tests/spring-boot-3/spring-boot-3-tomcat/src/test/java/co/elastic/apm/spring/boot/SpringBoot3TomcatIT.java index 1396d57e2a..dc0798243b 100644 --- a/integration-tests/spring-boot-3/spring-boot-3-tomcat/src/test/java/co/elastic/apm/spring/boot/SpringBoot3TomcatIT.java +++ b/integration-tests/spring-boot-3/spring-boot-3-tomcat/src/test/java/co/elastic/apm/spring/boot/SpringBoot3TomcatIT.java @@ -1,3 +1,21 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package co.elastic.apm.spring.boot; public class SpringBoot3TomcatIT extends SpringBootTomcatIT { diff --git a/integration-tests/spring-boot-3/spring-boot-3-undertow/src/test/java/co/elastic/apm/spring/boot/SpringBoot3UndertowIT.java b/integration-tests/spring-boot-3/spring-boot-3-undertow/src/test/java/co/elastic/apm/spring/boot/SpringBoot3UndertowIT.java index 7acb5b575f..41320c3a5c 100644 --- a/integration-tests/spring-boot-3/spring-boot-3-undertow/src/test/java/co/elastic/apm/spring/boot/SpringBoot3UndertowIT.java +++ b/integration-tests/spring-boot-3/spring-boot-3-undertow/src/test/java/co/elastic/apm/spring/boot/SpringBoot3UndertowIT.java @@ -1,3 +1,21 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package co.elastic.apm.spring.boot; public class SpringBoot3UndertowIT extends SpringBootUndertowIT { From 8a38364beea61637e52939b6be3ed1259fb5ef91 Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Fri, 5 May 2023 18:06:18 +0200 Subject: [PATCH 7/7] Fix javadoc build task issues due to test-jar dependency without test scope --- .../spring-boot-2/spring-boot-2-jetty/pom.xml | 1 + .../spring-boot-2/spring-boot-2-tomcat/pom.xml | 1 + .../spring-boot-2/spring-boot-2-undertow/pom.xml | 1 + integration-tests/spring-boot-3/pom.xml | 16 ---------------- .../spring-boot-3/spring-boot-3-jetty/pom.xml | 14 ++++++++++++++ .../spring-boot-3/spring-boot-3-tomcat/pom.xml | 7 +++++++ .../spring-boot-3/spring-boot-3-undertow/pom.xml | 14 ++++++++++++++ 7 files changed, 38 insertions(+), 16 deletions(-) diff --git a/integration-tests/spring-boot-2/spring-boot-2-jetty/pom.xml b/integration-tests/spring-boot-2/spring-boot-2-jetty/pom.xml index 73b752730e..0dd5a5d042 100644 --- a/integration-tests/spring-boot-2/spring-boot-2-jetty/pom.xml +++ b/integration-tests/spring-boot-2/spring-boot-2-jetty/pom.xml @@ -22,6 +22,7 @@ spring-boot-2-base ${project.version} test-jar + test diff --git a/integration-tests/spring-boot-2/spring-boot-2-tomcat/pom.xml b/integration-tests/spring-boot-2/spring-boot-2-tomcat/pom.xml index 95c3202a19..72825811bb 100644 --- a/integration-tests/spring-boot-2/spring-boot-2-tomcat/pom.xml +++ b/integration-tests/spring-boot-2/spring-boot-2-tomcat/pom.xml @@ -22,6 +22,7 @@ spring-boot-2-base ${project.version} test-jar + test diff --git a/integration-tests/spring-boot-2/spring-boot-2-undertow/pom.xml b/integration-tests/spring-boot-2/spring-boot-2-undertow/pom.xml index df49602012..bda6b56e52 100644 --- a/integration-tests/spring-boot-2/spring-boot-2-undertow/pom.xml +++ b/integration-tests/spring-boot-2/spring-boot-2-undertow/pom.xml @@ -22,6 +22,7 @@ spring-boot-2-base ${project.version} test-jar + test diff --git a/integration-tests/spring-boot-3/pom.xml b/integration-tests/spring-boot-3/pom.xml index bb98cdff64..cb414d037e 100644 --- a/integration-tests/spring-boot-3/pom.xml +++ b/integration-tests/spring-boot-3/pom.xml @@ -69,20 +69,4 @@ test - - - - - maven-jar-plugin - - - - test-jar - - - - - - - diff --git a/integration-tests/spring-boot-3/spring-boot-3-jetty/pom.xml b/integration-tests/spring-boot-3/spring-boot-3-jetty/pom.xml index 7e3d287aee..9a96c587f5 100644 --- a/integration-tests/spring-boot-3/spring-boot-3-jetty/pom.xml +++ b/integration-tests/spring-boot-3/spring-boot-3-jetty/pom.xml @@ -23,6 +23,20 @@ jakarta.servlet-api 5.0.0 + + ${project.groupId} + spring-boot-2-base + ${project.version} + test-jar + test + + + + org.springframework.boot + spring-boot-starter-tomcat + + + ${project.groupId} spring-boot-2-jetty diff --git a/integration-tests/spring-boot-3/spring-boot-3-tomcat/pom.xml b/integration-tests/spring-boot-3/spring-boot-3-tomcat/pom.xml index 67a28e4e6c..8db3b92a24 100644 --- a/integration-tests/spring-boot-3/spring-boot-3-tomcat/pom.xml +++ b/integration-tests/spring-boot-3/spring-boot-3-tomcat/pom.xml @@ -18,6 +18,13 @@ + + ${project.groupId} + spring-boot-2-base + ${project.version} + test-jar + test + ${project.groupId} spring-boot-2-tomcat diff --git a/integration-tests/spring-boot-3/spring-boot-3-undertow/pom.xml b/integration-tests/spring-boot-3/spring-boot-3-undertow/pom.xml index 31acf5da1f..edde6f8d79 100644 --- a/integration-tests/spring-boot-3/spring-boot-3-undertow/pom.xml +++ b/integration-tests/spring-boot-3/spring-boot-3-undertow/pom.xml @@ -18,6 +18,20 @@ + + ${project.groupId} + spring-boot-2-base + ${project.version} + test-jar + test + + + + org.springframework.boot + spring-boot-starter-tomcat + + + ${project.groupId} spring-boot-2-undertow