@@ -227,12 +227,14 @@ public void testBindingWithErrors() throws Exception {
227
227
228
228
assertTrue ("Has age errors" , br .hasFieldErrors ("age" ));
229
229
assertTrue ("Correct number of age errors" , br .getFieldErrorCount ("age" ) == 1 );
230
+ assertEquals ("typeMismatch" , binder .getBindingResult ().getFieldError ("age" ).getCode ());
230
231
assertEquals ("32x" , binder .getBindingResult ().getFieldValue ("age" ));
231
232
assertEquals ("32x" , binder .getBindingResult ().getFieldError ("age" ).getRejectedValue ());
232
233
assertEquals (0 , tb .getAge ());
233
234
234
235
assertTrue ("Has touchy errors" , br .hasFieldErrors ("touchy" ));
235
236
assertTrue ("Correct number of touchy errors" , br .getFieldErrorCount ("touchy" ) == 1 );
237
+ assertEquals ("methodInvocation" , binder .getBindingResult ().getFieldError ("touchy" ).getCode ());
236
238
assertEquals ("m.y" , binder .getBindingResult ().getFieldValue ("touchy" ));
237
239
assertEquals ("m.y" , binder .getBindingResult ().getFieldError ("touchy" ).getRejectedValue ());
238
240
assertNull (tb .getTouchy ());
@@ -316,12 +318,14 @@ public String getAsText() {
316
318
317
319
assertTrue ("Has age errors" , br .hasFieldErrors ("age" ));
318
320
assertTrue ("Correct number of age errors" , br .getFieldErrorCount ("age" ) == 1 );
321
+ assertEquals ("typeMismatch" , binder .getBindingResult ().getFieldError ("age" ).getCode ());
319
322
assertEquals ("32x" , binder .getBindingResult ().getFieldValue ("age" ));
320
323
assertEquals ("32x" , binder .getBindingResult ().getFieldError ("age" ).getRejectedValue ());
321
324
assertEquals (0 , tb .getAge ());
322
325
323
326
assertTrue ("Has touchy errors" , br .hasFieldErrors ("touchy" ));
324
327
assertTrue ("Correct number of touchy errors" , br .getFieldErrorCount ("touchy" ) == 1 );
328
+ assertEquals ("methodInvocation" , binder .getBindingResult ().getFieldError ("touchy" ).getCode ());
325
329
assertEquals ("m.y" , binder .getBindingResult ().getFieldValue ("touchy" ));
326
330
assertEquals ("m.y" , binder .getBindingResult ().getFieldError ("touchy" ).getRejectedValue ());
327
331
assertNull (tb .getTouchy ());
@@ -420,6 +424,7 @@ public String print(String object, Locale locale) {
420
424
421
425
binder .bind (pvs );
422
426
assertTrue (binder .getBindingResult ().hasFieldErrors ("name" ));
427
+ assertEquals ("typeMismatch" , binder .getBindingResult ().getFieldError ("name" ).getCode ());
423
428
assertEquals ("test" , binder .getBindingResult ().getFieldValue ("name" ));
424
429
}
425
430
@@ -568,6 +573,7 @@ public void testBindingErrorWithCustomFormatter() {
568
573
assertEquals (new Float (0.0 ), tb .getMyFloat ());
569
574
assertEquals ("1x2" , binder .getBindingResult ().getFieldValue ("myFloat" ));
570
575
assertTrue (binder .getBindingResult ().hasFieldErrors ("myFloat" ));
576
+ assertEquals ("typeMismatch" , binder .getBindingResult ().getFieldError ("myFloat" ).getCode ());
571
577
}
572
578
finally {
573
579
LocaleContextHolder .resetLocaleContext ();
@@ -882,7 +888,6 @@ public void testCustomEditorForPrimitiveProperty() {
882
888
public void setAsText (String text ) throws IllegalArgumentException {
883
889
setValue (new Integer (99 ));
884
890
}
885
-
886
891
@ Override
887
892
public String getAsText () {
888
893
return "argh" ;
@@ -907,7 +912,6 @@ public void testCustomEditorForAllStringProperties() {
907
912
public void setAsText (String text ) throws IllegalArgumentException {
908
913
setValue ("prefix" + text );
909
914
}
910
-
911
915
@ Override
912
916
public String getAsText () {
913
917
return ((String ) getValue ()).substring (6 );
@@ -980,7 +984,6 @@ public void testCustomFormatterForPrimitiveProperty() {
980
984
public Integer parse (String text , Locale locale ) throws ParseException {
981
985
return 99 ;
982
986
}
983
-
984
987
@ Override
985
988
public String print (Integer object , Locale locale ) {
986
989
return "argh" ;
0 commit comments