Package org.springframework.beans

Examples of org.springframework.beans.TestBean


    props.put("os.name", "myos");
    pvs.addPropertyValue("properties", props);
    pvs.addPropertyValue("systemPropertiesModeName", "SYSTEM_PROPERTIES_MODE_OVERRIDE");
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertEquals(System.getProperty("os.name"), tb.getTouchy());
  }
View Full Code Here


  public void testSelfReference() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("spouse", new RuntimeBeanReference("self"));
    lbf.registerBeanDefinition("self", new RootBeanDefinition(TestBean.class, pvs));
    TestBean self = (TestBean) lbf.getBean("self");
    assertEquals(self, self.getSpouse());
  }
View Full Code Here

    ac.registerSingleton("tb", TestBean.class, pvs);
    pvs = new MutablePropertyValues();
    pvs.addPropertyValue("ignoreUnresolvablePlaceholders", Boolean.TRUE);
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertEquals("${ref}", tb.getName());
  }
View Full Code Here

    ac.registerSingleton("tb", TestBean.class, pvs);
    pvs = new MutablePropertyValues();
    pvs.addPropertyValue("nullValue", "");
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertNull(tb.getName());
  }
View Full Code Here

    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    Properties p = new Properties();
    p.setProperty("kerry.(class)", "org.springframework.beans.TestBean");
    p.setProperty("kerry.age", "35");
    (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
    TestBean kerry1 = (TestBean) lbf.getBean("kerry");
    TestBean kerry2 = (TestBean) lbf.getBean("kerry");
    assertTrue("Non null", kerry1 != null);
    assertTrue("Singletons equal", kerry1 == kerry2);

    lbf = new DefaultListableBeanFactory();
    p = new Properties();
View Full Code Here

    Properties props = new Properties();
    props.put("ref", "");
    pvs.addPropertyValue("properties", props);
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertNull(tb.getName());
  }
View Full Code Here

    p.setProperty("wife.name", "kerry");

    p.setProperty("kerry.(parent)", "wife");
    p.setProperty("kerry.age", "35");
    (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
    TestBean kerry1 = (TestBean) lbf.getBean("kerry");
    TestBean kerry2 = (TestBean) lbf.getBean("kerry");
    assertEquals("kerry", kerry1.getName());
    assertNotNull("Non null", kerry1);
    assertTrue("Singletons equal", kerry1 == kerry2);

    lbf = new DefaultListableBeanFactory();
View Full Code Here

    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
    factory.registerBeanDefinition("parent", parentDefinition);
    factory.registerBeanDefinition("child", childDefinition);
    factory.registerAlias("parent", "alias");

    TestBean child = (TestBean) factory.getBean("child");
    assertEquals(EXPECTED_NAME, child.getName());
    assertEquals(EXPECTED_AGE, child.getAge());

    assertEquals("Use cached merged bean definition",
        factory.getMergedBeanDefinition("child"), factory.getMergedBeanDefinition("child"));
  }
View Full Code Here

    props.put("key", "new");
    props.put("mynewkey", "myname");
    pvs.addPropertyValue("properties", props);
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertEquals("myname", tb.getName());
  }
View Full Code Here

    Properties props = new Properties();
    props.put("test", "mytest");
    pvs.addPropertyValue("properties", new Properties(props));
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertEquals("mytest", tb.getTouchy());
  }
View Full Code Here

TOP

Related Classes of org.springframework.beans.TestBean

Copyright © 2018 www.massapicom. 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.