Browse Source

added tests with error in BindingResult (SPR-7809)

pull/7/head
Juergen Hoeller 14 years ago
parent
commit
d3d7634574
  1. 21
      org.springframework.context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java

21
org.springframework.context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2011 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.
@ -108,6 +108,15 @@ public class JodaTimeFormattingTests { @@ -108,6 +108,15 @@ public class JodaTimeFormattingTests {
assertEquals("Oct 31, 2009", binder.getBindingResult().getFieldValue("localDateAnnotated"));
}
@Test
public void testBindLocalDateAnnotatedWithError() {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localDateAnnotated", "Oct 031, 2009");
binder.bind(propertyValues);
assertEquals(1, binder.getBindingResult().getFieldErrorCount("localDateAnnotated"));
assertEquals("Oct 031, 2009", binder.getBindingResult().getFieldValue("localDateAnnotated"));
}
@Test
public void testBindNestedLocalDateAnnotated() {
MutablePropertyValues propertyValues = new MutablePropertyValues();
@ -127,6 +136,16 @@ public class JodaTimeFormattingTests { @@ -127,6 +136,16 @@ public class JodaTimeFormattingTests {
assertEquals("Oct 31, 2009", binder.getBindingResult().getFieldValue("localDateAnnotated"));
}
@Test
public void testBindLocalDateAnnotatedWithDirectFieldAccessAndError() {
binder.initDirectFieldAccess();
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localDateAnnotated", "Oct 031, 2009");
binder.bind(propertyValues);
assertEquals(1, binder.getBindingResult().getFieldErrorCount("localDateAnnotated"));
assertEquals("Oct 031, 2009", binder.getBindingResult().getFieldValue("localDateAnnotated"));
}
@Test
public void testBindLocalTime() {
MutablePropertyValues propertyValues = new MutablePropertyValues();

Loading…
Cancel
Save