ConstructorResolver always uses arguments when completely provided

Issue: SPR-13808
This commit is contained in:
Juergen Hoeller
2015-12-21 15:11:40 +01:00
parent 09cea6e6bb
commit cad2ce0ac2
2 changed files with 22 additions and 2 deletions

View File

@@ -24,6 +24,7 @@ import java.lang.annotation.Target;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
@@ -1827,6 +1828,18 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertNotNull(bf.getBean(FooBar.class));
}
@Test
public void testSingleConstructorWithProvidedArgument() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
bpp.setBeanFactory(bf);
bf.addBeanPostProcessor(bpp);
RootBeanDefinition bd = new RootBeanDefinition(ProvidedArgumentBean.class);
bd.getConstructorArgumentValues().addGenericArgumentValue(Collections.singletonList("value"));
bf.registerBeanDefinition("beanWithArgs", bd);
assertNotNull(bf.getBean(ProvidedArgumentBean.class));
}
public static class ResourceInjectionBean {
@@ -2920,4 +2933,11 @@ public class AutowiredAnnotationBeanPostProcessorTests {
}
}
public static class ProvidedArgumentBean {
public ProvidedArgumentBean(String[] args) {
}
}
}