From d3d763457410275573a95d75401d4796542920d4 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 18 Jan 2011 21:39:08 +0000 Subject: [PATCH] added tests with error in BindingResult (SPR-7809) --- .../joda/JodaTimeFormattingTests.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/org.springframework.context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java b/org.springframework.context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java index 44d324e567a..b27b2996656 100644 --- a/org.springframework.context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java +++ b/org.springframework.context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java @@ -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 { 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 { 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();