Package org.springframework.beans.factory.support

Examples of org.springframework.beans.factory.support.BeanDefinitionReader.loadBeanDefinitions()


  @Test
  public void testNonQualifiedFieldFails() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", NonQualifiedTestBean.class);
    try {
      context.refresh();
      fail("Should have thrown a BeanCreationException");
    }
View Full Code Here


  @Test
  public void testQualifiedByValue() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByValueTestBean.class);
    context.refresh();
    QualifiedByValueTestBean testBean = (QualifiedByValueTestBean) context.getBean("testBean");
    Person person = testBean.getLarry();
    assertEquals("Larry", person.getName());
View Full Code Here

    parent.registerBeanDefinition("someOtherLarry", otherLarry);
    parent.refresh();

    StaticApplicationContext context = new StaticApplicationContext(parent);
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByParentValueTestBean.class);
    context.refresh();
    QualifiedByParentValueTestBean testBean = (QualifiedByParentValueTestBean) context.getBean("testBean");
    Person person = testBean.getLarry();
    assertEquals("ParentLarry", person.getName());
View Full Code Here

  @Test
  public void testQualifiedByBeanName() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByBeanNameTestBean.class);
    context.refresh();
    QualifiedByBeanNameTestBean testBean = (QualifiedByBeanNameTestBean) context.getBean("testBean");
    Person person = testBean.getLarry();
    assertEquals("LarryBean", person.getName());
View Full Code Here

  @Test
  public void testQualifiedByFieldName() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByFieldNameTestBean.class);
    context.refresh();
    QualifiedByFieldNameTestBean testBean = (QualifiedByFieldNameTestBean) context.getBean("testBean");
    Person person = testBean.getLarry();
    assertEquals("LarryBean", person.getName());
View Full Code Here

  @Test
  public void testQualifiedByParameterName() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByParameterNameTestBean.class);
    context.refresh();
    QualifiedByParameterNameTestBean testBean = (QualifiedByParameterNameTestBean) context.getBean("testBean");
    Person person = testBean.getLarry();
    assertEquals("LarryBean", person.getName());
View Full Code Here

  @Test
  public void testQualifiedByAlias() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByAliasTestBean.class);
    context.refresh();
    QualifiedByAliasTestBean testBean = (QualifiedByAliasTestBean) context.getBean("testBean");
    Person person = testBean.getStooge();
    assertEquals("LarryBean", person.getName());
View Full Code Here

  @Test
  public void testQualifiedByAnnotation() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByAnnotationTestBean.class);
    context.refresh();
    QualifiedByAnnotationTestBean testBean = (QualifiedByAnnotationTestBean) context.getBean("testBean");
    Person person = testBean.getLarry();
    assertEquals("LarrySpecial", person.getName());
View Full Code Here

  @Test
  public void testQualifiedByCustomValue() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByCustomValueTestBean.class);
    context.refresh();
    QualifiedByCustomValueTestBean testBean = (QualifiedByCustomValueTestBean) context.getBean("testBean");
    Person person = testBean.getCurly();
    assertEquals("Curly", person.getName());
View Full Code Here

  @Test
  public void testQualifiedByAnnotationValue() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByAnnotationValueTestBean.class);
    context.refresh();
    QualifiedByAnnotationValueTestBean testBean = (QualifiedByAnnotationValueTestBean) context.getBean("testBean");
    Person person = testBean.getLarry();
    assertEquals("LarrySpecial", person.getName());
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.