Same method filtering in ConstructorResolver and getTypeForFactoryMethod

Issue: SPR-16999

(cherry picked from commit 0052c89)
This commit is contained in:
Juergen Hoeller
2018-07-03 15:53:17 +02:00
parent 740751bc01
commit 9f69638420
2 changed files with 46 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -22,6 +22,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import org.junit.Before;
@@ -783,6 +784,15 @@ public class ConfigurationClassPostProcessorTests {
assertSame(ctx.getBean(TestBean.class), bean.testBeans.get(0));
}
@Test
public void testMapInjectionFromSameConfigurationClass() {
ApplicationContext ctx = new AnnotationConfigApplicationContext(MapInjectionConfiguration.class);
MapInjectionConfiguration bean = ctx.getBean(MapInjectionConfiguration.class);
assertNotNull(bean.testBeans);
assertEquals(1, bean.testBeans.size());
assertSame(ctx.getBean(Runnable.class), bean.testBeans.get("testBean"));
}
@Test
public void testBeanLookupFromSameConfigurationClass() {
ApplicationContext ctx = new AnnotationConfigApplicationContext(BeanLookupConfiguration.class);
@@ -1468,6 +1478,23 @@ public class ConfigurationClassPostProcessorTests {
}
}
@Configuration
public static class MapInjectionConfiguration {
@Autowired
private Map<String, Runnable> testBeans;
@Bean
Runnable testBean() {
return () -> {};
}
// Unrelated, not to be considered as a factory method
private boolean testBean(boolean param) {
return param;
}
}
@Configuration
static abstract class BeanLookupConfiguration {