Search in sources :

Example 86 with MutablePropertyValues

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

the class JodaTimeFormattingTests method testBindLocalTimeWithSpecificFormatter.

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

Example 87 with MutablePropertyValues

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

the class JodaTimeFormattingTests method testBindMutableDateTimeAnnotated.

@Test
public void testBindMutableDateTimeAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("mutableDateTimeAnnotated", "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("mutableDateTimeAnnotated"));
}
Also used : MutablePropertyValues(org.springframework.beans.MutablePropertyValues) Test(org.junit.Test)

Example 88 with MutablePropertyValues

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

the class JodaTimeFormattingTests method testBindDuration.

@Test
public void testBindDuration() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("duration", "PT72.345S");
    binder.bind(propertyValues);
    assertEquals(0, binder.getBindingResult().getErrorCount());
    assertTrue(binder.getBindingResult().getFieldValue("duration").toString().equals("PT72.345S"));
}
Also used : MutablePropertyValues(org.springframework.beans.MutablePropertyValues) Test(org.junit.Test)

Example 89 with MutablePropertyValues

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

the class JodaTimeFormattingTests method testBindLocalTime.

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

Example 90 with MutablePropertyValues

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

the class JodaTimeFormattingTests method testBindLong.

@Test
public void testBindLong() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("millis", "1256961600");
    binder.bind(propertyValues);
    assertEquals(0, binder.getBindingResult().getErrorCount());
    assertEquals("1256961600", binder.getBindingResult().getFieldValue("millis"));
}
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