Search in sources :

Example 1 with BeanWithObjectProperty

use of org.springframework.tests.sample.beans.BeanWithObjectProperty in project spring-framework by spring-projects.

the class DataBinderTests method testBindingWithCustomEditorOnObjectField.

@Test
public void testBindingWithCustomEditorOnObjectField() {
    BeanWithObjectProperty tb = new BeanWithObjectProperty();
    DataBinder binder = new DataBinder(tb);
    binder.registerCustomEditor(Integer.class, "object", new CustomNumberEditor(Integer.class, true));
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("object", "1");
    binder.bind(pvs);
    assertEquals(new Integer(1), tb.getObject());
}
Also used : BeanWithObjectProperty(org.springframework.tests.sample.beans.BeanWithObjectProperty) CustomNumberEditor(org.springframework.beans.propertyeditors.CustomNumberEditor) MutablePropertyValues(org.springframework.beans.MutablePropertyValues) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)1 CustomNumberEditor (org.springframework.beans.propertyeditors.CustomNumberEditor)1 BeanWithObjectProperty (org.springframework.tests.sample.beans.BeanWithObjectProperty)1