Search in sources :

Example 91 with MutablePropertyValues

use of org.springframework.beans.MutablePropertyValues in project spring-framework by spring-projects.

the class JodaTimeFormattingTests method testBindInstantAnnotated.

@Test
public void testBindInstantAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("instantAnnotated", "2009-10-31T12:00:00.000Z");
    binder.bind(propertyValues);
    assertEquals(0, binder.getBindingResult().getErrorCount());
    assertEquals("2009-10-31T07:00:00.000-05:00", binder.getBindingResult().getFieldValue("instantAnnotated"));
}
Also used : MutablePropertyValues(org.springframework.beans.MutablePropertyValues) Test(org.junit.Test)

Example 92 with MutablePropertyValues

use of org.springframework.beans.MutablePropertyValues in project spring-framework by spring-projects.

the class DateFormattingTests method testBindDateAnnotated.

@Test
public void testBindDateAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateAnnotated", "10/31/09");
    binder.bind(propertyValues);
    assertEquals(0, binder.getBindingResult().getErrorCount());
    assertEquals("10/31/09", binder.getBindingResult().getFieldValue("dateAnnotated"));
}
Also used : MutablePropertyValues(org.springframework.beans.MutablePropertyValues) Test(org.junit.Test)

Example 93 with MutablePropertyValues

use of org.springframework.beans.MutablePropertyValues in project spring-framework by spring-projects.

the class DateFormattingTests method testBindDateAnnotatedWithFallbackError.

@Test
@Ignore
public void testBindDateAnnotatedWithFallbackError() {
    // TODO This currently passes because of the Date(String) constructor fallback is used
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateAnnotated", "Oct 031, 2009");
    binder.bind(propertyValues);
    assertEquals(1, binder.getBindingResult().getFieldErrorCount("dateAnnotated"));
    assertEquals("Oct 031, 2009", binder.getBindingResult().getFieldValue("dateAnnotated"));
}
Also used : MutablePropertyValues(org.springframework.beans.MutablePropertyValues) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 94 with MutablePropertyValues

use of org.springframework.beans.MutablePropertyValues in project spring-framework by spring-projects.

the class DateFormattingTests method testBindDateAnnotatedWithError.

@Test
public void testBindDateAnnotatedWithError() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateAnnotated", "Oct X31, 2009");
    binder.bind(propertyValues);
    assertEquals(1, binder.getBindingResult().getFieldErrorCount("dateAnnotated"));
    assertEquals("Oct X31, 2009", binder.getBindingResult().getFieldValue("dateAnnotated"));
}
Also used : MutablePropertyValues(org.springframework.beans.MutablePropertyValues) Test(org.junit.Test)

Example 95 with MutablePropertyValues

use of org.springframework.beans.MutablePropertyValues in project spring-framework by spring-projects.

the class DateFormattingTests method testBindCalendarAnnotated.

@Test
public void testBindCalendarAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("calendarAnnotated", "10/31/09");
    binder.bind(propertyValues);
    assertEquals(0, binder.getBindingResult().getErrorCount());
    assertEquals("10/31/09", binder.getBindingResult().getFieldValue("calendarAnnotated"));
}
Also used : MutablePropertyValues(org.springframework.beans.MutablePropertyValues) Test(org.junit.Test)

Aggregations

MutablePropertyValues (org.springframework.beans.MutablePropertyValues)305 Test (org.junit.Test)269 TestBean (org.springframework.tests.sample.beans.TestBean)86 ITestBean (org.springframework.tests.sample.beans.ITestBean)82 IndexedTestBean (org.springframework.tests.sample.beans.IndexedTestBean)73 DerivedTestBean (org.springframework.tests.sample.beans.DerivedTestBean)68 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)35 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)24 PropertyEditorSupport (java.beans.PropertyEditorSupport)23 PropertyValue (org.springframework.beans.PropertyValue)16 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)16 RuntimeBeanReference (org.springframework.beans.factory.config.RuntimeBeanReference)16 NestedTestBean (org.springframework.tests.sample.beans.NestedTestBean)15 ScannedGenericBeanDefinition (org.springframework.context.annotation.ScannedGenericBeanDefinition)14 HashMap (java.util.HashMap)13 BeanWrapper (org.springframework.beans.BeanWrapper)12 BeanWrapperImpl (org.springframework.beans.BeanWrapperImpl)11 ParseException (java.text.ParseException)9 RelaxedDataBinder (org.springframework.boot.bind.RelaxedDataBinder)9 BooleanTestBean (org.springframework.tests.sample.beans.BooleanTestBean)9