Search in sources :

Example 91 with TestBean

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);
}
Also used : TestBean(org.springframework.tests.sample.beans.TestBean) List(java.util.List) Test(org.junit.Test)

Example 92 with 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"));
}
Also used : Set(java.util.Set) TestBean(org.springframework.tests.sample.beans.TestBean) List(java.util.List) LinkedCaseInsensitiveMap(org.springframework.util.LinkedCaseInsensitiveMap) TreeMap(java.util.TreeMap) Map(java.util.Map) Test(org.junit.Test)

Example 93 with TestBean

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"));
}
Also used : Set(java.util.Set) TestBean(org.springframework.tests.sample.beans.TestBean) List(java.util.List) LinkedCaseInsensitiveMap(org.springframework.util.LinkedCaseInsensitiveMap) TreeMap(java.util.TreeMap) Map(java.util.Map) Test(org.junit.Test)

Example 94 with TestBean

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());
}
Also used : Set(java.util.Set) TestBean(org.springframework.tests.sample.beans.TestBean) List(java.util.List) Test(org.junit.Test)

Example 95 with TestBean

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());
}
Also used : Set(java.util.Set) TestBean(org.springframework.tests.sample.beans.TestBean) List(java.util.List) LinkedCaseInsensitiveMap(org.springframework.util.LinkedCaseInsensitiveMap) TreeMap(java.util.TreeMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

TestBean (org.springframework.tests.sample.beans.TestBean)788 Test (org.junit.Test)740 ITestBean (org.springframework.tests.sample.beans.ITestBean)456 IndexedTestBean (org.springframework.tests.sample.beans.IndexedTestBean)248 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)225 NestedTestBean (org.springframework.tests.sample.beans.NestedTestBean)164 DerivedTestBean (org.springframework.tests.sample.beans.DerivedTestBean)160 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)144 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)86 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)44 BooleanTestBean (org.springframework.tests.sample.beans.BooleanTestBean)40 NumberTestBean (org.springframework.tests.sample.beans.NumberTestBean)40 Properties (java.util.Properties)35 Errors (org.springframework.validation.Errors)34 NopInterceptor (org.springframework.tests.aop.interceptor.NopInterceptor)33 PropertyEditorSupport (java.beans.PropertyEditorSupport)31 HashMap (java.util.HashMap)30 List (java.util.List)27 Map (java.util.Map)27 PageContext (javax.servlet.jsp.PageContext)27