Examples of autowireBeanProperties()


Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory.autowireBeanProperties()

  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));
  }
View Full Code Here

Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory.autowireBeanProperties()

    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
    }
View Full Code Here

Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory.autowireBeanProperties()

  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());
  }

  @Test
  public void testAutowireExistingBeanByType() {
View Full Code Here

Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory.autowireBeanProperties()

  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);
  }

  @Test
View Full Code Here

Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory.autowireBeanProperties()

  @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) {
    }
  }
View Full Code Here

Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory.autowireBeanProperties()

  @Test
  public void testAutowireExistingBeanByTypeWithNoDependencyCheck() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    DependenciesBean existingBean = new DependenciesBean();
    lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
    assertNull(existingBean.getSpouse());
  }

  @Test
  public void testInvalidAutowireMode() {
View Full Code Here

Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory.autowireBeanProperties()

  @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) {
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.