Nested properties support for field-based validation

This commit validates that the changes introduced in 8221c9abc5 are
indeed allowing DirectFieldBindingResult to support nested validation
paths.

Issue: SPR-10623
This commit is contained in:
Stephane Nicoll
2014-06-27 10:59:18 +02:00
parent 113fd1180a
commit bc714888c4
3 changed files with 24 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2006 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,9 @@ public class FieldAccessBean {
private TestBean spouse;
public FieldAccessBean() {
this.spouse = new TestBean();
}
public String getName() {
return name;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@ import org.springframework.tests.sample.beans.TestBean;
/**
* @author Juergen Hoeller
* @author Stephane Nicoll
* @since 07.03.2006
*/
public class DataBinderFieldAccessTests extends TestCase {
@@ -109,6 +110,22 @@ public class DataBinderFieldAccessTests extends TestCase {
}
}
public void testedNestedBindingWithDefaultConversionNoErrors() throws Exception {
FieldAccessBean rod = new FieldAccessBean();
DataBinder binder = new DataBinder(rod, "person");
assertTrue(binder.isIgnoreUnknownFields());
binder.initDirectFieldAccess();
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.addPropertyValue(new PropertyValue("spouse.name", "Kerry"));
pvs.addPropertyValue(new PropertyValue("spouse.jedi", "on"));
binder.bind(pvs);
binder.close();
assertEquals("Kerry", rod.getSpouse().getName());
assertTrue((rod.getSpouse()).isJedi());
}
public void testBindingWithErrorsAndCustomEditors() throws Exception {
FieldAccessBean rod = new FieldAccessBean();
DataBinder binder = new DataBinder(rod, "person");