@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2016 the original author or authors .
* Copyright 2002 - 2018 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 .
@ -42,9 +42,11 @@ import org.junit.rules.ExpectedException;
@@ -42,9 +42,11 @@ import org.junit.rules.ExpectedException;
import org.springframework.beans.BeanWrapper ;
import org.springframework.beans.InvalidPropertyException ;
import org.springframework.beans.MethodInvocationException ;
import org.springframework.beans.MutablePropertyValues ;
import org.springframework.beans.NotWritablePropertyException ;
import org.springframework.beans.NullValueInNestedPathException ;
import org.springframework.beans.TypeMismatchException ;
import org.springframework.beans.propertyeditors.CustomCollectionEditor ;
import org.springframework.beans.propertyeditors.CustomNumberEditor ;
import org.springframework.beans.propertyeditors.StringTrimmerEditor ;
@ -78,11 +80,11 @@ import static org.junit.Assert.*;
@@ -78,11 +80,11 @@ import static org.junit.Assert.*;
public class DataBinderTests {
@Rule
public ExpectedException expectedException = ExpectedException . none ( ) ;
public final ExpectedException expectedException = ExpectedException . none ( ) ;
@Test
public void testBindingNoErrors ( ) throws Exception {
public void testBindingNoErrors ( ) throws Bind Exception {
TestBean rod = new TestBean ( ) ;
DataBinder binder = new DataBinder ( rod , "person" ) ;
assertTrue ( binder . isIgnoreUnknownFields ( ) ) ;
@ -116,7 +118,7 @@ public class DataBinderTests {
@@ -116,7 +118,7 @@ public class DataBinderTests {
}
@Test
public void testBindingWithDefaultConversionNoErrors ( ) throws Exception {
public void testBindingWithDefaultConversionNoErrors ( ) throws Bind Exception {
TestBean rod = new TestBean ( ) ;
DataBinder binder = new DataBinder ( rod , "person" ) ;
assertTrue ( binder . isIgnoreUnknownFields ( ) ) ;
@ -132,7 +134,7 @@ public class DataBinderTests {
@@ -132,7 +134,7 @@ public class DataBinderTests {
}
@Test
public void testNestedBindingWithDefaultConversionNoErrors ( ) throws Exception {
public void testNestedBindingWithDefaultConversionNoErrors ( ) throws Bind Exception {
TestBean rod = new TestBean ( new TestBean ( ) ) ;
DataBinder binder = new DataBinder ( rod , "person" ) ;
assertTrue ( binder . isIgnoreUnknownFields ( ) ) ;
@ -148,7 +150,7 @@ public class DataBinderTests {
@@ -148,7 +150,7 @@ public class DataBinderTests {
}
@Test
public void testBindingNoErrorsNotIgnoreUnknown ( ) throws Exception {
public void testBindingNoErrorsNotIgnoreUnknown ( ) {
TestBean rod = new TestBean ( ) ;
DataBinder binder = new DataBinder ( rod , "person" ) ;
binder . setIgnoreUnknownFields ( false ) ;
@ -167,7 +169,7 @@ public class DataBinderTests {
@@ -167,7 +169,7 @@ public class DataBinderTests {
}
@Test
public void testBindingNoErrorsWithInvalidField ( ) throws Exception {
public void testBindingNoErrorsWithInvalidField ( ) {
TestBean rod = new TestBean ( ) ;
DataBinder binder = new DataBinder ( rod , "person" ) ;
MutablePropertyValues pvs = new MutablePropertyValues ( ) ;
@ -184,7 +186,7 @@ public class DataBinderTests {
@@ -184,7 +186,7 @@ public class DataBinderTests {
}
@Test
public void testBindingNoErrorsWithIgnoreInvalid ( ) throws Exception {
public void testBindingNoErrorsWithIgnoreInvalid ( ) {
TestBean rod = new TestBean ( ) ;
DataBinder binder = new DataBinder ( rod , "person" ) ;
binder . setIgnoreInvalidFields ( true ) ;
@ -196,7 +198,7 @@ public class DataBinderTests {
@@ -196,7 +198,7 @@ public class DataBinderTests {
}
@Test
public void testBindingWithErrors ( ) throws Exception {
public void testBindingWithErrors ( ) {
TestBean rod = new TestBean ( ) ;
DataBinder binder = new DataBinder ( rod , "person" ) ;
MutablePropertyValues pvs = new MutablePropertyValues ( ) ;
@ -239,6 +241,7 @@ public class DataBinderTests {
@@ -239,6 +241,7 @@ public class DataBinderTests {
assertEquals ( "typeMismatch" , binder . getBindingResult ( ) . getFieldError ( "age" ) . getCode ( ) ) ;
assertEquals ( "32x" , binder . getBindingResult ( ) . getFieldValue ( "age" ) ) ;
assertEquals ( "32x" , binder . getBindingResult ( ) . getFieldError ( "age" ) . getRejectedValue ( ) ) ;
assertTrue ( binder . getBindingResult ( ) . getFieldError ( "age" ) . getSource ( ) instanceof TypeMismatchException ) ;
assertEquals ( 0 , tb . getAge ( ) ) ;
assertTrue ( "Has touchy errors" , br . hasFieldErrors ( "touchy" ) ) ;
@ -246,6 +249,7 @@ public class DataBinderTests {
@@ -246,6 +249,7 @@ public class DataBinderTests {
assertEquals ( "methodInvocation" , binder . getBindingResult ( ) . getFieldError ( "touchy" ) . getCode ( ) ) ;
assertEquals ( "m.y" , binder . getBindingResult ( ) . getFieldValue ( "touchy" ) ) ;
assertEquals ( "m.y" , binder . getBindingResult ( ) . getFieldError ( "touchy" ) . getRejectedValue ( ) ) ;
assertTrue ( binder . getBindingResult ( ) . getFieldError ( "touchy" ) . getSource ( ) instanceof MethodInvocationException ) ;
assertNull ( tb . getTouchy ( ) ) ;
rod = new TestBean ( ) ;
@ -260,7 +264,7 @@ public class DataBinderTests {
@@ -260,7 +264,7 @@ public class DataBinderTests {
}
@Test
public void testBindingWithSystemFieldError ( ) throws Exception {
public void testBindingWithSystemFieldError ( ) {
TestBean rod = new TestBean ( ) ;
DataBinder binder = new DataBinder ( rod , "person" ) ;
MutablePropertyValues pvs = new MutablePropertyValues ( ) ;
@ -277,7 +281,7 @@ public class DataBinderTests {
@@ -277,7 +281,7 @@ public class DataBinderTests {
}
@Test
public void testBindingWithErrorsAndCustomEditors ( ) throws Exception {
public void testBindingWithErrorsAndCustomEditors ( ) {
TestBean rod = new TestBean ( ) ;
DataBinder binder = new DataBinder ( rod , "person" ) ;
binder . registerCustomEditor ( String . class , "touchy" , new PropertyEditorSupport ( ) {
@ -683,7 +687,7 @@ public class DataBinderTests {
@@ -683,7 +687,7 @@ public class DataBinderTests {
}
@Test
public void testBindingWithAllowedFields ( ) throws Exception {
public void testBindingWithAllowedFields ( ) throws Bind Exception {
TestBean rod = new TestBean ( ) ;
DataBinder binder = new DataBinder ( rod ) ;
binder . setAllowedFields ( "name" , "myparam" ) ;
@ -698,7 +702,7 @@ public class DataBinderTests {
@@ -698,7 +702,7 @@ public class DataBinderTests {
}
@Test
public void testBindingWithDisallowedFields ( ) throws Exception {
public void testBindingWithDisallowedFields ( ) throws Bind Exception {
TestBean rod = new TestBean ( ) ;
DataBinder binder = new DataBinder ( rod ) ;
binder . setDisallowedFields ( "age" ) ;
@ -716,7 +720,7 @@ public class DataBinderTests {
@@ -716,7 +720,7 @@ public class DataBinderTests {
}
@Test
public void testBindingWithAllowedAndDisallowedFields ( ) throws Exception {
public void testBindingWithAllowedAndDisallowedFields ( ) throws Bind Exception {
TestBean rod = new TestBean ( ) ;
DataBinder binder = new DataBinder ( rod ) ;
binder . setAllowedFields ( "name" , "myparam" ) ;
@ -735,7 +739,7 @@ public class DataBinderTests {
@@ -735,7 +739,7 @@ public class DataBinderTests {
}
@Test
public void testBindingWithOverlappingAllowedAndDisallowedFields ( ) throws Exception {
public void testBindingWithOverlappingAllowedAndDisallowedFields ( ) throws Bind Exception {
TestBean rod = new TestBean ( ) ;
DataBinder binder = new DataBinder ( rod ) ;
binder . setAllowedFields ( "name" , "age" ) ;
@ -754,7 +758,7 @@ public class DataBinderTests {
@@ -754,7 +758,7 @@ public class DataBinderTests {
}
@Test
public void testBindingWithAllowedFieldsUsingAsterisks ( ) throws Exception {
public void testBindingWithAllowedFieldsUsingAsterisks ( ) throws Bind Exception {
TestBean rod = new TestBean ( ) ;
DataBinder binder = new DataBinder ( rod , "person" ) ;
binder . setAllowedFields ( "nam*" , "*ouchy" ) ;
@ -781,7 +785,7 @@ public class DataBinderTests {
@@ -781,7 +785,7 @@ public class DataBinderTests {
}
@Test
public void testBindingWithAllowedAndDisallowedMapFields ( ) throws Exception {
public void testBindingWithAllowedAndDisallowedMapFields ( ) throws Bind Exception {
TestBean rod = new TestBean ( ) ;
DataBinder binder = new DataBinder ( rod ) ;
binder . setAllowedFields ( "someMap[key1]" , "someMap[key2]" ) ;
@ -809,7 +813,7 @@ public class DataBinderTests {
@@ -809,7 +813,7 @@ public class DataBinderTests {
* Tests for required field , both null , non - existing and empty strings .
* /
@Test
public void testBindingWithRequiredFields ( ) throws Exception {
public void testBindingWithRequiredFields ( ) {
TestBean tb = new TestBean ( ) ;
tb . setSpouse ( new TestBean ( ) ) ;
@ -840,7 +844,7 @@ public class DataBinderTests {
@@ -840,7 +844,7 @@ public class DataBinderTests {
}
@Test
public void testBindingWithRequiredMapFields ( ) throws Exception {
public void testBindingWithRequiredMapFields ( ) {
TestBean tb = new TestBean ( ) ;
tb . setSpouse ( new TestBean ( ) ) ;
@ -860,7 +864,7 @@ public class DataBinderTests {
@@ -860,7 +864,7 @@ public class DataBinderTests {
}
@Test
public void testBindingWithNestedObjectCreation ( ) throws Exception {
public void testBindingWithNestedObjectCreation ( ) {
TestBean tb = new TestBean ( ) ;
DataBinder binder = new DataBinder ( tb , "person" ) ;
@ -1828,7 +1832,7 @@ public class DataBinderTests {
@@ -1828,7 +1832,7 @@ public class DataBinderTests {
}
@Test
public void testRejectWithoutDefaultMessage ( ) throws Exception {
public void testRejectWithoutDefaultMessage ( ) {
TestBean tb = new TestBean ( ) ;
tb . setName ( "myName" ) ;
tb . setAge ( 99 ) ;
@ -1875,7 +1879,7 @@ public class DataBinderTests {
@@ -1875,7 +1879,7 @@ public class DataBinderTests {
}
@Test
public void testTrackDisallowedFields ( ) throws Exception {
public void testTrackDisallowedFields ( ) {
TestBean testBean = new TestBean ( ) ;
DataBinder binder = new DataBinder ( testBean , "testBean" ) ;
binder . setAllowedFields ( "name" , "age" ) ;
@ -1895,7 +1899,7 @@ public class DataBinderTests {
@@ -1895,7 +1899,7 @@ public class DataBinderTests {
}
@Test
public void testAutoGrowWithinDefaultLimit ( ) throws Exception {
public void testAutoGrowWithinDefaultLimit ( ) {
TestBean testBean = new TestBean ( ) ;
DataBinder binder = new DataBinder ( testBean , "testBean" ) ;
@ -1907,7 +1911,7 @@ public class DataBinderTests {
@@ -1907,7 +1911,7 @@ public class DataBinderTests {
}
@Test
public void testAutoGrowBeyondDefaultLimit ( ) throws Exception {
public void testAutoGrowBeyondDefaultLimit ( ) {
TestBean testBean = new TestBean ( ) ;
DataBinder binder = new DataBinder ( testBean , "testBean" ) ;
@ -1924,7 +1928,7 @@ public class DataBinderTests {
@@ -1924,7 +1928,7 @@ public class DataBinderTests {
}
@Test
public void testAutoGrowWithinCustomLimit ( ) throws Exception {
public void testAutoGrowWithinCustomLimit ( ) {
TestBean testBean = new TestBean ( ) ;
DataBinder binder = new DataBinder ( testBean , "testBean" ) ;
binder . setAutoGrowCollectionLimit ( 10 ) ;
@ -1937,7 +1941,7 @@ public class DataBinderTests {
@@ -1937,7 +1941,7 @@ public class DataBinderTests {
}
@Test
public void testAutoGrowBeyondCustomLimit ( ) throws Exception {
public void testAutoGrowBeyondCustomLimit ( ) {
TestBean testBean = new TestBean ( ) ;
DataBinder binder = new DataBinder ( testBean , "testBean" ) ;
binder . setAutoGrowCollectionLimit ( 10 ) ;
@ -1971,7 +1975,7 @@ public class DataBinderTests {
@@ -1971,7 +1975,7 @@ public class DataBinderTests {
}
@Test
public void testFieldErrorAccessVariations ( ) throws Exception {
public void testFieldErrorAccessVariations ( ) {
TestBean testBean = new TestBean ( ) ;
DataBinder binder = new DataBinder ( testBean , "testBean" ) ;
assertNull ( binder . getBindingResult ( ) . getGlobalError ( ) ) ;