Search in sources :

Example 66 with MutablePropertyValues

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

the class JodaTimeFormattingTests method testBindLocalDateWithSpecificStyle.

@Test
public void testBindLocalDateWithSpecificStyle() throws Exception {
    JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
    registrar.setDateStyle("L");
    setUp(registrar);
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDate", "October 31, 2009");
    binder.bind(propertyValues);
    assertEquals(0, binder.getBindingResult().getErrorCount());
    assertEquals("October 31, 2009", binder.getBindingResult().getFieldValue("localDate"));
}
Also used : MutablePropertyValues(org.springframework.beans.MutablePropertyValues) Test(org.junit.Test)

Example 67 with MutablePropertyValues

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

the class JodaTimeFormattingTests method testBindDateTimeAnnotatedDefault.

@Test
public void testBindDateTimeAnnotatedDefault() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateTimeAnnotatedDefault", new DateTime(2009, 10, 31, 12, 0, ISOChronology.getInstanceUTC()));
    binder.bind(propertyValues);
    assertEquals(0, binder.getBindingResult().getErrorCount());
    String value = binder.getBindingResult().getFieldValue("dateTimeAnnotatedDefault").toString();
    assertTrue(value.startsWith("10/31/09"));
}
Also used : MutablePropertyValues(org.springframework.beans.MutablePropertyValues) DateTime(org.joda.time.DateTime) LocalDateTime(org.joda.time.LocalDateTime) Test(org.junit.Test)

Example 68 with MutablePropertyValues

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

the class DateTimeFormattingTests method testBindLocalDateTimeAnnotated.

@Test
public void testBindLocalDateTimeAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDateTimeAnnotated", LocalDateTime.of(2009, 10, 31, 12, 0));
    binder.bind(propertyValues);
    assertEquals(0, binder.getBindingResult().getErrorCount());
    String value = binder.getBindingResult().getFieldValue("localDateTimeAnnotated").toString();
    assertTrue(value.startsWith("Oct 31, 2009"));
    assertTrue(value.endsWith("12:00:00 PM"));
}
Also used : MutablePropertyValues(org.springframework.beans.MutablePropertyValues) Test(org.junit.Test)

Example 69 with MutablePropertyValues

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

the class DateTimeFormattingTests method testBindISOTimeWithZone.

@Test
public void testBindISOTimeWithZone() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("isoTime", "12:00:00.000-05:00");
    binder.bind(propertyValues);
    assertEquals(0, binder.getBindingResult().getErrorCount());
    assertEquals("12:00:00", binder.getBindingResult().getFieldValue("isoTime"));
}
Also used : MutablePropertyValues(org.springframework.beans.MutablePropertyValues) Test(org.junit.Test)

Example 70 with MutablePropertyValues

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

the class DateTimeFormattingTests method testBindISODateTime.

@Test
public void testBindISODateTime() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("isoDateTime", "2009-10-31T12:00:00");
    binder.bind(propertyValues);
    assertEquals(0, binder.getBindingResult().getErrorCount());
    assertEquals("2009-10-31T12:00:00", binder.getBindingResult().getFieldValue("isoDateTime"));
}
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