Examples of DependenciesBean


Examples of org.springframework.beans.factory.xml.DependenciesBean

    assertTrue(lbf.containsBean("singletonObject"));
    assertTrue(lbf.isSingleton("singletonObject"));
    assertEquals(TestBean.class, lbf.getType("singletonObject"));
    assertEquals(0, lbf.getAliases("singletonObject").length);
    DependenciesBean test = (DependenciesBean) lbf.getBean("test");
    assertEquals(singletonObject, lbf.getBean("singletonObject"));
    assertEquals(singletonObject, test.getSpouse());
  }
View Full Code Here

Examples of org.springframework.beans.factory.xml.DependenciesBean

    lbf.registerBeanDefinition("rod", bd);
    assertEquals(1, lbf.getBeanDefinitionCount());
    // Depends on age, name and spouse (TestBean)
    Object registered = lbf.autowire(DependenciesBean.class, AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT, true);
    assertEquals(1, lbf.getBeanDefinitionCount());
    DependenciesBean kerry = (DependenciesBean) registered;
    TestBean rod = (TestBean) lbf.getBean("rod");
    assertSame(rod, kerry.getSpouse());
  }
View Full Code Here

Examples of org.springframework.beans.factory.xml.DependenciesBean

  public void testAutowireBeanByName() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, new MutablePropertyValues());
    lbf.registerBeanDefinition("spouse", bd);
    DependenciesBean bean = (DependenciesBean)
        lbf.autowire(DependenciesBean.class, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, true);
    TestBean spouse = (TestBean) lbf.getBean("spouse");
    assertEquals(spouse, bean.getSpouse());
    assertTrue(BeanFactoryUtils.beanOfType(lbf, TestBean.class) == spouse);
  }
View Full Code Here

Examples of org.springframework.beans.factory.xml.DependenciesBean

  public void testAutowireBeanByNameWithNoDependencyCheck() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, new MutablePropertyValues());
    lbf.registerBeanDefinition("spous", bd);
    DependenciesBean bean = (DependenciesBean)
        lbf.autowire(DependenciesBean.class, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);
    assertNull(bean.getSpouse());
  }
View Full Code Here

Examples of org.springframework.beans.factory.xml.DependenciesBean

  public void testAutowireBeanByType() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, new MutablePropertyValues());
    lbf.registerBeanDefinition("test", bd);
    DependenciesBean bean = (DependenciesBean)
        lbf.autowire(DependenciesBean.class, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true);
    TestBean test = (TestBean) lbf.getBean("test");
    assertEquals(test, bean.getSpouse());
  }
View Full Code Here

Examples of org.springframework.beans.factory.xml.DependenciesBean

    }
  }

  public void testAutowireBeanByTypeWithNoDependencyCheck() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    DependenciesBean bean = (DependenciesBean)
        lbf.autowire(DependenciesBean.class, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
    assertNull(bean.getSpouse());
  }
View Full Code Here

Examples of org.springframework.beans.factory.xml.DependenciesBean

  public void testAutowireExistingBeanByName() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, new MutablePropertyValues());
    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.xml.DependenciesBean

  public void testAutowireExistingBeanByNameWithDependencyCheck() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, new MutablePropertyValues());
    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) {
View Full Code Here

Examples of org.springframework.beans.factory.xml.DependenciesBean

  public void testAutowireExistingBeanByNameWithNoDependencyCheck() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, new MutablePropertyValues());
    lbf.registerBeanDefinition("spous", bd);
    DependenciesBean existingBean = new DependenciesBean();
    lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);
    assertNull(existingBean.getSpouse());
  }
View Full Code Here

Examples of org.springframework.beans.factory.xml.DependenciesBean

  public void testAutowireExistingBeanByType() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, new MutablePropertyValues());
    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);
  }
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.