use of org.springframework.beans.MutablePropertyValues in project spring-framework by spring-projects.
the class PropertyResourceConfigurerIntegrationTests method testPropertyPlaceholderConfigurerWithNestedCircularReference.
@Test
public void testPropertyPlaceholderConfigurerWithNestedCircularReference() {
StaticApplicationContext ac = new StaticApplicationContext();
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("name", "name${var}");
ac.registerSingleton("tb1", TestBean.class, pvs);
pvs = new MutablePropertyValues();
pvs.add("properties", "var=${m}var\nm=${var2}\nvar2=${m}");
ac.registerSingleton("configurer1", PropertyPlaceholderConfigurer.class, pvs);
try {
ac.refresh();
fail("Should have thrown BeanDefinitionStoreException");
} catch (BeanDefinitionStoreException ex) {
// expected
}
}
use of org.springframework.beans.MutablePropertyValues in project spring-framework by spring-projects.
the class MoneyFormattingTests method testAmountWithNumberFormat1.
@Test
public void testAmountWithNumberFormat1() {
FormattedMoneyHolder1 bean = new FormattedMoneyHolder1();
DataBinder binder = new DataBinder(bean);
binder.setConversionService(conversionService);
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("amount", "$10.50");
binder.bind(propertyValues);
assertEquals(0, binder.getBindingResult().getErrorCount());
assertEquals("$10.50", binder.getBindingResult().getFieldValue("amount"));
assertTrue(bean.getAmount().getNumber().doubleValue() == 10.5d);
assertEquals("USD", bean.getAmount().getCurrency().getCurrencyCode());
LocaleContextHolder.setLocale(Locale.CANADA);
binder.bind(propertyValues);
LocaleContextHolder.setLocale(Locale.US);
assertEquals(0, binder.getBindingResult().getErrorCount());
assertEquals("$10.50", binder.getBindingResult().getFieldValue("amount"));
assertTrue(bean.getAmount().getNumber().doubleValue() == 10.5d);
assertEquals("CAD", bean.getAmount().getCurrency().getCurrencyCode());
}
use of org.springframework.beans.MutablePropertyValues in project spring-framework by spring-projects.
the class JodaTimeFormattingTests method testBindLocalTimeWithSpecificStyle.
@Test
public void testBindLocalTimeWithSpecificStyle() throws Exception {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
registrar.setTimeStyle("M");
setUp(registrar);
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localTime", "12:00:00 PM");
binder.bind(propertyValues);
assertEquals(0, binder.getBindingResult().getErrorCount());
assertEquals("12:00:00 PM", binder.getBindingResult().getFieldValue("localTime"));
}
use of org.springframework.beans.MutablePropertyValues in project spring-framework by spring-projects.
the class JodaTimeFormattingTests method testBindDateTime.
@Test
public void testBindDateTime() {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("dateTime", new DateTime(2009, 10, 31, 12, 0, ISOChronology.getInstanceUTC()));
binder.bind(propertyValues);
assertEquals(0, binder.getBindingResult().getErrorCount());
String value = binder.getBindingResult().getFieldValue("dateTime").toString();
assertTrue(value.startsWith("10/31/09"));
}
use of org.springframework.beans.MutablePropertyValues in project spring-framework by spring-projects.
the class JodaTimeFormattingTests method testBindLocalDateArray.
@Test
public void testBindLocalDateArray() {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localDate", new String[] { "10/31/09" });
binder.bind(propertyValues);
assertEquals(0, binder.getBindingResult().getErrorCount());
}
Aggregations