Skip to content

Commit 115a46c

Browse files
committed
Polish
1 parent 199d5e5 commit 115a46c

20 files changed

+28
-36
lines changed

spring-test/src/main/java/org/springframework/test/context/ActiveProfilesResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@ public interface ActiveProfilesResolver {
4040
* {@code ApplicationContext} for the given {@linkplain Class test class}.
4141
* @param testClass the test class for which the profiles should be resolved;
4242
* never {@code null}
43-
* @return the list of bean definition profiles to use when loading the
43+
* @return the bean definition profiles to use when loading the
4444
* {@code ApplicationContext}; never {@code null}
4545
* @see ActiveProfiles#resolver
4646
* @see ActiveProfiles#inheritProfiles

spring-test/src/main/java/org/springframework/test/context/BootstrapUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -76,7 +76,7 @@ public abstract class BootstrapUtils {
7676
static BootstrapContext createBootstrapContext(Class<?> testClass) {
7777
CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate = createCacheAwareContextLoaderDelegate();
7878
String className = DEFAULT_BOOTSTRAP_CONTEXT_CLASS_NAME;
79-
Class<? extends BootstrapContext> clazz = null;
79+
Class<? extends BootstrapContext> clazz;
8080
try {
8181
clazz = (Class<? extends BootstrapContext>)
8282
ClassUtils.forName(className, BootstrapUtils.class.getClassLoader());
@@ -93,7 +93,7 @@ static BootstrapContext createBootstrapContext(Class<?> testClass) {
9393
@SuppressWarnings("unchecked")
9494
private static CacheAwareContextLoaderDelegate createCacheAwareContextLoaderDelegate() {
9595
String className = DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_CLASS_NAME;
96-
Class<? extends CacheAwareContextLoaderDelegate> clazz = null;
96+
Class<? extends CacheAwareContextLoaderDelegate> clazz;
9797
try {
9898
clazz = (Class<? extends CacheAwareContextLoaderDelegate>)
9999
ClassUtils.forName(className, BootstrapUtils.class.getClassLoader());

spring-test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public class ContextConfigurationAttributes {
7575
* either explicitly or implicitly
7676
* @since 4.3
7777
*/
78-
@SuppressWarnings("unchecked")
78+
@SuppressWarnings({ "unchecked", "rawtypes" })
7979
public ContextConfigurationAttributes(Class<?> declaringClass) {
8080
this(declaringClass, EMPTY_LOCATIONS, EMPTY_CLASSES, false, (Class[]) EMPTY_CLASSES, true, ContextLoader.class);
8181
}

spring-test/src/main/java/org/springframework/test/context/MergedContextConfiguration.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ public class MergedContextConfiguration implements Serializable {
8888

8989
private final Class<?>[] classes;
9090

91-
@SuppressWarnings("serial")
9291
private final Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses;
9392

9493
private final String[] activeProfiles;
@@ -99,14 +98,11 @@ public class MergedContextConfiguration implements Serializable {
9998

10099
private final String[] propertySourceProperties;
101100

102-
@SuppressWarnings("serial")
103101
private final Set<ContextCustomizer> contextCustomizers;
104102

105-
@SuppressWarnings("serial")
106103
private final ContextLoader contextLoader;
107104

108105
@Nullable
109-
@SuppressWarnings("serial")
110106
private final CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate;
111107

112108
@Nullable

spring-test/src/main/java/org/springframework/test/context/MethodInvoker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public interface MethodInvoker {
4747
* Shared instance of the default {@link MethodInvoker}.
4848
* <p>This invoker never provides arguments to a {@link Method}.
4949
*/
50-
static final MethodInvoker DEFAULT_INVOKER = new DefaultMethodInvoker();
50+
MethodInvoker DEFAULT_INVOKER = new DefaultMethodInvoker();
5151

5252

5353
/**

spring-test/src/main/java/org/springframework/test/context/NestedTestConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -98,7 +98,7 @@
9898

9999
/**
100100
* JVM system property used to change the default <em>enclosing configuration
101-
* inheritance mode</em>: {@value #ENCLOSING_CONFIGURATION_PROPERTY_NAME}.
101+
* inheritance mode</em>: {@value}.
102102
* <p>Supported values include enum constants defined in
103103
* {@link EnclosingConfiguration}, ignoring case. For example, the default
104104
* may be changed to {@link EnclosingConfiguration#OVERRIDE} by supplying

spring-test/src/main/java/org/springframework/test/context/TestConstructor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979

8080
/**
8181
* JVM system property used to change the default <em>test constructor
82-
* autowire mode</em>: {@value #TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME}.
82+
* autowire mode</em>: {@value}.
8383
* <p>Acceptable values include enum constants defined in {@link AutowireMode},
8484
* ignoring case. For example, the default may be changed to {@link AutowireMode#ALL}
8585
* by supplying the following JVM system property via the command line.

spring-test/src/main/java/org/springframework/test/context/TestContextAnnotationUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ private static <T extends Annotation> AnnotationDescriptor<T> findAnnotationDesc
248248
return new AnnotationDescriptor<>(clazz, clazz.getAnnotation(annotationType));
249249
}
250250

251-
AnnotationDescriptor<T> descriptor = null;
251+
AnnotationDescriptor<T> descriptor;
252252

253253
// Declared on a composed annotation (i.e., as a meta-annotation)?
254254
for (Annotation composedAnn : clazz.getDeclaredAnnotations()) {

spring-test/src/main/java/org/springframework/test/context/aot/DisabledInAotMode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* <p>If a test class is annotated with {@code @DisabledInAotMode}, all other test
3333
* classes which specify configuration to load the same {@code ApplicationContext}
3434
* must also be annotated with {@code @DisabledInAotMode}. Failure to annotate
35-
* all such test classes will result in a exception, either at build time or
35+
* all such test classes will result in an exception, either at build time or
3636
* run time.
3737
*
3838
* <p>When used with JUnit Jupiter based tests, {@code @DisabledInAotMode} also

spring-test/src/main/java/org/springframework/test/context/aot/MergedContextConfigurationRuntimeHints.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ class MergedContextConfigurationRuntimeHints {
6464
private final Log logger = LogFactory.getLog(getClass());
6565

6666

67-
@SuppressWarnings("deprecation")
6867
public void registerHints(RuntimeHints runtimeHints, MergedContextConfiguration mergedConfig, ClassLoader classLoader) {
6968
// @ContextConfiguration(loader = ...)
7069
ContextLoader contextLoader = mergedConfig.getContextLoader();
@@ -92,7 +91,7 @@ public void registerHints(RuntimeHints runtimeHints, MergedContextConfiguration
9291

9392
// @WebAppConfiguration(value = ...)
9493
if (webMergedContextConfigurationClass.isInstance(mergedConfig)) {
95-
String resourceBasePath = null;
94+
String resourceBasePath;
9695
try {
9796
resourceBasePath = (String) getResourceBasePathMethod.invoke(mergedConfig);
9897
}
@@ -150,7 +149,6 @@ private void registerClasspathResourceDirectoryStructure(String directory, Runti
150149
}
151150
}
152151

153-
@SuppressWarnings("unchecked")
154152
private static Class<?> loadWebMergedContextConfigurationClass() {
155153
try {
156154
return ClassUtils.forName(WEB_MERGED_CONTEXT_CONFIGURATION_CLASS_NAME,

spring-test/src/main/java/org/springframework/test/context/aot/TestContextGenerationContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private TestContextGenerationContext(TestContextGenerationContext existing, Stri
6363
* Create a new {@link TestContextGenerationContext} instance using the specified
6464
* feature name to qualify generated assets for a dedicated round of code generation.
6565
* <p>If <em>this</em> {@code TestContextGenerationContext} has a configured feature
66-
* name, the existing feature name will prepended to the supplied feature name in
66+
* name, the existing feature name will be prepended to the supplied feature name in
6767
* order to avoid naming collisions.
6868
* @param featureName the feature name to use
6969
* @return a specialized {@link TestContextGenerationContext} for the specified

spring-test/src/main/java/org/springframework/test/context/cache/DefaultCacheAwareContextLoaderDelegate.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) {
137137
ApplicationContext context = this.contextCache.get(mergedConfig);
138138
try {
139139
if (context == null) {
140-
Integer failureCount = this.contextCache.getFailureCount(mergedConfig);
140+
int failureCount = this.contextCache.getFailureCount(mergedConfig);
141141
if (failureCount >= this.failureThreshold) {
142142
throw new IllegalStateException("""
143143
ApplicationContext failure threshold (%d) exceeded: \
@@ -287,7 +287,6 @@ private ContextLoader getContextLoader(MergedContextConfiguration mergedConfig)
287287
* have an AOT-optimized {@code ApplicationContext}
288288
* @since 6.0
289289
*/
290-
@SuppressWarnings("unchecked")
291290
private MergedContextConfiguration replaceIfNecessary(MergedContextConfiguration mergedConfig) {
292291
if (AotDetector.useGeneratedArtifacts()) {
293292
Class<?> testClass = mergedConfig.getTestClass();

spring-test/src/main/java/org/springframework/test/context/junit/jupiter/AbstractExpressionEvaluatingCondition.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -79,10 +79,10 @@ abstract class AbstractExpressionEvaluatingCondition implements ExecutionConditi
7979
* @param loadContextExtractor a function that extracts the {@code loadContext}
8080
* flag from the annotation
8181
* @param enabledOnTrue indicates whether the returned {@code ConditionEvaluationResult}
82-
* should be {@link ConditionEvaluationResult#enabled enabled} if the expression
82+
* should be {@link ConditionEvaluationResult#enabled(String)} enabled} if the expression
8383
* evaluates to {@code true}
8484
* @param context the {@code ExtensionContext}
85-
* @return {@link ConditionEvaluationResult#enabled enabled} if the container
85+
* @return {@link ConditionEvaluationResult#enabled(String)} enabled} if the container
8686
* or test should be enabled; otherwise {@link ConditionEvaluationResult#disabled disabled}
8787
*/
8888
protected <A extends Annotation> ConditionEvaluationResult evaluateAnnotation(Class<A> annotationType,

spring-test/src/main/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -370,7 +370,7 @@ protected Class<? extends Throwable> getExpectedException(FrameworkMethod framew
370370
// in BlockJUnit4ClassRunner has been deprecated.
371371
@SuppressWarnings("deprecation")
372372
protected Statement withPotentialTimeout(FrameworkMethod frameworkMethod, Object testInstance, Statement next) {
373-
Statement statement = null;
373+
Statement statement;
374374
long springTimeout = getSpringTimeout(frameworkMethod);
375375
long junitTimeout = getJUnitTimeout(frameworkMethod);
376376
if (springTimeout > 0 && junitTimeout > 0) {

spring-test/src/main/java/org/springframework/test/context/support/ActiveProfilesUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -64,7 +64,7 @@ abstract class ActiveProfilesUtils {
6464
* and enclosing classes.
6565
* @param testClass the class for which to resolve the active profiles (must not be
6666
* {@code null})
67-
* @return the set of active profiles for the specified class, including active
67+
* @return the active profiles for the specified class, including active
6868
* profiles from superclasses and enclosing classes if appropriate (never {@code null})
6969
* @see ActiveProfiles
7070
* @see ActiveProfilesResolver

spring-test/src/main/java/org/springframework/test/context/support/DefaultActiveProfilesResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@ public class DefaultActiveProfilesResolver implements ActiveProfilesResolver {
5050
* {@link ActiveProfiles#profiles} or {@link ActiveProfiles#value}.
5151
* @param testClass the test class for which the profiles should be resolved;
5252
* never {@code null}
53-
* @return the list of bean definition profiles to use when loading the
53+
* @return the bean definition profiles to use when loading the
5454
* {@code ApplicationContext}; never {@code null}
5555
*/
5656
@Override

spring-test/src/main/java/org/springframework/test/context/support/TestConstructorUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public static boolean isAutowirableConstructor(Constructor<?> constructor, Class
163163
return true;
164164
}
165165

166-
AutowireMode autowireMode = null;
166+
AutowireMode autowireMode;
167167

168168
// Is the test class annotated with @TestConstructor?
169169
TestConstructor testConstructor = TestContextAnnotationUtils.findMergedAnnotation(testClass, TestConstructor.class);

spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceAttributes.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class TestPropertySourceAttributes {
7373
private final boolean inheritProperties;
7474

7575

76-
@SuppressWarnings("unchecked")
7776
TestPropertySourceAttributes(MergedAnnotation<TestPropertySource> mergedAnnotation) {
7877
this.declaringClass = declaringClass(mergedAnnotation);
7978
this.rootAnnotation = mergedAnnotation.getRoot();

spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public abstract class TestPropertySourceUtils {
7979

8080
private static final PropertySourceFactory defaultPropertySourceFactory = new DefaultPropertySourceFactory();
8181

82-
private static Comparator<MergedAnnotation<? extends Annotation>> reversedMetaDistance =
82+
private static final Comparator<MergedAnnotation<? extends Annotation>> reversedMetaDistance =
8383
Comparator.<MergedAnnotation<? extends Annotation>> comparingInt(MergedAnnotation::getDistance).reversed();
8484

8585
private static final Log logger = LogFactory.getLog(TestPropertySourceUtils.class);

spring-test/src/main/java/org/springframework/test/context/web/AbstractGenericWebContextLoader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -190,7 +190,7 @@ else if (logger.isDebugEnabled()) {
190190
* @see org.springframework.test.context.SmartContextLoader#loadContext(MergedContextConfiguration)
191191
* @see org.springframework.test.context.aot.AotContextLoader#loadContextForAotProcessing(MergedContextConfiguration)
192192
*/
193-
private final GenericWebApplicationContext loadContext(
193+
private GenericWebApplicationContext loadContext(
194194
MergedContextConfiguration mergedConfig, boolean forAotProcessing) throws Exception {
195195

196196
if (!(mergedConfig instanceof WebMergedContextConfiguration webMergedConfig)) {

0 commit comments

Comments
 (0)