@@ -86,7 +86,7 @@ void beanDefinitionWithFactoryMethodNameAndAssignableConstructorArg() {
86
86
}
87
87
88
88
@ Test
89
- void beanDefinitionWithFactoryMethodNameAndMatchingMethodNamesThatShouldBeIgnored () {
89
+ void beanDefinitionWithFactoryMethodNameAndMatchingMethodNames () {
90
90
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory ();
91
91
BeanDefinition beanDefinition = BeanDefinitionBuilder
92
92
.rootBeanDefinition (DummySampleFactory .class ).setFactoryMethod ("of" )
@@ -96,6 +96,18 @@ void beanDefinitionWithFactoryMethodNameAndMatchingMethodNamesThatShouldBeIgnore
96
96
.findMethod (DummySampleFactory .class , "of" , Integer .class ));
97
97
}
98
98
99
+ @ Test
100
+ void beanDefinitionWithFactoryMethodNameAndOverriddenMethod () {
101
+ DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory ();
102
+ beanFactory .registerBeanDefinition ("config" , new RootBeanDefinition (ExtendedSampleFactory .class ));
103
+ BeanDefinition beanDefinition = BeanDefinitionBuilder
104
+ .rootBeanDefinition (String .class ).setFactoryMethodOnBean ("resolve" , "config" )
105
+ .addConstructorArgValue ("test" ).getBeanDefinition ();
106
+ Executable executable = resolve (beanFactory , beanDefinition );
107
+ assertThat (executable ).isNotNull ().isEqualTo (ReflectionUtils
108
+ .findMethod (ExtendedSampleFactory .class , "resolve" , String .class ));
109
+ }
110
+
99
111
@ Test
100
112
void detectBeanInstanceExecutableWithBeanClassAndFactoryMethodNameIgnoreTargetType () {
101
113
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory ();
@@ -386,8 +398,17 @@ static String of(Integer value) {
386
398
return value .toString ();
387
399
}
388
400
389
- private String of (String ignored ) {
390
- return ignored ;
401
+ protected String resolve (String value ) {
402
+ return value ;
403
+ }
404
+ }
405
+
406
+ @ SuppressWarnings ("unused" )
407
+ static class ExtendedSampleFactory extends DummySampleFactory {
408
+
409
+ @ Override
410
+ protected String resolve (String value ) {
411
+ return super .resolve (value );
391
412
}
392
413
}
393
414
0 commit comments