@ -1,5 +1,5 @@
/ *
/ *
* Copyright 2012 - 202 1 the original author or authors .
* Copyright 2012 - 202 2 the original author or authors .
*
*
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* you may not use this file except in compliance with the License .
@ -39,6 +39,7 @@ import org.springframework.context.annotation.ConditionContext;
import org.springframework.context.annotation.Conditional ;
import org.springframework.context.annotation.Conditional ;
import org.springframework.context.annotation.Configuration ;
import org.springframework.context.annotation.Configuration ;
import org.springframework.context.annotation.Lazy ;
import org.springframework.context.annotation.Lazy ;
import org.springframework.context.annotation.Profile ;
import org.springframework.core.env.Environment ;
import org.springframework.core.env.Environment ;
import org.springframework.core.type.AnnotatedTypeMetadata ;
import org.springframework.core.type.AnnotatedTypeMetadata ;
import org.springframework.util.ClassUtils ;
import org.springframework.util.ClassUtils ;
@ -230,6 +231,13 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
} ) ;
} ) ;
}
}
@Test
void changesMadeByInitializersShouldBeVisibleToRegisteredClasses ( ) {
get ( ) . withInitializer ( ( context ) - > context . getEnvironment ( ) . setActiveProfiles ( "test" ) )
. withUserConfiguration ( ProfileConfig . class )
. run ( ( context ) - > assertThat ( context ) . hasSingleBean ( ProfileConfig . class ) ) ;
}
protected abstract T get ( ) ;
protected abstract T get ( ) ;
private static void throwCheckedException ( String message ) throws IOException {
private static void throwCheckedException ( String message ) throws IOException {
@ -342,4 +350,10 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
}
}
@Profile ( "test" )
@Configuration ( proxyBeanMethods = false )
static class ProfileConfig {
}
}
}