Package org.springframework.beans.factory.xml

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


        mr.render();
    }

    private static BeanFactory getBeanFactory() throws Exception {
        // get the bean factory
        BeanFactory factory = new XmlBeanFactory(new FileSystemResource(
                "ch4/src/conf/beans.xml"));

        return factory;
    }
View Full Code Here


  private ConfigurableListableBeanFactory dependentBeansBF;

  protected void setUp() {
    // Interesting hierarchical factory to test counts.
    // Slow to read so we cache it.
    XmlBeanFactory grandParent = new XmlBeanFactory(new ClassPathResource("root.xml", getClass()));
    XmlBeanFactory parent = new XmlBeanFactory(new ClassPathResource("middle.xml", getClass()), grandParent);
    XmlBeanFactory child = new XmlBeanFactory(new ClassPathResource("leaf.xml", getClass()), parent);
    this.dependentBeansBF = new XmlBeanFactory(new ClassPathResource("dependentBeans.xml", getClass()));
    dependentBeansBF.preInstantiateSingletons();
    this.listableBeanFactory = child;
  }
View Full Code Here

* @author Juergen Hoeller
*/
public class FactoryBeanTests extends TestCase {

  public void testFactoryBeanReturnsNull() throws Exception {
    XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource("factoryBeanReturnsNull.xml", getClass()));
    Object result = factory.getBean("factoryBean");
    assertNull(result);
  }
View Full Code Here

  private Set set = Collections.synchronizedSet(new HashSet());

  private Throwable ex = null;

  protected void setUp() throws Exception {
    XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource("concurrent.xml", getClass()));
    CustomDateEditor editor = new CustomDateEditor(df, false);
    factory.registerCustomEditor(Date.class, editor);
    this.factory = factory;
  }
View Full Code Here

                System.exit(-1);
            }

            PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
            configurer.setProperties(commandLineProperties);
            XmlBeanFactory factoryBean = new XmlBeanFactory(new ClassPathResource("com/alphacsp/cit/context/applicationContext.xml"));
            configurer.postProcessBeanFactory(factoryBean);

            UserInterface userInterface = (UserInterface) factoryBean.getBean("userInterface");
            userInterface.start();

            Interperter interperter = (Interperter) factoryBean.getBean("interperter");

            interperter.interpret();
        } catch (ValidationException e) {
            System.err.println(e.getMessage());
            System.exit(-1);
View Full Code Here

  private BeanFactory beanFactory;


  protected void setUp() throws Exception {
    this.beanFactory = new XmlBeanFactory(new ClassPathResource(
        "ObjectFactoryCreatingFactoryBeanTests.xml", getClass()));
  }
View Full Code Here

* @since 04.10.2004
*/
public class PropertyPathFactoryBeanTests extends TestCase {

  public void testPropertyPathFactoryBeanWithSingletonResult() {
    XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("propertyPath.xml", getClass()));
    assertEquals(new Integer(12), xbf.getBean("propertyPath1"));
    assertEquals(new Integer(11), xbf.getBean("propertyPath2"));
    assertEquals(new Integer(10), xbf.getBean("tb.age"));
    assertEquals(ITestBean.class, xbf.getType("otb.spouse"));
    Object result1 = xbf.getBean("otb.spouse");
    Object result2 = xbf.getBean("otb.spouse");
    assertTrue(result1 instanceof TestBean);
    assertTrue(result1 == result2);
    assertEquals(99, ((TestBean) result1).getAge());
  }
View Full Code Here

    assertTrue(result1 == result2);
    assertEquals(99, ((TestBean) result1).getAge());
  }

  public void testPropertyPathFactoryBeanWithPrototypeResult() {
    XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("propertyPath.xml", getClass()));
    assertNull(xbf.getType("tb.spouse"));
    assertEquals(TestBean.class, xbf.getType("propertyPath3"));
    Object result1 = xbf.getBean("tb.spouse");
    Object result2 = xbf.getBean("propertyPath3");
    Object result3 = xbf.getBean("propertyPath3");
    assertTrue(result1 instanceof TestBean);
    assertTrue(result2 instanceof TestBean);
    assertTrue(result3 instanceof TestBean);
    assertEquals(11, ((TestBean) result1).getAge());
    assertEquals(11, ((TestBean) result2).getAge());
View Full Code Here

    assertTrue(result1 != result3);
    assertTrue(result2 != result3);
  }

  public void testPropertyPathFactoryBeanWithNullResult() {
    XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("propertyPath.xml", getClass()));
    assertNull(xbf.getType("tb.spouse.spouse"));
    assertNull(xbf.getBean("tb.spouse.spouse"));
  }
View Full Code Here

    assertNull(xbf.getType("tb.spouse.spouse"));
    assertNull(xbf.getBean("tb.spouse.spouse"));
  }

  public void testPropertyPathFactoryBeanAsInnerBean() {
    XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("propertyPath.xml", getClass()));
    TestBean spouse = (TestBean) xbf.getBean("otb.spouse");
    TestBean tbWithInner = (TestBean) xbf.getBean("tbWithInner");
    assertSame(spouse, tbWithInner.getSpouse());
    assertTrue(!tbWithInner.getFriends().isEmpty());
    assertSame(spouse, tbWithInner.getFriends().iterator().next());
  }
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.xml.XmlBeanFactory

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.