Enabled spring RestTemplate tests for spring 6
@@ -43,8 +43,11 @@ package co.elastic.apm.agent.resttemplate;
*/
import co.elastic.apm.agent.TestClassWithDependencyRunner;
+import org.junit.jupiter.api.condition.EnabledForJreRange;
+import org.junit.jupiter.api.condition.JRE;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
+import org.junit.jupiter.params.provider.ValueSource;
import java.util.List;
import java.util.stream.Collectors;
@@ -62,12 +65,36 @@ public class SpringRestTemplateVersionsIT {
"4.1.0.RELEASE|true",
"4.2.0.RELEASE|true",
"4.3.0.RELEASE|true",
- "5.0.0.RELEASE|true",
- "5.1.0.RELEASE|true",
- "5.2.0.RELEASE|true",
- "[5.3.0,6.0.0)|true" // using ivy range specifier to make test against later versions
})
- void testVersion(String version, boolean isSupported) throws Exception {
+ void testVersion4AndOlder(String version, boolean isSupported) throws Exception {
+ testVersionImpl(version, isSupported, List.of("org.slf4j:jcl-over-slf4j:1.7.30"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {
+ "5.0.0.RELEASE",
+ "5.1.0.RELEASE",
+ "5.2.0.RELEASE",
+ "[5.3.0,6.0.0)", // using ivy range specifier to make test against later versions
+ })
+ void testVersion5(String version) throws Exception {
+ testVersionImpl(version, true, List.of(String.format("org.springframework:spring-jcl:%s", version)));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {
+ "[6.0.0,7.0.0)" // using ivy range specifier to make test against later versions
+ })
+ @EnabledForJreRange(min = JRE.JAVA_17, disabledReason = "Spring 6 requires JDK 17")
+ void testVersion6(String version) throws Exception {
+ testVersionImpl(version, true, List.of(
+ String.format("org.springframework:spring-jcl:%s", version),
+ "io.micrometer:micrometer-observation:1.10.2",
+ "io.micrometer:micrometer-commons:1.10.2"
+ ));
+ }
+
+ void testVersionImpl(String version, boolean isSupported, List<String> additionalDependencies) throws Exception {
List<String> dependencies = Stream.of(
"spring-webmvc",
"spring-aop",
@@ -79,12 +106,7 @@ public class SpringRestTemplateVersionsIT {
.map(s -> String.format("org.springframework:%s:%s", s, version))
.collect(Collectors.toList());
- if (version.startsWith("5.")) {
- dependencies.add(String.format("org.springframework:spring-jcl:%s", version));
- } else {
- dependencies.add("org.slf4j:jcl-over-slf4j:1.7.30");
- }
-
+ dependencies.addAll(additionalDependencies);
Class<?> testClass = SprintRestTemplateIntegration.class;
Class<?>[] otherClasses = new Class<?>[0];
@@ -96,5 +118,4 @@ public class SpringRestTemplateVersionsIT {
runner.run();
}
-
}
