Package org.springframework.tests.sample.beans

Examples of org.springframework.tests.sample.beans.IndexedTestBean


    props.setProperty("tb.array[0].name", "99");
    props.setProperty("tb.list[1].name", "test");
    bfpp.setProperties(props);
    bfpp.postProcessBeanFactory(factory);

    IndexedTestBean tb = (IndexedTestBean) factory.getBean("tb");
    assertEquals("X99", tb.getArray()[0].getName());
    assertEquals("Xtest", ((TestBean) tb.getList().get(1)).getName());
  }
View Full Code Here


    assertEquals("name", tag.getProperty());
  }

  public void testBindTagWithIndexedProperties() throws JspException {
    PageContext pc = createPageContext();
    IndexedTestBean tb = new IndexedTestBean();
    Errors errors = new ServletRequestDataBinder(tb, "tb").getBindingResult();
    errors.rejectValue("array[0]", "code1", "message1");
    errors.rejectValue("array[0]", "code2", "message2");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);
View Full Code Here

    assertTrue("Correct errorMessage", "message2".equals(status.getErrorMessages()[1]));
  }

  public void testBindTagWithMappedProperties() throws JspException {
    PageContext pc = createPageContext();
    IndexedTestBean tb = new IndexedTestBean();
    Errors errors = new ServletRequestDataBinder(tb, "tb").getBindingResult();
    errors.rejectValue("map[key1]", "code1", "message1");
    errors.rejectValue("map[key1]", "code2", "message2");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);
View Full Code Here

    assertTrue("Correct errorMessage", "message2".equals(status.getErrorMessages()[1]));
  }

  public void testBindTagWithIndexedPropertiesAndCustomEditor() throws JspException {
    PageContext pc = createPageContext();
    IndexedTestBean tb = new IndexedTestBean();
    DataBinder binder = new ServletRequestDataBinder(tb, "tb");
    binder.registerCustomEditor(TestBean.class, null, new PropertyEditorSupport() {
      @Override
      public String getAsText() {
        return "something";
View Full Code Here

  public void testNestedPropertyValue() {
    DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
    new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
    DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
    new XmlBeanDefinitionReader(child).loadBeanDefinitions(CHILD_CONTEXT);
    IndexedTestBean bean = (IndexedTestBean) child.getBean("indexedTestBean");
    assertEquals("name applied correctly", "myname", bean.getArray()[0].getName());
  }
View Full Code Here

    DependenciesBean rod2a = (DependenciesBean) xbf.getBean("rod2a");
    // should have been set explicitly
    assertEquals(kerry, rod2a.getSpouse());

    ConstructorDependenciesBean rod3 = (ConstructorDependenciesBean) xbf.getBean("rod3");
    IndexedTestBean other = (IndexedTestBean) xbf.getBean("other");
    // should have been autowired
    assertEquals(kerry, rod3.getSpouse1());
    assertEquals(kerry, rod3.getSpouse2());
    assertEquals(other, rod3.getOther());
View Full Code Here

    assertEquals(kerry1, rod2.getSpouse2());
    assertEquals(0, rod2.getAge());
    assertEquals(null, rod2.getName());

    ConstructorDependenciesBean rod = (ConstructorDependenciesBean) xbf.getBean("rod3");
    IndexedTestBean other = (IndexedTestBean) xbf.getBean("other");
    // should have been autowired
    assertEquals(kerry, rod.getSpouse1());
    assertEquals(kerry, rod.getSpouse2());
    assertEquals(other, rod.getOther());
    assertEquals(0, rod.getAge());
View Full Code Here

    new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);

    ConstructorDependenciesBean rod5 = (ConstructorDependenciesBean) xbf.getBean("rod5");
    TestBean kerry1 = (TestBean) xbf.getBean("kerry1");
    TestBean kerry2 = (TestBean) xbf.getBean("kerry2");
    IndexedTestBean other = (IndexedTestBean) xbf.getBean("other");
    // should have been autowired
    assertEquals(kerry2, rod5.getSpouse1());
    assertEquals(kerry1, rod5.getSpouse2());
    assertEquals(other, rod5.getOther());
    assertEquals(99, rod5.getAge());
View Full Code Here

TOP

Related Classes of org.springframework.tests.sample.beans.IndexedTestBean

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.