mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-10-01 23:09:01 +00:00
Upgrade to JUnit Jupiter 5.13.1
Closes gh-46058
This commit is contained in:
+1
-1
@@ -13,7 +13,7 @@ graalVersion=22.3
|
||||
hamcrestVersion=3.0
|
||||
jacksonVersion=2.19.1
|
||||
javaFormatVersion=0.0.47
|
||||
junitJupiterVersion=5.12.2
|
||||
junitJupiterVersion=5.13.1
|
||||
kotlinVersion=2.1.0
|
||||
mavenVersion=3.9.10
|
||||
mockitoVersion=5.17.0
|
||||
|
||||
+3
-1
@@ -24,6 +24,7 @@ import org.junit.jupiter.api.Named;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
||||
import org.junit.jupiter.params.support.ParameterDeclarations;
|
||||
|
||||
import org.springframework.security.oauth2.jwt.Jwt;
|
||||
|
||||
@@ -37,7 +38,8 @@ import org.springframework.security.oauth2.jwt.Jwt;
|
||||
public final class JwtConverterCustomizationsArgumentsProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext extensionContext) {
|
||||
public Stream<? extends Arguments> provideArguments(ParameterDeclarations parameterDeclarations,
|
||||
ExtensionContext extensionContext) {
|
||||
String customPrefix = "CUSTOM_AUTHORITY_PREFIX_";
|
||||
String customDelimiter = "[~,#:]";
|
||||
String customAuthoritiesClaim = "custom_authorities";
|
||||
|
||||
+21
-2
@@ -69,7 +69,7 @@ class ResourcesExtension implements BeforeEachCallback, AfterEachCallback, Param
|
||||
.addPackage(testMethod.getDeclaringClass().getPackage(), withPackageResources.value()));
|
||||
ResourcesClassLoader classLoader = new ResourcesClassLoader(context.getRequiredTestClass().getClassLoader(),
|
||||
resources);
|
||||
store.put(TCCL_KEY, Thread.currentThread().getContextClassLoader());
|
||||
store.put(TCCL_KEY, new Tccl());
|
||||
Thread.currentThread().setContextClassLoader(classLoader);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ class ResourcesExtension implements BeforeEachCallback, AfterEachCallback, Param
|
||||
public void afterEach(ExtensionContext context) throws Exception {
|
||||
Store store = context.getStore(Namespace.create(ResourcesExtension.class));
|
||||
store.get(RESOURCES_KEY, Resources.class).delete();
|
||||
Thread.currentThread().setContextClassLoader(store.get(TCCL_KEY, ClassLoader.class));
|
||||
Thread.currentThread().setContextClassLoader(store.get(TCCL_KEY, Tccl.class).get());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -183,4 +183,23 @@ class ResourcesExtension implements BeforeEachCallback, AfterEachCallback, Param
|
||||
return resources;
|
||||
}
|
||||
|
||||
/**
|
||||
* Holder for the thread context class loader that can be safely
|
||||
* {@link Store#put(Object, Object) stored} without it causing unwanted
|
||||
* {@link ClassLoader#close closure} of the class loader.
|
||||
*/
|
||||
private static class Tccl {
|
||||
|
||||
private final ClassLoader classLoader;
|
||||
|
||||
Tccl() {
|
||||
this.classLoader = Thread.currentThread().getContextClassLoader();
|
||||
}
|
||||
|
||||
ClassLoader get() {
|
||||
return this.classLoader;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -22,6 +22,7 @@ import java.util.stream.Stream;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
||||
import org.junit.jupiter.params.support.ParameterDeclarations;
|
||||
import org.junit.platform.commons.util.Preconditions;
|
||||
|
||||
/**
|
||||
@@ -32,7 +33,8 @@ import org.junit.platform.commons.util.Preconditions;
|
||||
class BooleanArgumentsProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
public Stream<? extends Arguments> provideArguments(ParameterDeclarations parameterDeclarations,
|
||||
ExtensionContext context) {
|
||||
Method testMethod = context.getRequiredTestMethod();
|
||||
Preconditions.condition(testMethod.getParameterCount() > 0, () -> String.format(
|
||||
"@BooleanValueSource cannot provide arguments to method [%s]: the method does not declare any formal parameters.",
|
||||
|
||||
Reference in New Issue
Block a user