Skip to content

Commit ddf3984

Browse files
committed
Upgrade to JUnit Jupiter 5.13.1
Closes gh-46058
1 parent fe049e6 commit ddf3984

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ graalVersion=22.3
1313
hamcrestVersion=3.0
1414
jacksonVersion=2.19.1
1515
javaFormatVersion=0.0.47
16-
junitJupiterVersion=5.12.2
16+
junitJupiterVersion=5.13.1
1717
kotlinVersion=2.1.0
1818
mavenVersion=3.9.10
1919
mockitoVersion=5.17.0

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/JwtConverterCustomizationsArgumentsProvider.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.junit.jupiter.api.extension.ExtensionContext;
2525
import org.junit.jupiter.params.provider.Arguments;
2626
import org.junit.jupiter.params.provider.ArgumentsProvider;
27+
import org.junit.jupiter.params.support.ParameterDeclarations;
2728

2829
import org.springframework.security.oauth2.jwt.Jwt;
2930

@@ -37,7 +38,8 @@
3738
public final class JwtConverterCustomizationsArgumentsProvider implements ArgumentsProvider {
3839

3940
@Override
40-
public Stream<? extends Arguments> provideArguments(ExtensionContext extensionContext) {
41+
public Stream<? extends Arguments> provideArguments(ParameterDeclarations parameterDeclarations,
42+
ExtensionContext extensionContext) {
4143
String customPrefix = "CUSTOM_AUTHORITY_PREFIX_";
4244
String customDelimiter = "[~,#:]";
4345
String customAuthoritiesClaim = "custom_authorities";

spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/resources/ResourcesExtension.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void beforeEach(ExtensionContext context) throws Exception {
6969
.addPackage(testMethod.getDeclaringClass().getPackage(), withPackageResources.value()));
7070
ResourcesClassLoader classLoader = new ResourcesClassLoader(context.getRequiredTestClass().getClassLoader(),
7171
resources);
72-
store.put(TCCL_KEY, Thread.currentThread().getContextClassLoader());
72+
store.put(TCCL_KEY, new Tccl());
7373
Thread.currentThread().setContextClassLoader(classLoader);
7474
}
7575

@@ -105,7 +105,7 @@ private List<WithPackageResources> packageResourcesOf(Method method, ExtensionCo
105105
public void afterEach(ExtensionContext context) throws Exception {
106106
Store store = context.getStore(Namespace.create(ResourcesExtension.class));
107107
store.get(RESOURCES_KEY, Resources.class).delete();
108-
Thread.currentThread().setContextClassLoader(store.get(TCCL_KEY, ClassLoader.class));
108+
Thread.currentThread().setContextClassLoader(store.get(TCCL_KEY, Tccl.class).get());
109109
}
110110

111111
@Override
@@ -183,4 +183,23 @@ private Resources getResources(ExtensionContext extensionContext) {
183183
return resources;
184184
}
185185

186+
/**
187+
* Holder for the thread context class loader that can be safely
188+
* {@link Store#put(Object, Object) stored} without it causing unwanted
189+
* {@link ClassLoader#close closure} of the class loader.
190+
*/
191+
private static class Tccl {
192+
193+
private final ClassLoader classLoader;
194+
195+
Tccl() {
196+
this.classLoader = Thread.currentThread().getContextClassLoader();
197+
}
198+
199+
ClassLoader get() {
200+
return this.classLoader;
201+
}
202+
203+
}
204+
186205
}

spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/BooleanArgumentsProvider.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.junit.jupiter.api.extension.ExtensionContext;
2323
import org.junit.jupiter.params.provider.Arguments;
2424
import org.junit.jupiter.params.provider.ArgumentsProvider;
25+
import org.junit.jupiter.params.support.ParameterDeclarations;
2526
import org.junit.platform.commons.util.Preconditions;
2627

2728
/**
@@ -32,7 +33,8 @@
3233
class BooleanArgumentsProvider implements ArgumentsProvider {
3334

3435
@Override
35-
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
36+
public Stream<? extends Arguments> provideArguments(ParameterDeclarations parameterDeclarations,
37+
ExtensionContext context) {
3638
Method testMethod = context.getRequiredTestMethod();
3739
Preconditions.condition(testMethod.getParameterCount() > 0, () -> String.format(
3840
"@BooleanValueSource cannot provide arguments to method [%s]: the method does not declare any formal parameters.",

0 commit comments

Comments
 (0)