@ -32,6 +32,7 @@ import org.jspecify.annotations.Nullable;
import org.springframework.beans.BeanInstantiationException ;
import org.springframework.beans.BeanInstantiationException ;
import org.springframework.beans.BeanUtils ;
import org.springframework.beans.BeanUtils ;
import org.springframework.context.ApplicationContextInitializer ;
import org.springframework.core.annotation.AnnotationAwareOrderComparator ;
import org.springframework.core.annotation.AnnotationAwareOrderComparator ;
import org.springframework.test.context.BootstrapContext ;
import org.springframework.test.context.BootstrapContext ;
import org.springframework.test.context.CacheAwareContextLoaderDelegate ;
import org.springframework.test.context.CacheAwareContextLoaderDelegate ;
@ -359,8 +360,6 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot
ContextLoader contextLoader = resolveContextLoader ( testClass , configAttributesList ) ;
ContextLoader contextLoader = resolveContextLoader ( testClass , configAttributesList ) ;
List < String > locations = new ArrayList < > ( ) ;
List < String > locations = new ArrayList < > ( ) ;
List < Class < ? > > classes = new ArrayList < > ( ) ;
List < Class < ? > > classes = new ArrayList < > ( ) ;
List < Class < ? > > initializers = new ArrayList < > ( ) ;
for ( ContextConfigurationAttributes configAttributes : configAttributesList ) {
for ( ContextConfigurationAttributes configAttributes : configAttributesList ) {
if ( logger . isTraceEnabled ( ) ) {
if ( logger . isTraceEnabled ( ) ) {
logger . trace ( String . format ( "Processing locations and classes for context configuration attributes %s" ,
logger . trace ( String . format ( "Processing locations and classes for context configuration attributes %s" ,
@ -384,14 +383,13 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot
}
}
// Legacy ContextLoaders don't know how to process classes
// Legacy ContextLoaders don't know how to process classes
}
}
if ( configAttributes . getInitializers ( ) . length > 0 ) {
initializers . addAll ( 0 , Arrays . asList ( configAttributes . getInitializers ( ) ) ) ;
}
if ( ! configAttributes . isInheritLocations ( ) ) {
if ( ! configAttributes . isInheritLocations ( ) ) {
break ;
break ;
}
}
}
}
Set < Class < ? extends ApplicationContextInitializer < ? > > > initializers =
ApplicationContextInitializerUtils . resolveInitializerClasses ( configAttributesList ) ;
Set < ContextCustomizer > contextCustomizers = getContextCustomizers ( testClass ,
Set < ContextCustomizer > contextCustomizers = getContextCustomizers ( testClass ,
Collections . unmodifiableList ( configAttributesList ) ) ;
Collections . unmodifiableList ( configAttributesList ) ) ;
@ -405,8 +403,7 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot
TestPropertySourceUtils . buildMergedTestPropertySources ( testClass ) ;
TestPropertySourceUtils . buildMergedTestPropertySources ( testClass ) ;
MergedContextConfiguration mergedConfig = new MergedContextConfiguration ( testClass ,
MergedContextConfiguration mergedConfig = new MergedContextConfiguration ( testClass ,
StringUtils . toStringArray ( locations ) , ClassUtils . toClassArray ( classes ) ,
StringUtils . toStringArray ( locations ) , ClassUtils . toClassArray ( classes ) ,
ApplicationContextInitializerUtils . resolveInitializerClasses ( configAttributesList ) ,
initializers , ActiveProfilesUtils . resolveActiveProfiles ( testClass ) ,
ActiveProfilesUtils . resolveActiveProfiles ( testClass ) ,
mergedTestPropertySources . getPropertySourceDescriptors ( ) ,
mergedTestPropertySources . getPropertySourceDescriptors ( ) ,
mergedTestPropertySources . getProperties ( ) ,
mergedTestPropertySources . getProperties ( ) ,
contextCustomizers , contextLoader , cacheAwareContextLoaderDelegate , parentConfig ) ;
contextCustomizers , contextLoader , cacheAwareContextLoaderDelegate , parentConfig ) ;