Java Code Examples for org.springframework.beans.factory.support.DefaultListableBeanFactory#autowireBeanProperties()
The following examples show how to use
org.springframework.beans.factory.support.DefaultListableBeanFactory#autowireBeanProperties() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultListableBeanFactoryTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testAutowireExistingBeanByType() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("test", bd); DependenciesBean existingBean = new DependenciesBean(); lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true); TestBean test = (TestBean) lbf.getBean("test"); assertEquals(existingBean.getSpouse(), test); }
Example 2
Source File: DefaultListableBeanFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testAutowireExistingBeanByTypeWithNoDependencyCheck() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); DependenciesBean existingBean = new DependenciesBean(); lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false); assertNull(existingBean.getSpouse()); }
Example 3
Source File: DefaultListableBeanFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testInvalidAutowireMode() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); try { lbf.autowireBeanProperties(new TestBean(), AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
Example 4
Source File: DefaultListableBeanFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testAutowireExistingBeanByType() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("test", bd); DependenciesBean existingBean = new DependenciesBean(); lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true); TestBean test = (TestBean) lbf.getBean("test"); assertEquals(existingBean.getSpouse(), test); }
Example 5
Source File: DefaultListableBeanFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testAutowireExistingBeanByNameWithNoDependencyCheck() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("spous", bd); DependenciesBean existingBean = new DependenciesBean(); lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false); assertNull(existingBean.getSpouse()); }
Example 6
Source File: DefaultListableBeanFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testAutowireExistingBeanByNameWithDependencyCheck() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("spous", bd); DependenciesBean existingBean = new DependenciesBean(); try { lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, true); fail("Should have thrown UnsatisfiedDependencyException"); } catch (UnsatisfiedDependencyException ex) { // expected } }
Example 7
Source File: DefaultListableBeanFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testAutowireExistingBeanByName() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("spouse", bd); DependenciesBean existingBean = new DependenciesBean(); lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, true); TestBean spouse = (TestBean) lbf.getBean("spouse"); assertEquals(existingBean.getSpouse(), spouse); assertSame(spouse, BeanFactoryUtils.beanOfType(lbf, TestBean.class)); }
Example 8
Source File: DefaultListableBeanFactoryTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testInvalidAutowireMode() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); try { lbf.autowireBeanProperties(new TestBean(), AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
Example 9
Source File: DefaultListableBeanFactoryTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testAutowireExistingBeanByTypeWithNoDependencyCheck() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); DependenciesBean existingBean = new DependenciesBean(); lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false); assertNull(existingBean.getSpouse()); }
Example 10
Source File: DefaultListableBeanFactoryTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testAutowireExistingBeanByTypeWithDependencyCheck() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); DependenciesBean existingBean = new DependenciesBean(); try { lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true); fail("Should have thrown UnsatisfiedDependencyException"); } catch (UnsatisfiedDependencyException expected) { } }
Example 11
Source File: DefaultListableBeanFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testAutowireExistingBeanByName() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("spouse", bd); DependenciesBean existingBean = new DependenciesBean(); lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, true); TestBean spouse = (TestBean) lbf.getBean("spouse"); assertEquals(existingBean.getSpouse(), spouse); assertSame(spouse, BeanFactoryUtils.beanOfType(lbf, TestBean.class)); }
Example 12
Source File: DefaultListableBeanFactoryTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testAutowireExistingBeanByNameWithNoDependencyCheck() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("spous", bd); DependenciesBean existingBean = new DependenciesBean(); lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false); assertNull(existingBean.getSpouse()); }
Example 13
Source File: DefaultListableBeanFactoryTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testAutowireExistingBeanByNameWithDependencyCheck() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("spous", bd); DependenciesBean existingBean = new DependenciesBean(); try { lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, true); fail("Should have thrown UnsatisfiedDependencyException"); } catch (UnsatisfiedDependencyException ex) { // expected } }
Example 14
Source File: DefaultListableBeanFactoryTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testAutowireExistingBeanByName() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("spouse", bd); DependenciesBean existingBean = new DependenciesBean(); lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, true); TestBean spouse = (TestBean) lbf.getBean("spouse"); assertEquals(existingBean.getSpouse(), spouse); assertSame(spouse, BeanFactoryUtils.beanOfType(lbf, TestBean.class)); }
Example 15
Source File: DefaultListableBeanFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testInvalidAutowireMode() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); try { lbf.autowireBeanProperties(new TestBean(), AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
Example 16
Source File: DefaultListableBeanFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testAutowireExistingBeanByTypeWithNoDependencyCheck() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); DependenciesBean existingBean = new DependenciesBean(); lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false); assertNull(existingBean.getSpouse()); }
Example 17
Source File: DefaultListableBeanFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testAutowireExistingBeanByTypeWithDependencyCheck() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); DependenciesBean existingBean = new DependenciesBean(); try { lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true); fail("Should have thrown UnsatisfiedDependencyException"); } catch (UnsatisfiedDependencyException expected) { } }
Example 18
Source File: DefaultListableBeanFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testAutowireExistingBeanByType() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("test", bd); DependenciesBean existingBean = new DependenciesBean(); lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true); TestBean test = (TestBean) lbf.getBean("test"); assertEquals(existingBean.getSpouse(), test); }
Example 19
Source File: DefaultListableBeanFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testAutowireExistingBeanByNameWithNoDependencyCheck() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("spous", bd); DependenciesBean existingBean = new DependenciesBean(); lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false); assertNull(existingBean.getSpouse()); }
Example 20
Source File: DefaultListableBeanFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testAutowireExistingBeanByNameWithDependencyCheck() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("spous", bd); DependenciesBean existingBean = new DependenciesBean(); try { lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, true); fail("Should have thrown UnsatisfiedDependencyException"); } catch (UnsatisfiedDependencyException ex) { // expected } }