Polish "Allow MethodReference to support a more flexible signature"

See gh-29005
This commit is contained in:
Stephane Nicoll
2022-09-12 16:24:50 +02:00
parent bbe5e91ebc
commit 0dba729823
4 changed files with 44 additions and 2 deletions

View File

@@ -61,7 +61,10 @@ import org.springframework.context.testfixture.context.generator.annotation.Lazy
import org.springframework.context.testfixture.context.generator.annotation.LazyAutowiredMethodComponent;
import org.springframework.context.testfixture.context.generator.annotation.LazyConstructorArgumentComponent;
import org.springframework.context.testfixture.context.generator.annotation.LazyFactoryMethodArgumentComponent;
import org.springframework.context.testfixture.context.generator.annotation.PropertySourceConfiguration;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.ResourceLoader;
import static org.assertj.core.api.Assertions.assertThat;
@@ -279,6 +282,19 @@ class ApplicationContextAotGeneratorTests {
.withMemberCategory(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(context.getRuntimeHints());
}
@Test
void processAheadOfTimeWithPropertySource() {
GenericApplicationContext applicationContext = new AnnotationConfigApplicationContext();
applicationContext.registerBean(PropertySourceConfiguration.class);
testCompiledResult(applicationContext, (initializer, compiled) -> {
GenericApplicationContext freshApplicationContext = toFreshApplicationContext(initializer);
ConfigurableEnvironment environment = freshApplicationContext.getEnvironment();
PropertySource<?> propertySource = environment.getPropertySources().get("testp1");
assertThat(propertySource).isNotNull();
assertThat(propertySource.getProperty("from.p1")).isEqualTo("p1Value");
});
}
private Consumer<List<? extends JdkProxyHint>> doesNotHaveProxyFor(Class<?> target) {
return hints -> assertThat(hints).noneMatch(hint -> hint.getProxiedInterfaces().get(0).equals(target));
}

View File

@@ -65,7 +65,7 @@ class ApplicationContextInitializationCodeGeneratorTests {
static Stream<Arguments> methodArguments() {
String applicationContext = "applicationContext";
String environment = applicationContext + ".getConfigurableEnvironment()";
String environment = applicationContext + ".getEnvironment()";
return Stream.of(
Arguments.of(DefaultListableBeanFactory.class, "beanFactory"),
Arguments.of(ConfigurableListableBeanFactory.class, "beanFactory"),