Support declarativeBinding mode in DataBinder
Closes gh-30948
This commit is contained in:
@@ -681,6 +681,23 @@ class DataBinderTests {
|
||||
assertThat(dataBinder.convertIfNecessary(bean, String.class)).as("Type converter should have been used").isEqualTo("[Fred]");
|
||||
}
|
||||
|
||||
@Test
|
||||
void bindingInDeclarativeMode() throws BindException {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod);
|
||||
binder.setDeclarativeBinding(true);
|
||||
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.add("name", "Rod");
|
||||
pvs.add("age", "32x");
|
||||
|
||||
binder.bind(pvs);
|
||||
binder.close();
|
||||
|
||||
assertThat(rod.getName()).isNull();
|
||||
assertThat(rod.getAge()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void bindingWithAllowedFields() throws BindException {
|
||||
TestBean rod = new TestBean();
|
||||
|
||||
Reference in New Issue
Block a user