1
1
/*
2
- * Copyright 2002-2015 the original author or authors.
2
+ * Copyright 2002-2016 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -226,12 +226,14 @@ public void testBindingWithErrors() throws Exception {
226
226
227
227
assertTrue ("Has age errors" , br .hasFieldErrors ("age" ));
228
228
assertTrue ("Correct number of age errors" , br .getFieldErrorCount ("age" ) == 1 );
229
+ assertEquals ("typeMismatch" , binder .getBindingResult ().getFieldError ("age" ).getCode ());
229
230
assertEquals ("32x" , binder .getBindingResult ().getFieldValue ("age" ));
230
231
assertEquals ("32x" , binder .getBindingResult ().getFieldError ("age" ).getRejectedValue ());
231
232
assertEquals (0 , tb .getAge ());
232
233
233
234
assertTrue ("Has touchy errors" , br .hasFieldErrors ("touchy" ));
234
235
assertTrue ("Correct number of touchy errors" , br .getFieldErrorCount ("touchy" ) == 1 );
236
+ assertEquals ("methodInvocation" , binder .getBindingResult ().getFieldError ("touchy" ).getCode ());
235
237
assertEquals ("m.y" , binder .getBindingResult ().getFieldValue ("touchy" ));
236
238
assertEquals ("m.y" , binder .getBindingResult ().getFieldError ("touchy" ).getRejectedValue ());
237
239
assertNull (tb .getTouchy ());
@@ -315,12 +317,14 @@ public String getAsText() {
315
317
316
318
assertTrue ("Has age errors" , br .hasFieldErrors ("age" ));
317
319
assertTrue ("Correct number of age errors" , br .getFieldErrorCount ("age" ) == 1 );
320
+ assertEquals ("typeMismatch" , binder .getBindingResult ().getFieldError ("age" ).getCode ());
318
321
assertEquals ("32x" , binder .getBindingResult ().getFieldValue ("age" ));
319
322
assertEquals ("32x" , binder .getBindingResult ().getFieldError ("age" ).getRejectedValue ());
320
323
assertEquals (0 , tb .getAge ());
321
324
322
325
assertTrue ("Has touchy errors" , br .hasFieldErrors ("touchy" ));
323
326
assertTrue ("Correct number of touchy errors" , br .getFieldErrorCount ("touchy" ) == 1 );
327
+ assertEquals ("methodInvocation" , binder .getBindingResult ().getFieldError ("touchy" ).getCode ());
324
328
assertEquals ("m.y" , binder .getBindingResult ().getFieldValue ("touchy" ));
325
329
assertEquals ("m.y" , binder .getBindingResult ().getFieldError ("touchy" ).getRejectedValue ());
326
330
assertNull (tb .getTouchy ());
@@ -419,6 +423,7 @@ public String print(String object, Locale locale) {
419
423
420
424
binder .bind (pvs );
421
425
assertTrue (binder .getBindingResult ().hasFieldErrors ("name" ));
426
+ assertEquals ("typeMismatch" , binder .getBindingResult ().getFieldError ("name" ).getCode ());
422
427
assertEquals ("test" , binder .getBindingResult ().getFieldValue ("name" ));
423
428
}
424
429
@@ -567,6 +572,7 @@ public void testBindingErrorWithCustomFormatter() {
567
572
assertEquals (new Float (0.0 ), tb .getMyFloat ());
568
573
assertEquals ("1x2" , binder .getBindingResult ().getFieldValue ("myFloat" ));
569
574
assertTrue (binder .getBindingResult ().hasFieldErrors ("myFloat" ));
575
+ assertEquals ("typeMismatch" , binder .getBindingResult ().getFieldError ("myFloat" ).getCode ());
570
576
}
571
577
finally {
572
578
LocaleContextHolder .resetLocaleContext ();
@@ -881,7 +887,6 @@ public void testCustomEditorForPrimitiveProperty() {
881
887
public void setAsText (String text ) throws IllegalArgumentException {
882
888
setValue (new Integer (99 ));
883
889
}
884
-
885
890
@ Override
886
891
public String getAsText () {
887
892
return "argh" ;
@@ -906,7 +911,6 @@ public void testCustomEditorForAllStringProperties() {
906
911
public void setAsText (String text ) throws IllegalArgumentException {
907
912
setValue ("prefix" + text );
908
913
}
909
-
910
914
@ Override
911
915
public String getAsText () {
912
916
return ((String ) getValue ()).substring (6 );
@@ -979,7 +983,6 @@ public void testCustomFormatterForPrimitiveProperty() {
979
983
public Integer parse (String text , Locale locale ) throws ParseException {
980
984
return 99 ;
981
985
}
982
-
983
986
@ Override
984
987
public String print (Integer object , Locale locale ) {
985
988
return "argh" ;
0 commit comments