Polish
This commit is contained in:
parent
199d5e5f37
commit
115a46c5e8
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -40,7 +40,7 @@ public interface ActiveProfilesResolver {
|
|||
* {@code ApplicationContext} for the given {@linkplain Class test class}.
|
||||
* @param testClass the test class for which the profiles should be resolved;
|
||||
* never {@code null}
|
||||
* @return the list of bean definition profiles to use when loading the
|
||||
* @return the bean definition profiles to use when loading the
|
||||
* {@code ApplicationContext}; never {@code null}
|
||||
* @see ActiveProfiles#resolver
|
||||
* @see ActiveProfiles#inheritProfiles
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -76,7 +76,7 @@ public abstract class BootstrapUtils {
|
|||
static BootstrapContext createBootstrapContext(Class<?> testClass) {
|
||||
CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate = createCacheAwareContextLoaderDelegate();
|
||||
String className = DEFAULT_BOOTSTRAP_CONTEXT_CLASS_NAME;
|
||||
Class<? extends BootstrapContext> clazz = null;
|
||||
Class<? extends BootstrapContext> clazz;
|
||||
try {
|
||||
clazz = (Class<? extends BootstrapContext>)
|
||||
ClassUtils.forName(className, BootstrapUtils.class.getClassLoader());
|
||||
|
@ -93,7 +93,7 @@ public abstract class BootstrapUtils {
|
|||
@SuppressWarnings("unchecked")
|
||||
private static CacheAwareContextLoaderDelegate createCacheAwareContextLoaderDelegate() {
|
||||
String className = DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_CLASS_NAME;
|
||||
Class<? extends CacheAwareContextLoaderDelegate> clazz = null;
|
||||
Class<? extends CacheAwareContextLoaderDelegate> clazz;
|
||||
try {
|
||||
clazz = (Class<? extends CacheAwareContextLoaderDelegate>)
|
||||
ClassUtils.forName(className, BootstrapUtils.class.getClassLoader());
|
||||
|
|
|
@ -75,7 +75,7 @@ public class ContextConfigurationAttributes {
|
|||
* either explicitly or implicitly
|
||||
* @since 4.3
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public ContextConfigurationAttributes(Class<?> declaringClass) {
|
||||
this(declaringClass, EMPTY_LOCATIONS, EMPTY_CLASSES, false, (Class[]) EMPTY_CLASSES, true, ContextLoader.class);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,6 @@ public class MergedContextConfiguration implements Serializable {
|
|||
|
||||
private final Class<?>[] classes;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private final Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses;
|
||||
|
||||
private final String[] activeProfiles;
|
||||
|
@ -99,14 +98,11 @@ public class MergedContextConfiguration implements Serializable {
|
|||
|
||||
private final String[] propertySourceProperties;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private final Set<ContextCustomizer> contextCustomizers;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private final ContextLoader contextLoader;
|
||||
|
||||
@Nullable
|
||||
@SuppressWarnings("serial")
|
||||
private final CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate;
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -47,7 +47,7 @@ public interface MethodInvoker {
|
|||
* Shared instance of the default {@link MethodInvoker}.
|
||||
* <p>This invoker never provides arguments to a {@link Method}.
|
||||
*/
|
||||
static final MethodInvoker DEFAULT_INVOKER = new DefaultMethodInvoker();
|
||||
MethodInvoker DEFAULT_INVOKER = new DefaultMethodInvoker();
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -98,7 +98,7 @@ public @interface NestedTestConfiguration {
|
|||
|
||||
/**
|
||||
* JVM system property used to change the default <em>enclosing configuration
|
||||
* inheritance mode</em>: {@value #ENCLOSING_CONFIGURATION_PROPERTY_NAME}.
|
||||
* inheritance mode</em>: {@value}.
|
||||
* <p>Supported values include enum constants defined in
|
||||
* {@link EnclosingConfiguration}, ignoring case. For example, the default
|
||||
* may be changed to {@link EnclosingConfiguration#OVERRIDE} by supplying
|
||||
|
|
|
@ -79,7 +79,7 @@ public @interface TestConstructor {
|
|||
|
||||
/**
|
||||
* JVM system property used to change the default <em>test constructor
|
||||
* autowire mode</em>: {@value #TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME}.
|
||||
* autowire mode</em>: {@value}.
|
||||
* <p>Acceptable values include enum constants defined in {@link AutowireMode},
|
||||
* ignoring case. For example, the default may be changed to {@link AutowireMode#ALL}
|
||||
* by supplying the following JVM system property via the command line.
|
||||
|
|
|
@ -248,7 +248,7 @@ public abstract class TestContextAnnotationUtils {
|
|||
return new AnnotationDescriptor<>(clazz, clazz.getAnnotation(annotationType));
|
||||
}
|
||||
|
||||
AnnotationDescriptor<T> descriptor = null;
|
||||
AnnotationDescriptor<T> descriptor;
|
||||
|
||||
// Declared on a composed annotation (i.e., as a meta-annotation)?
|
||||
for (Annotation composedAnn : clazz.getDeclaredAnnotations()) {
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.junit.jupiter.api.condition.DisabledIf;
|
|||
* <p>If a test class is annotated with {@code @DisabledInAotMode}, all other test
|
||||
* classes which specify configuration to load the same {@code ApplicationContext}
|
||||
* must also be annotated with {@code @DisabledInAotMode}. Failure to annotate
|
||||
* all such test classes will result in a exception, either at build time or
|
||||
* all such test classes will result in an exception, either at build time or
|
||||
* run time.
|
||||
*
|
||||
* <p>When used with JUnit Jupiter based tests, {@code @DisabledInAotMode} also
|
||||
|
|
|
@ -64,7 +64,6 @@ class MergedContextConfigurationRuntimeHints {
|
|||
private final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void registerHints(RuntimeHints runtimeHints, MergedContextConfiguration mergedConfig, ClassLoader classLoader) {
|
||||
// @ContextConfiguration(loader = ...)
|
||||
ContextLoader contextLoader = mergedConfig.getContextLoader();
|
||||
|
@ -92,7 +91,7 @@ class MergedContextConfigurationRuntimeHints {
|
|||
|
||||
// @WebAppConfiguration(value = ...)
|
||||
if (webMergedContextConfigurationClass.isInstance(mergedConfig)) {
|
||||
String resourceBasePath = null;
|
||||
String resourceBasePath;
|
||||
try {
|
||||
resourceBasePath = (String) getResourceBasePathMethod.invoke(mergedConfig);
|
||||
}
|
||||
|
@ -150,7 +149,6 @@ class MergedContextConfigurationRuntimeHints {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Class<?> loadWebMergedContextConfigurationClass() {
|
||||
try {
|
||||
return ClassUtils.forName(WEB_MERGED_CONTEXT_CONFIGURATION_CLASS_NAME,
|
||||
|
|
|
@ -63,7 +63,7 @@ class TestContextGenerationContext extends DefaultGenerationContext {
|
|||
* Create a new {@link TestContextGenerationContext} instance using the specified
|
||||
* feature name to qualify generated assets for a dedicated round of code generation.
|
||||
* <p>If <em>this</em> {@code TestContextGenerationContext} has a configured feature
|
||||
* name, the existing feature name will prepended to the supplied feature name in
|
||||
* name, the existing feature name will be prepended to the supplied feature name in
|
||||
* order to avoid naming collisions.
|
||||
* @param featureName the feature name to use
|
||||
* @return a specialized {@link TestContextGenerationContext} for the specified
|
||||
|
|
|
@ -137,7 +137,7 @@ public class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContext
|
|||
ApplicationContext context = this.contextCache.get(mergedConfig);
|
||||
try {
|
||||
if (context == null) {
|
||||
Integer failureCount = this.contextCache.getFailureCount(mergedConfig);
|
||||
int failureCount = this.contextCache.getFailureCount(mergedConfig);
|
||||
if (failureCount >= this.failureThreshold) {
|
||||
throw new IllegalStateException("""
|
||||
ApplicationContext failure threshold (%d) exceeded: \
|
||||
|
@ -287,7 +287,6 @@ public class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContext
|
|||
* have an AOT-optimized {@code ApplicationContext}
|
||||
* @since 6.0
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private MergedContextConfiguration replaceIfNecessary(MergedContextConfiguration mergedConfig) {
|
||||
if (AotDetector.useGeneratedArtifacts()) {
|
||||
Class<?> testClass = mergedConfig.getTestClass();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -79,10 +79,10 @@ abstract class AbstractExpressionEvaluatingCondition implements ExecutionConditi
|
|||
* @param loadContextExtractor a function that extracts the {@code loadContext}
|
||||
* flag from the annotation
|
||||
* @param enabledOnTrue indicates whether the returned {@code ConditionEvaluationResult}
|
||||
* should be {@link ConditionEvaluationResult#enabled enabled} if the expression
|
||||
* should be {@link ConditionEvaluationResult#enabled(String)} enabled} if the expression
|
||||
* evaluates to {@code true}
|
||||
* @param context the {@code ExtensionContext}
|
||||
* @return {@link ConditionEvaluationResult#enabled enabled} if the container
|
||||
* @return {@link ConditionEvaluationResult#enabled(String)} enabled} if the container
|
||||
* or test should be enabled; otherwise {@link ConditionEvaluationResult#disabled disabled}
|
||||
*/
|
||||
protected <A extends Annotation> ConditionEvaluationResult evaluateAnnotation(Class<A> annotationType,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -370,7 +370,7 @@ public class SpringJUnit4ClassRunner extends BlockJUnit4ClassRunner {
|
|||
// in BlockJUnit4ClassRunner has been deprecated.
|
||||
@SuppressWarnings("deprecation")
|
||||
protected Statement withPotentialTimeout(FrameworkMethod frameworkMethod, Object testInstance, Statement next) {
|
||||
Statement statement = null;
|
||||
Statement statement;
|
||||
long springTimeout = getSpringTimeout(frameworkMethod);
|
||||
long junitTimeout = getJUnitTimeout(frameworkMethod);
|
||||
if (springTimeout > 0 && junitTimeout > 0) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -64,7 +64,7 @@ abstract class ActiveProfilesUtils {
|
|||
* and enclosing classes.
|
||||
* @param testClass the class for which to resolve the active profiles (must not be
|
||||
* {@code null})
|
||||
* @return the set of active profiles for the specified class, including active
|
||||
* @return the active profiles for the specified class, including active
|
||||
* profiles from superclasses and enclosing classes if appropriate (never {@code null})
|
||||
* @see ActiveProfiles
|
||||
* @see ActiveProfilesResolver
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -50,7 +50,7 @@ public class DefaultActiveProfilesResolver implements ActiveProfilesResolver {
|
|||
* {@link ActiveProfiles#profiles} or {@link ActiveProfiles#value}.
|
||||
* @param testClass the test class for which the profiles should be resolved;
|
||||
* never {@code null}
|
||||
* @return the list of bean definition profiles to use when loading the
|
||||
* @return the bean definition profiles to use when loading the
|
||||
* {@code ApplicationContext}; never {@code null}
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -163,7 +163,7 @@ public abstract class TestConstructorUtils {
|
|||
return true;
|
||||
}
|
||||
|
||||
AutowireMode autowireMode = null;
|
||||
AutowireMode autowireMode;
|
||||
|
||||
// Is the test class annotated with @TestConstructor?
|
||||
TestConstructor testConstructor = TestContextAnnotationUtils.findMergedAnnotation(testClass, TestConstructor.class);
|
||||
|
|
|
@ -73,7 +73,6 @@ class TestPropertySourceAttributes {
|
|||
private final boolean inheritProperties;
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
TestPropertySourceAttributes(MergedAnnotation<TestPropertySource> mergedAnnotation) {
|
||||
this.declaringClass = declaringClass(mergedAnnotation);
|
||||
this.rootAnnotation = mergedAnnotation.getRoot();
|
||||
|
|
|
@ -79,7 +79,7 @@ public abstract class TestPropertySourceUtils {
|
|||
|
||||
private static final PropertySourceFactory defaultPropertySourceFactory = new DefaultPropertySourceFactory();
|
||||
|
||||
private static Comparator<MergedAnnotation<? extends Annotation>> reversedMetaDistance =
|
||||
private static final Comparator<MergedAnnotation<? extends Annotation>> reversedMetaDistance =
|
||||
Comparator.<MergedAnnotation<? extends Annotation>> comparingInt(MergedAnnotation::getDistance).reversed();
|
||||
|
||||
private static final Log logger = LogFactory.getLog(TestPropertySourceUtils.class);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -190,7 +190,7 @@ public abstract class AbstractGenericWebContextLoader extends AbstractContextLoa
|
|||
* @see org.springframework.test.context.SmartContextLoader#loadContext(MergedContextConfiguration)
|
||||
* @see org.springframework.test.context.aot.AotContextLoader#loadContextForAotProcessing(MergedContextConfiguration)
|
||||
*/
|
||||
private final GenericWebApplicationContext loadContext(
|
||||
private GenericWebApplicationContext loadContext(
|
||||
MergedContextConfiguration mergedConfig, boolean forAotProcessing) throws Exception {
|
||||
|
||||
if (!(mergedConfig instanceof WebMergedContextConfiguration webMergedConfig)) {
|
||||
|
|
Loading…
Reference in New Issue