public void testFactoryNesting() {
    ITestBean father = (ITestBean) getBeanFactory().getBean("father");
    assertTrue("Bean from root context", father != null);

    ITestBean rod = (ITestBean) getBeanFactory().getBean("rod");
    assertTrue("Bean from child context", "Rod".equals(rod.getName()));
    assertTrue("Bean has external reference", rod.getSpouse() == father);

    rod = (ITestBean) parent.getBean("rod");
    assertTrue("Bean from root context", "Roderick".equals(rod.getName()));
  }
 /** Uses a separate factory */
 public void testRefToSeparatePrototypeInstances() throws Exception {
   InputStream is = getClass().getResourceAsStream("reftypes.xml");
   XmlBeanFactory xbf = new XmlBeanFactory(is);
   assertTrue(
       "6 beans in reftypes, not " + xbf.getBeanDefinitionCount(),
       xbf.getBeanDefinitionCount() == 6);
   TestBean emma = (TestBean) xbf.getBean("emma");
   TestBean georgia = (TestBean) xbf.getBean("georgia");
   ITestBean emmasJenks = emma.getSpouse();
   ITestBean georgiasJenks = georgia.getSpouse();
   assertTrue(
       "Emma and georgia think they have a different boyfriend", emmasJenks != georgiasJenks);
   assertTrue("Emmas jenks has right name", emmasJenks.getName().equals("Andrew"));
   assertTrue("Emmas doesn't equal new ref", emmasJenks != xbf.getBean("jenks"));
   assertTrue("Georgias jenks has right name", emmasJenks.getName().equals("Andrew"));
   assertTrue("They are object equal", emmasJenks.equals(georgiasJenks));
   assertTrue("They object equal direct ref", emmasJenks.equals(xbf.getBean("jenks")));
 }