added chaining-capable "add" method to MutablePropertyValues
This commit is contained in:
@@ -51,13 +51,13 @@ public final class AutoProxyCreatorTests {
|
||||
sac.registerSingleton("testInterceptor", TestInterceptor.class);
|
||||
|
||||
RootBeanDefinition proxyCreator = new RootBeanDefinition(BeanNameAutoProxyCreator.class);
|
||||
proxyCreator.getPropertyValues().addPropertyValue("interceptorNames", "testInterceptor");
|
||||
proxyCreator.getPropertyValues().addPropertyValue("beanNames", "singletonToBeProxied,innerBean,singletonFactoryToBeProxied");
|
||||
proxyCreator.getPropertyValues().add("interceptorNames", "testInterceptor");
|
||||
proxyCreator.getPropertyValues().add("beanNames", "singletonToBeProxied,innerBean,singletonFactoryToBeProxied");
|
||||
sac.getDefaultListableBeanFactory().registerBeanDefinition("beanNameAutoProxyCreator", proxyCreator);
|
||||
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, RootBeanDefinition.AUTOWIRE_BY_TYPE);
|
||||
RootBeanDefinition innerBean = new RootBeanDefinition(TestBean.class);
|
||||
bd.getPropertyValues().addPropertyValue("spouse", new BeanDefinitionHolder(innerBean, "innerBean"));
|
||||
bd.getPropertyValues().add("spouse", new BeanDefinitionHolder(innerBean, "innerBean"));
|
||||
sac.getDefaultListableBeanFactory().registerBeanDefinition("singletonToBeProxied", bd);
|
||||
|
||||
sac.registerSingleton("singletonFactoryToBeProxied", DummyFactory.class);
|
||||
@@ -100,8 +100,8 @@ public final class AutoProxyCreatorTests {
|
||||
sac.registerSingleton("testInterceptor", TestInterceptor.class);
|
||||
|
||||
RootBeanDefinition proxyCreator = new RootBeanDefinition(BeanNameAutoProxyCreator.class);
|
||||
proxyCreator.getPropertyValues().addPropertyValue("interceptorNames", "testInterceptor");
|
||||
proxyCreator.getPropertyValues().addPropertyValue("beanNames", "singletonToBeProxied,&singletonFactoryToBeProxied");
|
||||
proxyCreator.getPropertyValues().add("interceptorNames", "testInterceptor");
|
||||
proxyCreator.getPropertyValues().add("beanNames", "singletonToBeProxied,&singletonFactoryToBeProxied");
|
||||
sac.getDefaultListableBeanFactory().registerBeanDefinition("beanNameAutoProxyCreator", proxyCreator);
|
||||
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
|
||||
@@ -182,7 +182,7 @@ public final class AutoProxyCreatorTests {
|
||||
sac.registerSingleton("testAutoProxyCreator", TestAutoProxyCreator.class);
|
||||
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("singleton", "false");
|
||||
pvs.add("singleton", "false");
|
||||
sac.registerSingleton("prototypeFactoryToBeProxied", DummyFactory.class, pvs);
|
||||
|
||||
sac.refresh();
|
||||
@@ -205,7 +205,7 @@ public final class AutoProxyCreatorTests {
|
||||
StaticApplicationContext sac = new StaticApplicationContext();
|
||||
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("proxyFactoryBean", "false");
|
||||
pvs.add("proxyFactoryBean", "false");
|
||||
sac.registerSingleton("testAutoProxyCreator", TestAutoProxyCreator.class, pvs);
|
||||
|
||||
sac.registerSingleton("singletonFactoryToBeProxied", DummyFactory.class);
|
||||
@@ -236,11 +236,11 @@ public final class AutoProxyCreatorTests {
|
||||
StaticApplicationContext sac = new StaticApplicationContext();
|
||||
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("proxyObject", "false");
|
||||
pvs.add("proxyObject", "false");
|
||||
sac.registerSingleton("testAutoProxyCreator", TestAutoProxyCreator.class, pvs);
|
||||
|
||||
pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("singleton", "false");
|
||||
pvs.add("singleton", "false");
|
||||
sac.registerSingleton("prototypeFactoryToBeProxied", DummyFactory.class, pvs);
|
||||
|
||||
sac.refresh();
|
||||
|
||||
@@ -763,7 +763,7 @@ public final class XmlBeanFactoryTests {
|
||||
XmlBeanFactory xbf = new XmlBeanFactory(AUTOWIRE_CONTEXT);
|
||||
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "kerry");
|
||||
pvs.add("name", "kerry");
|
||||
lbf.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class, pvs));
|
||||
xbf.setParentBeanFactory(lbf);
|
||||
doTestAutowire(xbf);
|
||||
|
||||
@@ -215,8 +215,8 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport {
|
||||
definition.setBeanClass(TestBean.class);
|
||||
|
||||
MutablePropertyValues mpvs = new MutablePropertyValues();
|
||||
mpvs.addPropertyValue("name", element.getAttribute("name"));
|
||||
mpvs.addPropertyValue("age", element.getAttribute("age"));
|
||||
mpvs.add("name", element.getAttribute("name"));
|
||||
mpvs.add("age", element.getAttribute("age"));
|
||||
definition.setPropertyValues(mpvs);
|
||||
|
||||
parserContext.getRegistry().registerBeanDefinition(element.getAttribute("id"), definition);
|
||||
@@ -244,8 +244,8 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport {
|
||||
BeanDefinition def = definition.getBeanDefinition();
|
||||
|
||||
MutablePropertyValues mpvs = (def.getPropertyValues() == null) ? new MutablePropertyValues() : def.getPropertyValues();
|
||||
mpvs.addPropertyValue("name", element.getAttribute("name"));
|
||||
mpvs.addPropertyValue("age", element.getAttribute("age"));
|
||||
mpvs.add("name", element.getAttribute("name"));
|
||||
mpvs.add("age", element.getAttribute("age"));
|
||||
|
||||
((AbstractBeanDefinition) def).setPropertyValues(mpvs);
|
||||
return definition;
|
||||
|
||||
@@ -80,7 +80,7 @@ public class AnnotationProcessorPerformanceTests {
|
||||
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(ResourceAnnotatedTestBean.class);
|
||||
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
|
||||
rbd.getPropertyValues().addPropertyValue("spouse", new RuntimeBeanReference("spouse"));
|
||||
rbd.getPropertyValues().add("spouse", new RuntimeBeanReference("spouse"));
|
||||
ctx.registerBeanDefinition("test", rbd);
|
||||
ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class));
|
||||
TestBean spouse = (TestBean) ctx.getBean("spouse");
|
||||
@@ -133,7 +133,7 @@ public class AnnotationProcessorPerformanceTests {
|
||||
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(AutowiredAnnotatedTestBean.class);
|
||||
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
|
||||
rbd.getPropertyValues().addPropertyValue("spouse", new RuntimeBeanReference("spouse"));
|
||||
rbd.getPropertyValues().add("spouse", new RuntimeBeanReference("spouse"));
|
||||
ctx.registerBeanDefinition("test", rbd);
|
||||
ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class));
|
||||
TestBean spouse = (TestBean) ctx.getBean("spouse");
|
||||
|
||||
@@ -264,7 +264,7 @@ public class CommonAnnotationBeanPostProcessorTests {
|
||||
|
||||
RootBeanDefinition annotatedBd = new RootBeanDefinition(ExtendedResourceInjectionBean.class);
|
||||
TestBean tb5 = new TestBean();
|
||||
annotatedBd.getPropertyValues().addPropertyValue("testBean2", tb5);
|
||||
annotatedBd.getPropertyValues().add("testBean2", tb5);
|
||||
bf.registerBeanDefinition("annotatedBean", annotatedBd);
|
||||
bf.registerBeanDefinition("annotatedBean2", new RootBeanDefinition(NamedResourceInjectionBean.class));
|
||||
TestBean tb = new TestBean();
|
||||
|
||||
@@ -131,7 +131,7 @@ public class ApplicationContextEventTests {
|
||||
public void innerBeanAsListener() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
RootBeanDefinition listenerDef = new RootBeanDefinition(TestBean.class);
|
||||
listenerDef.getPropertyValues().addPropertyValue("friends", new RootBeanDefinition(BeanThatListens.class));
|
||||
listenerDef.getPropertyValues().add("friends", new RootBeanDefinition(BeanThatListens.class));
|
||||
context.registerBeanDefinition("listener", listenerDef);
|
||||
context.refresh();
|
||||
context.publishEvent(new MyEvent(this));
|
||||
|
||||
@@ -98,7 +98,7 @@ public class EventPublicationInterceptorTests {
|
||||
|
||||
StaticApplicationContext ctx = new TestContext();
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("applicationEventClass", TestEvent.class.getName());
|
||||
pvs.add("applicationEventClass", TestEvent.class.getName());
|
||||
// should automatically receive applicationEventPublisher reference
|
||||
ctx.registerSingleton("publisher", EventPublicationInterceptor.class, pvs);
|
||||
ctx.registerSingleton("otherListener", FactoryBeanTestListener.class);
|
||||
|
||||
@@ -86,7 +86,7 @@ public class ApplicationContextExpressionTests {
|
||||
|
||||
GenericBeanDefinition bd0 = new GenericBeanDefinition();
|
||||
bd0.setBeanClass(TestBean.class);
|
||||
bd0.getPropertyValues().addPropertyValue("name", "myName");
|
||||
bd0.getPropertyValues().add("name", "myName");
|
||||
bd0.addQualifier(new AutowireCandidateQualifier(Qualifier.class, "original"));
|
||||
ac.registerBeanDefinition("tb0", bd0);
|
||||
|
||||
@@ -100,9 +100,9 @@ public class ApplicationContextExpressionTests {
|
||||
GenericBeanDefinition bd2 = new GenericBeanDefinition();
|
||||
bd2.setBeanClass(TestBean.class);
|
||||
bd2.setScope("myScope");
|
||||
bd2.getPropertyValues().addPropertyValue("name", "{ XXX#{tb0.name}YYY#{mySpecialAttr}ZZZ }");
|
||||
bd2.getPropertyValues().addPropertyValue("age", "#{mySpecialAttr}");
|
||||
bd2.getPropertyValues().addPropertyValue("country", "${code} #{systemProperties.country}");
|
||||
bd2.getPropertyValues().add("name", "{ XXX#{tb0.name}YYY#{mySpecialAttr}ZZZ }");
|
||||
bd2.getPropertyValues().add("age", "#{mySpecialAttr}");
|
||||
bd2.getPropertyValues().add("country", "${code} #{systemProperties.country}");
|
||||
ac.registerBeanDefinition("tb2", bd2);
|
||||
|
||||
GenericBeanDefinition bd3 = new GenericBeanDefinition();
|
||||
@@ -179,8 +179,8 @@ public class ApplicationContextExpressionTests {
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(ac);
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(PrototypeTestBean.class);
|
||||
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
|
||||
rbd.getPropertyValues().addPropertyValue("country", "#{systemProperties.country}");
|
||||
rbd.getPropertyValues().addPropertyValue("country2", new TypedStringValue("#{systemProperties.country}"));
|
||||
rbd.getPropertyValues().add("country", "#{systemProperties.country}");
|
||||
rbd.getPropertyValues().add("country2", new TypedStringValue("#{systemProperties.country}"));
|
||||
ac.registerBeanDefinition("test", rbd);
|
||||
ac.refresh();
|
||||
|
||||
@@ -215,7 +215,7 @@ public class ApplicationContextExpressionTests {
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
|
||||
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
|
||||
rbd.getConstructorArgumentValues().addGenericArgumentValue("#{systemProperties.name}");
|
||||
rbd.getPropertyValues().addPropertyValue("country", "#{systemProperties.country}");
|
||||
rbd.getPropertyValues().add("country", "#{systemProperties.country}");
|
||||
ac.registerBeanDefinition("test", rbd);
|
||||
ac.refresh();
|
||||
StopWatch sw = new StopWatch();
|
||||
@@ -246,7 +246,7 @@ public class ApplicationContextExpressionTests {
|
||||
|
||||
GenericBeanDefinition bd = new GenericBeanDefinition();
|
||||
bd.setBeanClass(TestBean.class);
|
||||
bd.getPropertyValues().addPropertyValue("country", "#{systemProperties.country}");
|
||||
bd.getPropertyValues().add("country", "#{systemProperties.country}");
|
||||
ac.registerBeanDefinition("tb", bd);
|
||||
|
||||
SecurityManager oldSecurityManager = System.getSecurityManager();
|
||||
|
||||
@@ -72,10 +72,10 @@ public class BeanFactoryPostProcessorTests {
|
||||
ac.registerSingleton("tb1", TestBean.class);
|
||||
ac.registerSingleton("tb2", TestBean.class);
|
||||
MutablePropertyValues pvs1 = new MutablePropertyValues();
|
||||
pvs1.addPropertyValue("initValue", "${key}");
|
||||
pvs1.add("initValue", "${key}");
|
||||
ac.registerSingleton("bfpp1", TestBeanFactoryPostProcessor.class, pvs1);
|
||||
MutablePropertyValues pvs2 = new MutablePropertyValues();
|
||||
pvs2.addPropertyValue("properties", "key=value");
|
||||
pvs2.add("properties", "key=value");
|
||||
ac.registerSingleton("bfpp2", PropertyPlaceholderConfigurer.class, pvs2);
|
||||
ac.refresh();
|
||||
TestBeanFactoryPostProcessor bfpp = (TestBeanFactoryPostProcessor) ac.getBean("bfpp1");
|
||||
|
||||
@@ -48,10 +48,10 @@ public class PropertyResourceConfigurerIntegrationTests {
|
||||
public void testPropertyPlaceholderConfigurerWithSystemPropertyInLocation() {
|
||||
StaticApplicationContext ac = new StaticApplicationContext();
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("spouse", new RuntimeBeanReference("${ref}"));
|
||||
pvs.add("spouse", new RuntimeBeanReference("${ref}"));
|
||||
ac.registerSingleton("tb", TestBean.class, pvs);
|
||||
pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("location", "${user.dir}/test");
|
||||
pvs.add("location", "${user.dir}/test");
|
||||
ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
|
||||
try {
|
||||
ac.refresh();
|
||||
@@ -73,10 +73,10 @@ public class PropertyResourceConfigurerIntegrationTests {
|
||||
public void testPropertyPlaceholderConfigurerWithSystemPropertiesInLocation() {
|
||||
StaticApplicationContext ac = new StaticApplicationContext();
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("spouse", new RuntimeBeanReference("${ref}"));
|
||||
pvs.add("spouse", new RuntimeBeanReference("${ref}"));
|
||||
ac.registerSingleton("tb", TestBean.class, pvs);
|
||||
pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("location", "${user.dir}/test/${user.dir}");
|
||||
pvs.add("location", "${user.dir}/test/${user.dir}");
|
||||
ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
|
||||
try {
|
||||
ac.refresh();
|
||||
@@ -102,10 +102,10 @@ public class PropertyResourceConfigurerIntegrationTests {
|
||||
public void testPropertyPlaceholderConfigurerWithUnresolvableSystemPropertiesInLocation() {
|
||||
StaticApplicationContext ac = new StaticApplicationContext();
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("spouse", new RuntimeBeanReference("${ref}"));
|
||||
pvs.add("spouse", new RuntimeBeanReference("${ref}"));
|
||||
ac.registerSingleton("tb", TestBean.class, pvs);
|
||||
pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("location", "${myprop}/test/${myprop}");
|
||||
pvs.add("location", "${myprop}/test/${myprop}");
|
||||
ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
|
||||
try {
|
||||
ac.refresh();
|
||||
@@ -121,10 +121,10 @@ public class PropertyResourceConfigurerIntegrationTests {
|
||||
public void testPropertyPlaceholderConfigurerWithMultiLevelCircularReference() {
|
||||
StaticApplicationContext ac = new StaticApplicationContext();
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "name${var}");
|
||||
pvs.add("name", "name${var}");
|
||||
ac.registerSingleton("tb1", TestBean.class, pvs);
|
||||
pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("properties", "var=${m}var\nm=${var2}\nvar2=${var}");
|
||||
pvs.add("properties", "var=${m}var\nm=${var2}\nvar2=${var}");
|
||||
ac.registerSingleton("configurer1", PropertyPlaceholderConfigurer.class, pvs);
|
||||
try {
|
||||
ac.refresh();
|
||||
@@ -139,10 +139,10 @@ public class PropertyResourceConfigurerIntegrationTests {
|
||||
public void testPropertyPlaceholderConfigurerWithNestedCircularReference() {
|
||||
StaticApplicationContext ac = new StaticApplicationContext();
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "name${var}");
|
||||
pvs.add("name", "name${var}");
|
||||
ac.registerSingleton("tb1", TestBean.class, pvs);
|
||||
pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("properties", "var=${m}var\nm=${var2}\nvar2=${m}");
|
||||
pvs.add("properties", "var=${m}var\nm=${var2}\nvar2=${m}");
|
||||
ac.registerSingleton("configurer1", PropertyPlaceholderConfigurer.class, pvs);
|
||||
try {
|
||||
ac.refresh();
|
||||
|
||||
@@ -90,15 +90,15 @@ public class ResourceBundleMessageSourceTests extends TestCase {
|
||||
basepath + "messages",
|
||||
basepath + "more-messages"};
|
||||
}
|
||||
pvs.addPropertyValue("basenames", basenames);
|
||||
pvs.add("basenames", basenames);
|
||||
if (!fallbackToSystemLocale) {
|
||||
pvs.addPropertyValue("fallbackToSystemLocale", Boolean.FALSE);
|
||||
pvs.add("fallbackToSystemLocale", Boolean.FALSE);
|
||||
}
|
||||
if (useCodeAsDefaultMessage) {
|
||||
pvs.addPropertyValue("useCodeAsDefaultMessage", Boolean.TRUE);
|
||||
pvs.add("useCodeAsDefaultMessage", Boolean.TRUE);
|
||||
}
|
||||
if (alwaysUseMessageFormat) {
|
||||
pvs.addPropertyValue("alwaysUseMessageFormat", Boolean.TRUE);
|
||||
pvs.add("alwaysUseMessageFormat", Boolean.TRUE);
|
||||
}
|
||||
Class clazz = reloadable ?
|
||||
(Class) ReloadableResourceBundleMessageSource.class : ResourceBundleMessageSource.class;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindLocalDate() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("localDate", "10/31/09");
|
||||
propertyValues.add("localDate", "10/31/09");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("10/31/09", binder.getBindingResult().getFieldValue("localDate"));
|
||||
@@ -67,7 +67,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindLocalDateArray() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("localDate", new String[] { "10/31/09" });
|
||||
propertyValues.add("localDate", new String[] { "10/31/09" });
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindLocalDateAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("localDateAnnotated", "Oct 31, 2009");
|
||||
propertyValues.add("localDateAnnotated", "Oct 31, 2009");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("Oct 31, 2009", binder.getBindingResult().getFieldValue("localDateAnnotated"));
|
||||
@@ -84,7 +84,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindLocalTime() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("localTime", "12:00 PM");
|
||||
propertyValues.add("localTime", "12:00 PM");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("12:00 PM", binder.getBindingResult().getFieldValue("localTime"));
|
||||
@@ -93,7 +93,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindLocalTimeAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("localTimeAnnotated", "12:00:00 PM");
|
||||
propertyValues.add("localTimeAnnotated", "12:00:00 PM");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("12:00:00 PM", binder.getBindingResult().getFieldValue("localTimeAnnotated"));
|
||||
@@ -102,7 +102,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindLocalDateTime() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("localDateTime", "10/31/09 12:00 PM");
|
||||
propertyValues.add("localDateTime", "10/31/09 12:00 PM");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("10/31/09 12:00 PM", binder.getBindingResult().getFieldValue("localDateTime"));
|
||||
@@ -111,7 +111,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindLocalDateTimeAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("localDateTimeAnnotated", "Saturday, October 31, 2009 12:00:00 PM ");
|
||||
propertyValues.add("localDateTimeAnnotated", "Saturday, October 31, 2009 12:00:00 PM ");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("Saturday, October 31, 2009 12:00:00 PM ", binder.getBindingResult().getFieldValue(
|
||||
@@ -121,7 +121,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindDateTime() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("dateTime", "10/31/09 12:00 PM");
|
||||
propertyValues.add("dateTime", "10/31/09 12:00 PM");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("10/31/09 12:00 PM", binder.getBindingResult().getFieldValue("dateTime"));
|
||||
@@ -130,7 +130,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindDateTimeAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("dateTimeAnnotated", "Oct 31, 2009 12:00 PM");
|
||||
propertyValues.add("dateTimeAnnotated", "Oct 31, 2009 12:00 PM");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("Oct 31, 2009 12:00 PM", binder.getBindingResult().getFieldValue("dateTimeAnnotated"));
|
||||
@@ -139,7 +139,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindDateTimeAnnotatedPattern() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("dateTimeAnnotatedPattern", "10/31/09 12:00 PM");
|
||||
propertyValues.add("dateTimeAnnotatedPattern", "10/31/09 12:00 PM");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("10/31/09 12:00 PM", binder.getBindingResult().getFieldValue("dateTimeAnnotatedPattern"));
|
||||
@@ -148,7 +148,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindDateTimeAnnotatedDefault() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("dateTimeAnnotatedDefault", "10/31/09 12:00 PM");
|
||||
propertyValues.add("dateTimeAnnotatedDefault", "10/31/09 12:00 PM");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("10/31/09 12:00 PM", binder.getBindingResult().getFieldValue("dateTimeAnnotatedDefault"));
|
||||
@@ -157,7 +157,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindDate() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("date", "10/31/09 12:00 PM");
|
||||
propertyValues.add("date", "10/31/09 12:00 PM");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("10/31/09 12:00 PM", binder.getBindingResult().getFieldValue("date"));
|
||||
@@ -166,7 +166,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindDateAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("dateAnnotated", "10/31/09");
|
||||
propertyValues.add("dateAnnotated", "10/31/09");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("10/31/09", binder.getBindingResult().getFieldValue("dateAnnotated"));
|
||||
@@ -175,7 +175,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindCalendar() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("calendar", "10/31/09 12:00 PM");
|
||||
propertyValues.add("calendar", "10/31/09 12:00 PM");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("10/31/09 12:00 PM", binder.getBindingResult().getFieldValue("calendar"));
|
||||
@@ -184,7 +184,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindCalendarAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("calendarAnnotated", "10/31/09");
|
||||
propertyValues.add("calendarAnnotated", "10/31/09");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("10/31/09", binder.getBindingResult().getFieldValue("calendarAnnotated"));
|
||||
@@ -193,7 +193,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindLong() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("millis", "1256961600");
|
||||
propertyValues.add("millis", "1256961600");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("1256961600", binder.getBindingResult().getFieldValue("millis"));
|
||||
@@ -202,7 +202,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindLongAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("millisAnnotated", "10/31/09");
|
||||
propertyValues.add("millisAnnotated", "10/31/09");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("10/31/09", binder.getBindingResult().getFieldValue("millisAnnotated"));
|
||||
@@ -211,7 +211,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindISODate() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("isoDate", "2009-10-31");
|
||||
propertyValues.add("isoDate", "2009-10-31");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("2009-10-31", binder.getBindingResult().getFieldValue("isoDate"));
|
||||
@@ -220,7 +220,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindISOTime() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("isoTime", "12:00:00.000-05:00");
|
||||
propertyValues.add("isoTime", "12:00:00.000-05:00");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("12:00:00.000", binder.getBindingResult().getFieldValue("isoTime"));
|
||||
@@ -229,7 +229,7 @@ public class JodaTimeFormattingTests {
|
||||
@Test
|
||||
public void testBindISODateTime() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("isoDateTime", "2009-10-31T12:00:00.000Z");
|
||||
propertyValues.add("isoDateTime", "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("isoDateTime"));
|
||||
|
||||
@@ -38,7 +38,7 @@ public class NumberFormattingTests {
|
||||
@Test
|
||||
public void testDefaultNumberFormatting() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("numberDefault", "3,339.12");
|
||||
propertyValues.add("numberDefault", "3,339.12");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("3,339", binder.getBindingResult().getFieldValue("numberDefault"));
|
||||
@@ -47,7 +47,7 @@ public class NumberFormattingTests {
|
||||
@Test
|
||||
public void testDefaultNumberFormattingAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("numberDefaultAnnotated", "3,339.12");
|
||||
propertyValues.add("numberDefaultAnnotated", "3,339.12");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("3,339.12", binder.getBindingResult().getFieldValue("numberDefaultAnnotated"));
|
||||
@@ -56,7 +56,7 @@ public class NumberFormattingTests {
|
||||
@Test
|
||||
public void testCurrencyFormatting() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("currency", "$3,339.12");
|
||||
propertyValues.add("currency", "$3,339.12");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("$3,339.12", binder.getBindingResult().getFieldValue("currency"));
|
||||
@@ -65,7 +65,7 @@ public class NumberFormattingTests {
|
||||
@Test
|
||||
public void testPercentFormatting() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("percent", "53%");
|
||||
propertyValues.add("percent", "53%");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("53%", binder.getBindingResult().getFieldValue("percent"));
|
||||
@@ -74,7 +74,7 @@ public class NumberFormattingTests {
|
||||
@Test
|
||||
public void testPatternFormatting() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.addPropertyValue("pattern", "1,25.00");
|
||||
propertyValues.add("pattern", "1,25.00");
|
||||
binder.bind(propertyValues);
|
||||
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||
assertEquals("1,25.00", binder.getBindingResult().getFieldValue("pattern"));
|
||||
|
||||
@@ -72,7 +72,7 @@ public class AsyncAnnotationBeanPostProcessorTests {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setThreadNamePrefix("testExecutor");
|
||||
executor.afterPropertiesSet();
|
||||
processorDefinition.getPropertyValues().addPropertyValue("executor", executor);
|
||||
processorDefinition.getPropertyValues().add("executor", executor);
|
||||
BeanDefinition targetDefinition = new RootBeanDefinition(AsyncAnnotationBeanPostProcessorTests.TestBean.class);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
context.registerBeanDefinition("target", targetDefinition);
|
||||
|
||||
@@ -59,9 +59,9 @@ public class DataBinderTests extends TestCase {
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
assertTrue(binder.isIgnoreUnknownFields());
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "Rod");
|
||||
pvs.addPropertyValue("age", "032");
|
||||
pvs.addPropertyValue("nonExisting", "someValue");
|
||||
pvs.add("name", "Rod");
|
||||
pvs.add("age", "032");
|
||||
pvs.add("nonExisting", "someValue");
|
||||
|
||||
binder.bind(pvs);
|
||||
binder.close();
|
||||
@@ -92,8 +92,8 @@ public class DataBinderTests extends TestCase {
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
assertTrue(binder.isIgnoreUnknownFields());
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "Rod");
|
||||
pvs.addPropertyValue("jedi", "on");
|
||||
pvs.add("name", "Rod");
|
||||
pvs.add("jedi", "on");
|
||||
|
||||
binder.bind(pvs);
|
||||
binder.close();
|
||||
@@ -107,8 +107,8 @@ public class DataBinderTests extends TestCase {
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
assertTrue(binder.isIgnoreUnknownFields());
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("spouse.name", "Kerry");
|
||||
pvs.addPropertyValue("spouse.jedi", "on");
|
||||
pvs.add("spouse.name", "Kerry");
|
||||
pvs.add("spouse.jedi", "on");
|
||||
|
||||
binder.bind(pvs);
|
||||
binder.close();
|
||||
@@ -122,9 +122,9 @@ public class DataBinderTests extends TestCase {
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
binder.setIgnoreUnknownFields(false);
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "Rod");
|
||||
pvs.addPropertyValue("age", new Integer(32));
|
||||
pvs.addPropertyValue("nonExisting", "someValue");
|
||||
pvs.add("name", "Rod");
|
||||
pvs.add("age", new Integer(32));
|
||||
pvs.add("nonExisting", "someValue");
|
||||
|
||||
try {
|
||||
binder.bind(pvs);
|
||||
@@ -139,8 +139,8 @@ public class DataBinderTests extends TestCase {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "Rod");
|
||||
pvs.addPropertyValue("spouse.age", new Integer(32));
|
||||
pvs.add("name", "Rod");
|
||||
pvs.add("spouse.age", new Integer(32));
|
||||
|
||||
try {
|
||||
binder.bind(pvs);
|
||||
@@ -156,8 +156,8 @@ public class DataBinderTests extends TestCase {
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
binder.setIgnoreInvalidFields(true);
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "Rod");
|
||||
pvs.addPropertyValue("spouse.age", new Integer(32));
|
||||
pvs.add("name", "Rod");
|
||||
pvs.add("spouse.age", new Integer(32));
|
||||
|
||||
binder.bind(pvs);
|
||||
}
|
||||
@@ -166,9 +166,9 @@ public class DataBinderTests extends TestCase {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "Rod");
|
||||
pvs.addPropertyValue("age", "32x");
|
||||
pvs.addPropertyValue("touchy", "m.y");
|
||||
pvs.add("name", "Rod");
|
||||
pvs.add("age", "32x");
|
||||
pvs.add("touchy", "m.y");
|
||||
binder.bind(pvs);
|
||||
|
||||
try {
|
||||
@@ -215,9 +215,9 @@ public class DataBinderTests extends TestCase {
|
||||
rod = new TestBean();
|
||||
binder = new DataBinder(rod, "person");
|
||||
pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "Rod");
|
||||
pvs.addPropertyValue("age", "32x");
|
||||
pvs.addPropertyValue("touchy", "m.y");
|
||||
pvs.add("name", "Rod");
|
||||
pvs.add("age", "32x");
|
||||
pvs.add("touchy", "m.y");
|
||||
binder.bind(pvs);
|
||||
assertEquals(binder.getBindingResult(), ex.getBindingResult());
|
||||
}
|
||||
@@ -243,10 +243,10 @@ public class DataBinderTests extends TestCase {
|
||||
}
|
||||
});
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "Rod");
|
||||
pvs.addPropertyValue("age", "32x");
|
||||
pvs.addPropertyValue("touchy", "m.y");
|
||||
pvs.addPropertyValue("spouse", "Kerry");
|
||||
pvs.add("name", "Rod");
|
||||
pvs.add("age", "32x");
|
||||
pvs.add("touchy", "m.y");
|
||||
pvs.add("spouse", "Kerry");
|
||||
binder.bind(pvs);
|
||||
|
||||
try {
|
||||
@@ -290,7 +290,7 @@ public class DataBinderTests extends TestCase {
|
||||
DataBinder binder = new DataBinder(tb);
|
||||
binder.registerCustomEditor(Integer.class, "object", new CustomNumberEditor(Integer.class, true));
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("object", "1");
|
||||
pvs.add("object", "1");
|
||||
binder.bind(pvs);
|
||||
assertEquals(new Integer(1), tb.getObject());
|
||||
}
|
||||
@@ -302,7 +302,7 @@ public class DataBinderTests extends TestCase {
|
||||
conversionService.addFormatterForFieldType(Float.class, new NumberFormatter());
|
||||
binder.setConversionService(conversionService);
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("myFloat", "1,2");
|
||||
pvs.add("myFloat", "1,2");
|
||||
|
||||
LocaleContextHolder.setLocale(Locale.GERMAN);
|
||||
try {
|
||||
@@ -330,8 +330,8 @@ public class DataBinderTests extends TestCase {
|
||||
DataBinder binder = new DataBinder(rod);
|
||||
binder.setAllowedFields(new String[] {"name", "myparam"});
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "Rod");
|
||||
pvs.addPropertyValue("age", "32x");
|
||||
pvs.add("name", "Rod");
|
||||
pvs.add("age", "32x");
|
||||
|
||||
binder.bind(pvs);
|
||||
binder.close();
|
||||
@@ -344,8 +344,8 @@ public class DataBinderTests extends TestCase {
|
||||
DataBinder binder = new DataBinder(rod);
|
||||
binder.setDisallowedFields(new String[] {"age"});
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "Rod");
|
||||
pvs.addPropertyValue("age", "32x");
|
||||
pvs.add("name", "Rod");
|
||||
pvs.add("age", "32x");
|
||||
|
||||
binder.bind(pvs);
|
||||
binder.close();
|
||||
@@ -362,8 +362,8 @@ public class DataBinderTests extends TestCase {
|
||||
binder.setAllowedFields(new String[] {"name", "myparam"});
|
||||
binder.setDisallowedFields(new String[] {"age"});
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "Rod");
|
||||
pvs.addPropertyValue("age", "32x");
|
||||
pvs.add("name", "Rod");
|
||||
pvs.add("age", "32x");
|
||||
|
||||
binder.bind(pvs);
|
||||
binder.close();
|
||||
@@ -380,8 +380,8 @@ public class DataBinderTests extends TestCase {
|
||||
binder.setAllowedFields(new String[] {"name", "age"});
|
||||
binder.setDisallowedFields(new String[] {"age"});
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "Rod");
|
||||
pvs.addPropertyValue("age", "32x");
|
||||
pvs.add("name", "Rod");
|
||||
pvs.add("age", "32x");
|
||||
|
||||
binder.bind(pvs);
|
||||
binder.close();
|
||||
@@ -398,9 +398,9 @@ public class DataBinderTests extends TestCase {
|
||||
binder.setAllowedFields(new String[] {"nam*", "*ouchy"});
|
||||
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "Rod");
|
||||
pvs.addPropertyValue("touchy", "Rod");
|
||||
pvs.addPropertyValue("age", "32x");
|
||||
pvs.add("name", "Rod");
|
||||
pvs.add("touchy", "Rod");
|
||||
pvs.add("age", "32x");
|
||||
|
||||
binder.bind(pvs);
|
||||
binder.close();
|
||||
@@ -425,10 +425,10 @@ public class DataBinderTests extends TestCase {
|
||||
binder.setDisallowedFields(new String[] {"someMap['key3']", "someMap[key4]"});
|
||||
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("someMap[key1]", "value1");
|
||||
pvs.addPropertyValue("someMap['key2']", "value2");
|
||||
pvs.addPropertyValue("someMap[key3]", "value3");
|
||||
pvs.addPropertyValue("someMap['key4']", "value4");
|
||||
pvs.add("someMap[key1]", "value1");
|
||||
pvs.add("someMap['key2']", "value2");
|
||||
pvs.add("someMap[key3]", "value3");
|
||||
pvs.add("someMap['key4']", "value4");
|
||||
|
||||
binder.bind(pvs);
|
||||
binder.close();
|
||||
@@ -453,10 +453,10 @@ public class DataBinderTests extends TestCase {
|
||||
binder.setRequiredFields(new String[] {"touchy", "name", "age", "date", "spouse.name"});
|
||||
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("touchy", "");
|
||||
pvs.addPropertyValue("name", null);
|
||||
pvs.addPropertyValue("age", null);
|
||||
pvs.addPropertyValue("spouse.name", " ");
|
||||
pvs.add("touchy", "");
|
||||
pvs.add("name", null);
|
||||
pvs.add("age", null);
|
||||
pvs.add("spouse.name", " ");
|
||||
|
||||
binder.bind(pvs);
|
||||
|
||||
@@ -483,9 +483,9 @@ public class DataBinderTests extends TestCase {
|
||||
binder.setRequiredFields(new String[] {"someMap[key1]", "someMap[key2]", "someMap['key3']", "someMap[key4]"});
|
||||
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("someMap[key1]", "value1");
|
||||
pvs.addPropertyValue("someMap['key2']", "value2");
|
||||
pvs.addPropertyValue("someMap[key3]", "value3");
|
||||
pvs.add("someMap[key1]", "value1");
|
||||
pvs.add("someMap['key2']", "value2");
|
||||
pvs.add("someMap[key3]", "value3");
|
||||
|
||||
binder.bind(pvs);
|
||||
|
||||
@@ -505,8 +505,8 @@ public class DataBinderTests extends TestCase {
|
||||
});
|
||||
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("spouse", "someValue");
|
||||
pvs.addPropertyValue("spouse.name", "test");
|
||||
pvs.add("spouse", "someValue");
|
||||
pvs.add("spouse.name", "test");
|
||||
binder.bind(pvs);
|
||||
|
||||
assertNotNull(tb.getSpouse());
|
||||
@@ -528,9 +528,9 @@ public class DataBinderTests extends TestCase {
|
||||
});
|
||||
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "value");
|
||||
pvs.addPropertyValue("touchy", "value");
|
||||
pvs.addPropertyValue("spouse.name", "sue");
|
||||
pvs.add("name", "value");
|
||||
pvs.add("touchy", "value");
|
||||
pvs.add("spouse.name", "sue");
|
||||
binder.bind(pvs);
|
||||
|
||||
binder.getBindingResult().rejectValue("name", "someCode", "someMessage");
|
||||
@@ -564,7 +564,7 @@ public class DataBinderTests extends TestCase {
|
||||
});
|
||||
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("age", "");
|
||||
pvs.add("age", "");
|
||||
binder.bind(pvs);
|
||||
|
||||
assertEquals("argh", binder.getBindingResult().getFieldValue("age"));
|
||||
@@ -585,8 +585,8 @@ public class DataBinderTests extends TestCase {
|
||||
});
|
||||
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "value");
|
||||
pvs.addPropertyValue("touchy", "value");
|
||||
pvs.add("name", "value");
|
||||
pvs.add("touchy", "value");
|
||||
binder.bind(pvs);
|
||||
|
||||
binder.getBindingResult().rejectValue("name", "someCode", "someMessage");
|
||||
@@ -613,12 +613,12 @@ public class DataBinderTests extends TestCase {
|
||||
});
|
||||
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "value");
|
||||
pvs.add("name", "value");
|
||||
binder.bind(pvs);
|
||||
assertEquals("value", tb.getName());
|
||||
|
||||
pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("name", "vaLue");
|
||||
pvs.add("name", "vaLue");
|
||||
binder.bind(pvs);
|
||||
assertEquals("value", tb.getName());
|
||||
}
|
||||
@@ -638,7 +638,7 @@ public class DataBinderTests extends TestCase {
|
||||
tb.setSpouse(tb2);
|
||||
DataBinder db = new DataBinder(tb, "tb");
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("spouse.age", "argh");
|
||||
pvs.add("spouse.age", "argh");
|
||||
db.bind(pvs);
|
||||
Errors errors = db.getBindingResult();
|
||||
Validator testValidator = new TestBeanValidator();
|
||||
@@ -865,7 +865,7 @@ public class DataBinderTests extends TestCase {
|
||||
}
|
||||
});
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("set", new String[] {"10", "20", "30"});
|
||||
pvs.add("set", new String[] {"10", "20", "30"});
|
||||
binder.bind(pvs);
|
||||
|
||||
assertEquals(tb.getSet(), binder.getBindingResult().getFieldValue("set"));
|
||||
@@ -876,7 +876,7 @@ public class DataBinderTests extends TestCase {
|
||||
assertTrue(tb.getSet().contains(new Integer(30)));
|
||||
|
||||
pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("set", null);
|
||||
pvs.add("set", null);
|
||||
binder.bind(pvs);
|
||||
|
||||
assertNull(tb.getSet());
|
||||
@@ -887,7 +887,7 @@ public class DataBinderTests extends TestCase {
|
||||
DataBinder binder = new DataBinder(tb, "tb");
|
||||
binder.registerCustomEditor(Set.class, new CustomCollectionEditor(TreeSet.class, true));
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("set", null);
|
||||
pvs.add("set", null);
|
||||
binder.bind(pvs);
|
||||
|
||||
assertTrue(tb.getSet() instanceof TreeSet);
|
||||
@@ -903,7 +903,7 @@ public class DataBinderTests extends TestCase {
|
||||
}
|
||||
});
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("array[0]", "a");
|
||||
pvs.add("array[0]", "a");
|
||||
binder.bind(pvs);
|
||||
Errors errors = binder.getBindingResult();
|
||||
errors.rejectValue("array[0].name", "NOT_ROD", "are you sure you're not Rod?");
|
||||
@@ -942,7 +942,7 @@ public class DataBinderTests extends TestCase {
|
||||
}
|
||||
});
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("array[0].nestedIndexedBean.list[0].name", "a");
|
||||
pvs.add("array[0].nestedIndexedBean.list[0].name", "a");
|
||||
binder.bind(pvs);
|
||||
Errors errors = binder.getBindingResult();
|
||||
errors.rejectValue("array[0].nestedIndexedBean.list[0].name", "NOT_ROD", "are you sure you're not Rod?");
|
||||
@@ -981,8 +981,8 @@ public class DataBinderTests extends TestCase {
|
||||
}
|
||||
});
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("array[0].nestedIndexedBean.list[0].name", "test1");
|
||||
pvs.addPropertyValue("array[1].nestedIndexedBean.list[1].name", "test2");
|
||||
pvs.add("array[0].nestedIndexedBean.list[0].name", "test1");
|
||||
pvs.add("array[1].nestedIndexedBean.list[1].name", "test2");
|
||||
binder.bind(pvs);
|
||||
assertEquals("listtest1", ((TestBean) tb.getArray()[0].getNestedIndexedBean().getList().get(0)).getName());
|
||||
assertEquals("listtest2", ((TestBean) tb.getArray()[1].getNestedIndexedBean().getList().get(1)).getName());
|
||||
@@ -1004,8 +1004,8 @@ public class DataBinderTests extends TestCase {
|
||||
}
|
||||
});
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("array[0].nestedIndexedBean.list[0].name", "test1");
|
||||
pvs.addPropertyValue("array[1].nestedIndexedBean.list[1].name", "test2");
|
||||
pvs.add("array[0].nestedIndexedBean.list[0].name", "test1");
|
||||
pvs.add("array[1].nestedIndexedBean.list[1].name", "test2");
|
||||
binder.bind(pvs);
|
||||
assertEquals("listtest1", ((TestBean) tb.getArray()[0].getNestedIndexedBean().getList().get(0)).getName());
|
||||
assertEquals("test2", ((TestBean) tb.getArray()[1].getNestedIndexedBean().getList().get(1)).getName());
|
||||
@@ -1027,8 +1027,8 @@ public class DataBinderTests extends TestCase {
|
||||
}
|
||||
});
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("array[0].nestedIndexedBean.list[0].name", "test1");
|
||||
pvs.addPropertyValue("array[1].nestedIndexedBean.list[1].name", "test2");
|
||||
pvs.add("array[0].nestedIndexedBean.list[0].name", "test1");
|
||||
pvs.add("array[1].nestedIndexedBean.list[1].name", "test2");
|
||||
binder.bind(pvs);
|
||||
assertEquals("listtest1", ((TestBean) tb.getArray()[0].getNestedIndexedBean().getList().get(0)).getName());
|
||||
assertEquals("test2", ((TestBean) tb.getArray()[1].getNestedIndexedBean().getList().get(1)).getName());
|
||||
@@ -1050,7 +1050,7 @@ public class DataBinderTests extends TestCase {
|
||||
}
|
||||
});
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("array[0]", "a");
|
||||
pvs.add("array[0]", "a");
|
||||
binder.bind(pvs);
|
||||
Errors errors = binder.getBindingResult();
|
||||
errors.rejectValue("array[0]", "NOT_ROD", "are you sure you're not Rod?");
|
||||
@@ -1156,7 +1156,7 @@ public class DataBinderTests extends TestCase {
|
||||
}
|
||||
});
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("array[0]", "a");
|
||||
pvs.add("array[0]", "a");
|
||||
binder.bind(pvs);
|
||||
Errors errors = binder.getBindingResult();
|
||||
errors.rejectValue("array[0]", "NOT_ROD", "are you sure you're not Rod?");
|
||||
@@ -1182,7 +1182,7 @@ public class DataBinderTests extends TestCase {
|
||||
}
|
||||
});
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("stringArray", "a1-b2");
|
||||
pvs.add("stringArray", "a1-b2");
|
||||
binder.bind(pvs);
|
||||
assertTrue(!binder.getBindingResult().hasErrors());
|
||||
assertEquals(2, tb.getStringArray().length);
|
||||
@@ -1199,7 +1199,7 @@ public class DataBinderTests extends TestCase {
|
||||
}
|
||||
});
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("stringArray", new String[] {"a1", "b2"});
|
||||
pvs.add("stringArray", new String[] {"a1", "b2"});
|
||||
binder.bind(pvs);
|
||||
assertTrue(!binder.getBindingResult().hasErrors());
|
||||
assertEquals(2, tb.getStringArray().length);
|
||||
@@ -1211,7 +1211,7 @@ public class DataBinderTests extends TestCase {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("age", "32x");
|
||||
pvs.add("age", "32x");
|
||||
binder.bind(pvs);
|
||||
Errors errors = binder.getBindingResult();
|
||||
FieldError ageError = errors.getFieldError("age");
|
||||
@@ -1237,7 +1237,7 @@ public class DataBinderTests extends TestCase {
|
||||
TestBean rod = new TestBean();
|
||||
DataBinder binder = new DataBinder(rod, "person");
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("age", "32x");
|
||||
pvs.add("age", "32x");
|
||||
binder.bind(pvs);
|
||||
Errors errors = binder.getBindingResult();
|
||||
|
||||
@@ -1257,8 +1257,8 @@ public class DataBinderTests extends TestCase {
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
TestBean tb1 = new TestBean("tb1", 99);
|
||||
TestBean tb2 = new TestBean("tb2", 99);
|
||||
pvs.addPropertyValue("list[0]", tb1);
|
||||
pvs.addPropertyValue("list[1]", tb2);
|
||||
pvs.add("list[0]", tb1);
|
||||
pvs.add("list[1]", tb2);
|
||||
binder.bind(pvs);
|
||||
assertEquals(tb1.getName(), binder.getBindingResult().getFieldValue("list[0].name"));
|
||||
assertEquals(tb2.getName(), binder.getBindingResult().getFieldValue("list[1].name"));
|
||||
@@ -1322,8 +1322,8 @@ public class DataBinderTests extends TestCase {
|
||||
String beanName = "foobar";
|
||||
|
||||
MutablePropertyValues mpvs = new MutablePropertyValues();
|
||||
mpvs.addPropertyValue("name", name);
|
||||
mpvs.addPropertyValue("beanName", beanName);
|
||||
mpvs.add("name", name);
|
||||
mpvs.add("beanName", beanName);
|
||||
|
||||
binder.bind(mpvs);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user