use of org.springframework.tests.sample.beans.TestBean in project spring-framework by spring-projects.
the class CollectionMergingTests method mergeListWithInnerBeanAsListElementInConstructor.
@Test
public void mergeListWithInnerBeanAsListElementInConstructor() throws Exception {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithListOfRefsInConstructor");
List list = bean.getSomeList();
assertNotNull(list);
assertEquals(3, list.size());
assertNotNull(list.get(2));
assertTrue(list.get(2) instanceof TestBean);
}
use of org.springframework.tests.sample.beans.TestBean in project spring-framework by spring-projects.
the class UtilNamespaceHandlerTests method testCircularCollectionBeansStartingWithList.
@Test
public void testCircularCollectionBeansStartingWithList() {
this.beanFactory.getBean("circularList");
TestBean bean = (TestBean) this.beanFactory.getBean("circularCollectionBeansBean");
List list = bean.getSomeList();
assertTrue(Proxy.isProxyClass(list.getClass()));
assertEquals(1, list.size());
assertEquals(bean, list.get(0));
Set set = bean.getSomeSet();
assertFalse(Proxy.isProxyClass(set.getClass()));
assertEquals(1, set.size());
assertTrue(set.contains(bean));
Map map = bean.getSomeMap();
assertFalse(Proxy.isProxyClass(map.getClass()));
assertEquals(1, map.size());
assertEquals(bean, map.get("foo"));
}
use of org.springframework.tests.sample.beans.TestBean in project spring-framework by spring-projects.
the class UtilNamespaceHandlerTests method testCircularCollections.
@Test
public void testCircularCollections() {
TestBean bean = (TestBean) this.beanFactory.getBean("circularCollectionsBean");
List list = bean.getSomeList();
assertEquals(1, list.size());
assertEquals(bean, list.get(0));
Set set = bean.getSomeSet();
assertEquals(1, set.size());
assertTrue(set.contains(bean));
Map map = bean.getSomeMap();
assertEquals(1, map.size());
assertEquals(bean, map.get("foo"));
}
use of org.springframework.tests.sample.beans.TestBean in project spring-framework by spring-projects.
the class UtilNamespaceHandlerTests method testNestedShortcutCollections.
@Test
public void testNestedShortcutCollections() {
TestBean bean = (TestBean) this.beanFactory.getBean("nestedShortcutCollections");
assertEquals(1, bean.getStringArray().length);
assertEquals("fooStr", bean.getStringArray()[0]);
List list = bean.getSomeList();
assertEquals(1, list.size());
assertEquals("foo", list.get(0));
Set set = bean.getSomeSet();
assertEquals(1, set.size());
assertTrue(set.contains("bar"));
TestBean bean2 = (TestBean) this.beanFactory.getBean("nestedShortcutCollections");
assertTrue(Arrays.equals(bean.getStringArray(), bean2.getStringArray()));
assertFalse(bean.getStringArray() == bean2.getStringArray());
assertEquals(list, bean2.getSomeList());
assertEquals(set, bean2.getSomeSet());
assertFalse(list == bean2.getSomeList());
assertFalse(set == bean2.getSomeSet());
}
use of org.springframework.tests.sample.beans.TestBean in project spring-framework by spring-projects.
the class UtilNamespaceHandlerTests method testNestedCollections.
@Test
public void testNestedCollections() {
TestBean bean = (TestBean) this.beanFactory.getBean("nestedCollectionsBean");
List list = bean.getSomeList();
assertEquals(1, list.size());
assertEquals("foo", list.get(0));
Set set = bean.getSomeSet();
assertEquals(1, set.size());
assertTrue(set.contains("bar"));
Map map = bean.getSomeMap();
assertEquals(1, map.size());
assertTrue(map.get("foo") instanceof Set);
Set innerSet = (Set) map.get("foo");
assertEquals(1, innerSet.size());
assertTrue(innerSet.contains("bar"));
TestBean bean2 = (TestBean) this.beanFactory.getBean("nestedCollectionsBean");
assertEquals(list, bean2.getSomeList());
assertEquals(set, bean2.getSomeSet());
assertEquals(map, bean2.getSomeMap());
assertFalse(list == bean2.getSomeList());
assertFalse(set == bean2.getSomeSet());
assertFalse(map == bean2.getSomeMap());
}
Aggregations