public void testRefSubelementsBuildCollectionFromSingleElement() throws Exception { InputStream is = getClass().getResourceAsStream("collections.xml"); XmlBeanFactory xbf = new XmlBeanFactory(is); // assertTrue("5 beans in reftypes, not " + xbf.getBeanDefinitionCount(), // xbf.getBeanDefinitionCount() == 5); TestBean loner = (TestBean) xbf.getBean("loner"); TestBean dave = (TestBean) xbf.getBean("david"); assertTrue(loner.getFriends().size() == 1); assertTrue(loner.getFriends().contains(dave)); }
public void testRefSubelementsBuildCollection() throws Exception { InputStream is = getClass().getResourceAsStream("collections.xml"); XmlBeanFactory xbf = new XmlBeanFactory(is); // assertTrue("5 beans in reftypes, not " + xbf.getBeanDefinitionCount(), // xbf.getBeanDefinitionCount() == 5); TestBean jen = (TestBean) xbf.getBean("jenny"); TestBean dave = (TestBean) xbf.getBean("david"); TestBean rod = (TestBean) xbf.getBean("rod"); // Must be a list to support ordering // Our bean doesn't modify the collection: // of course it could be a different copy in a real object List friends = (List) rod.getFriends(); assertTrue(friends.size() == 2); assertTrue("First friend must be jen, not " + friends.get(0), friends.get(0).equals(jen)); assertTrue(friends.get(1).equals(dave)); // Should be ordered }