Support declarativeBinding mode in DataBinder

Closes gh-30948
This commit is contained in:
rstoyanchev
2023-07-25 18:04:21 +03:00
parent 37eaded63d
commit 67e3d86bd8
7 changed files with 106 additions and 0 deletions

View File

@@ -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();