Search in sources :

Example 81 with MutablePropertyValues

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

the class JodaTimeFormattingTests method testBindISODate.

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

Example 82 with MutablePropertyValues

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

the class JodaTimeFormattingTests method testBindDateWithoutErrorFallingBackToDateConstructor.

@Test
public void testBindDateWithoutErrorFallingBackToDateConstructor() {
    DataBinder binder = new DataBinder(new JodaTimeBean());
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("date", "Sat, 12 Aug 1995 13:30:00 GMT");
    binder.bind(propertyValues);
    assertEquals(0, binder.getBindingResult().getErrorCount());
}
Also used : MutablePropertyValues(org.springframework.beans.MutablePropertyValues) DataBinder(org.springframework.validation.DataBinder) Test(org.junit.Test)

Example 83 with MutablePropertyValues

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

the class JodaTimeFormattingTests method testBindDateTimeWithSpecificFormatter.

@Test
public void testBindDateTimeWithSpecificFormatter() throws Exception {
    JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
    registrar.setDateTimeFormatter(org.joda.time.format.DateTimeFormat.forPattern("yyyyMMddHHmmss"));
    setUp(registrar);
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateTime", "20091031130000");
    binder.bind(propertyValues);
    assertEquals(0, binder.getBindingResult().getErrorCount());
    assertEquals("20091031130000", binder.getBindingResult().getFieldValue("dateTime"));
}
Also used : MutablePropertyValues(org.springframework.beans.MutablePropertyValues) Test(org.junit.Test)

Example 84 with MutablePropertyValues

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

the class JodaTimeFormattingTests method testBindYearMonth.

@Test
public void testBindYearMonth() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("yearMonth", "2007-12");
    binder.bind(propertyValues);
    assertEquals(0, binder.getBindingResult().getErrorCount());
    assertTrue(binder.getBindingResult().getFieldValue("yearMonth").toString().equals("2007-12"));
}
Also used : MutablePropertyValues(org.springframework.beans.MutablePropertyValues) Test(org.junit.Test)

Example 85 with MutablePropertyValues

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

the class JodaTimeFormattingTests method testBindNestedLocalDateAnnotated.

@Test
public void testBindNestedLocalDateAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("children[0].localDateAnnotated", "Oct 31, 2009");
    binder.bind(propertyValues);
    assertEquals(0, binder.getBindingResult().getErrorCount());
    assertEquals("Oct 31, 2009", binder.getBindingResult().getFieldValue("children[0].localDateAnnotated"));
}
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