Fix apache shenyu latest dep test (#13037)

This commit is contained in:
Lauri Tulmin 2025-01-14 15:26:54 +02:00 committed by GitHub
parent ff331d8e0d
commit cefd973d40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 20 deletions

View File

@ -26,12 +26,21 @@ dependencies {
exclude("org.codehaus.groovy", "groovy")
}
// the latest version of apache shenyu uses spring-boot 2.7
latestDepTestLibrary("org.springframework.boot:spring-boot-starter-test:2.7.+") // related dependency
// the latest version of apache shenyu uses spring-boot 3.3
latestDepTestLibrary("org.springframework.boot:spring-boot-starter-test:3.3.+") // related dependency
testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent"))
}
val latestDepTest = findProperty("testLatestDeps") as Boolean
// spring 6 (spring boot 3) requires java 17
if (latestDepTest) {
otelJava {
minJavaVersionSupported.set(JavaVersion.VERSION_17)
}
}
tasks.withType<Test>().configureEach {
jvmArgs("-Dotel.instrumentation.apache-shenyu.experimental-span-attributes=true")
@ -39,13 +48,16 @@ tasks.withType<Test>().configureEach {
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
systemProperty("testLatestDeps", latestDepTest)
}
configurations.testRuntimeClasspath {
resolutionStrategy {
// requires old logback (and therefore also old slf4j)
force("ch.qos.logback:logback-classic:1.2.11")
force("org.slf4j:slf4j-api:1.7.36")
// spring 6 (spring boot 3) uses slf4j 2.0
if (!latestDepTest) {
configurations.testRuntimeClasspath {
resolutionStrategy {
// requires old logback (and therefore also old slf4j)
force("ch.qos.logback:logback-classic:1.2.11")
force("org.slf4j:slf4j-api:1.7.36")
}
}
}

View File

@ -74,7 +74,7 @@ class ShenYuRouteTest {
InvocationTargetException,
IllegalAccessException {
Class<?> metaDataCache = null;
Class<?> metaDataCache;
try {
metaDataCache = Class.forName("org.apache.shenyu.plugin.global.cache.MetaDataCache");
} catch (ClassNotFoundException e) {
@ -87,17 +87,18 @@ class ShenYuRouteTest {
cacheMethod.invoke(
cacheInst,
new MetaData(
"123",
"test-shenyu",
"/",
"/a/b/c",
"http",
"shenyu-service",
"hello",
"string",
"test-ext",
true));
MetaData.builder()
.id("123")
.appName("test-shenyu")
.contextPath("/")
.path("/a/b/c")
.rpcType("http")
.serviceName("shenyu-service")
.methodName("hello")
.parameterTypes("string")
.rpcExt("test-ext")
.enabled(true)
.build());
}
@Test