Moved tests from testsuite to beans
This commit is contained in:
@@ -22,7 +22,7 @@ import org.springframework.beans.TestBean;
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class CountingFactory implements FactoryBean {
|
||||
|
||||
|
||||
private static int factoryBeanInstanceCount = 0;
|
||||
|
||||
|
||||
@@ -61,4 +61,4 @@ public class CountingFactory implements FactoryBean {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.beans.factory.xml;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.springframework.beans.TestBean;
|
||||
import org.springframework.beans.factory.CountingFactory;
|
||||
@@ -40,7 +41,7 @@ public class AutowireWithExclusionTests extends TestCase {
|
||||
TestBean rob = (TestBean) beanFactory.getBean("rob");
|
||||
TestBean sally = (TestBean) beanFactory.getBean("sally");
|
||||
assertEquals(sally, rob.getSpouse());
|
||||
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
Assert.assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
}
|
||||
|
||||
public void testByTypeAutowireWithExclusion() throws Exception {
|
||||
@@ -49,7 +50,7 @@ public class AutowireWithExclusionTests extends TestCase {
|
||||
beanFactory.preInstantiateSingletons();
|
||||
TestBean rob = (TestBean) beanFactory.getBean("rob");
|
||||
assertEquals("props1", rob.getSomeProperties().getProperty("name"));
|
||||
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
Assert.assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
}
|
||||
|
||||
public void testByTypeAutowireWithExclusionInParentFactory() throws Exception {
|
||||
@@ -62,7 +63,7 @@ public class AutowireWithExclusionTests extends TestCase {
|
||||
child.registerBeanDefinition("rob2", robDef);
|
||||
TestBean rob = (TestBean) child.getBean("rob2");
|
||||
assertEquals("props1", rob.getSomeProperties().getProperty("name"));
|
||||
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
Assert.assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
}
|
||||
|
||||
public void testByTypeAutowireWithPrimaryInParentFactory() throws Exception {
|
||||
@@ -79,7 +80,7 @@ public class AutowireWithExclusionTests extends TestCase {
|
||||
child.registerBeanDefinition("props3", propsDef);
|
||||
TestBean rob = (TestBean) child.getBean("rob2");
|
||||
assertEquals("props1", rob.getSomeProperties().getProperty("name"));
|
||||
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
Assert.assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
}
|
||||
|
||||
public void testByTypeAutowireWithPrimaryOverridingParentFactory() throws Exception {
|
||||
@@ -96,7 +97,7 @@ public class AutowireWithExclusionTests extends TestCase {
|
||||
child.registerBeanDefinition("props3", propsDef);
|
||||
TestBean rob = (TestBean) child.getBean("rob2");
|
||||
assertEquals("props3", rob.getSomeProperties().getProperty("name"));
|
||||
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
Assert.assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
}
|
||||
|
||||
public void testByTypeAutowireWithInclusion() throws Exception {
|
||||
@@ -105,7 +106,7 @@ public class AutowireWithExclusionTests extends TestCase {
|
||||
beanFactory.preInstantiateSingletons();
|
||||
TestBean rob = (TestBean) beanFactory.getBean("rob");
|
||||
assertEquals("props1", rob.getSomeProperties().getProperty("name"));
|
||||
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
Assert.assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
}
|
||||
|
||||
public void testByTypeAutowireWithSelectiveInclusion() throws Exception {
|
||||
@@ -114,7 +115,7 @@ public class AutowireWithExclusionTests extends TestCase {
|
||||
beanFactory.preInstantiateSingletons();
|
||||
TestBean rob = (TestBean) beanFactory.getBean("rob");
|
||||
assertEquals("props1", rob.getSomeProperties().getProperty("name"));
|
||||
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
Assert.assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
}
|
||||
|
||||
public void testConstructorAutowireWithAutoSelfExclusion() throws Exception {
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.beans.factory.xml;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class BeanNameGenerationTests extends TestCase {
|
||||
|
||||
private DefaultListableBeanFactory beanFactory;
|
||||
|
||||
public void setUp() {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
|
||||
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
|
||||
reader.loadBeanDefinitions(new ClassPathResource("beanNameGeneration.xml", getClass()));
|
||||
}
|
||||
|
||||
public void testNaming() {
|
||||
String className = GeneratedNameBean.class.getName();
|
||||
|
||||
String targetName = className + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + "0";
|
||||
GeneratedNameBean topLevel1 = (GeneratedNameBean) beanFactory.getBean(targetName);
|
||||
assertNotNull(topLevel1);
|
||||
|
||||
targetName = className + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + "1";
|
||||
GeneratedNameBean topLevel2 = (GeneratedNameBean) beanFactory.getBean(targetName);
|
||||
assertNotNull(topLevel2);
|
||||
|
||||
GeneratedNameBean child1 = topLevel1.getChild();
|
||||
assertNotNull(child1.getBeanName());
|
||||
assertTrue(child1.getBeanName().startsWith(className));
|
||||
|
||||
GeneratedNameBean child2 = topLevel2.getChild();
|
||||
assertNotNull(child2.getBeanName());
|
||||
assertTrue(child2.getBeanName().startsWith(className));
|
||||
|
||||
assertFalse(child1.getBeanName().equals(child2.getBeanName()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.beans.factory.xml;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.beans.TestBean;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReader;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
/**
|
||||
* Unit and integration tests for the collection merging support.
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Rick Evans
|
||||
*/
|
||||
public class CollectionMergingTests extends TestCase {
|
||||
|
||||
private DefaultListableBeanFactory beanFactory;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
BeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
|
||||
reader.loadBeanDefinitions(new ClassPathResource("collectionMerging.xml", getClass()));
|
||||
}
|
||||
|
||||
public void testMergeList() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithList");
|
||||
List list = bean.getSomeList();
|
||||
assertEquals("Incorrect size", 3, list.size());
|
||||
assertEquals(list.get(0), "Rob Harrop");
|
||||
assertEquals(list.get(1), "Rod Johnson");
|
||||
assertEquals(list.get(2), "Juergen Hoeller");
|
||||
}
|
||||
|
||||
public void testMergeListWithInnerBeanAsListElement() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithListOfRefs");
|
||||
List list = bean.getSomeList();
|
||||
assertNotNull(list);
|
||||
assertEquals(3, list.size());
|
||||
assertNotNull(list.get(2));
|
||||
assertTrue(list.get(2) instanceof TestBean);
|
||||
}
|
||||
|
||||
public void testMergeSet() {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithSet");
|
||||
Set set = bean.getSomeSet();
|
||||
assertEquals("Incorrect size", 2, set.size());
|
||||
assertTrue(set.contains("Rob Harrop"));
|
||||
assertTrue(set.contains("Sally Greenwood"));
|
||||
}
|
||||
|
||||
public void testMergeSetWithInnerBeanAsSetElement() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithSetOfRefs");
|
||||
Set set = bean.getSomeSet();
|
||||
assertNotNull(set);
|
||||
assertEquals(2, set.size());
|
||||
Iterator it = set.iterator();
|
||||
it.next();
|
||||
Object o = it.next();
|
||||
assertNotNull(o);
|
||||
assertTrue(o instanceof TestBean);
|
||||
assertEquals("Sally", ((TestBean) o).getName());
|
||||
}
|
||||
|
||||
public void testMergeMap() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMap");
|
||||
Map map = bean.getSomeMap();
|
||||
assertEquals("Incorrect size", 3, map.size());
|
||||
assertEquals(map.get("Rob"), "Sally");
|
||||
assertEquals(map.get("Rod"), "Kerry");
|
||||
assertEquals(map.get("Juergen"), "Eva");
|
||||
}
|
||||
|
||||
public void testMergeMapWithInnerBeanAsMapEntryValue() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMapOfRefs");
|
||||
Map map = bean.getSomeMap();
|
||||
assertNotNull(map);
|
||||
assertEquals(2, map.size());
|
||||
assertNotNull(map.get("Rob"));
|
||||
assertTrue(map.get("Rob") instanceof TestBean);
|
||||
assertEquals("Sally", ((TestBean) map.get("Rob")).getName());
|
||||
}
|
||||
|
||||
public void testMergeProperties() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithProps");
|
||||
Properties props = bean.getSomeProperties();
|
||||
assertEquals("Incorrect size", 3, props.size());
|
||||
assertEquals(props.getProperty("Rob"), "Sally");
|
||||
assertEquals(props.getProperty("Rod"), "Kerry");
|
||||
assertEquals(props.getProperty("Juergen"), "Eva");
|
||||
}
|
||||
|
||||
|
||||
public void testMergeListInConstructor() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithListInConstructor");
|
||||
List list = bean.getSomeList();
|
||||
assertEquals("Incorrect size", 3, list.size());
|
||||
assertEquals(list.get(0), "Rob Harrop");
|
||||
assertEquals(list.get(1), "Rod Johnson");
|
||||
assertEquals(list.get(2), "Juergen Hoeller");
|
||||
}
|
||||
|
||||
public void testMergeListWithInnerBeanAsListElementInConstructor() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithListOfRefsInConstructor");
|
||||
List list = bean.getSomeList();
|
||||
assertNotNull(list);
|
||||
assertEquals(3, list.size());
|
||||
assertNotNull(list.get(2));
|
||||
assertTrue(list.get(2) instanceof TestBean);
|
||||
}
|
||||
|
||||
public void testMergeSetInConstructor() {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithSetInConstructor");
|
||||
Set set = bean.getSomeSet();
|
||||
assertEquals("Incorrect size", 2, set.size());
|
||||
assertTrue(set.contains("Rob Harrop"));
|
||||
assertTrue(set.contains("Sally Greenwood"));
|
||||
}
|
||||
|
||||
public void testMergeSetWithInnerBeanAsSetElementInConstructor() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithSetOfRefsInConstructor");
|
||||
Set set = bean.getSomeSet();
|
||||
assertNotNull(set);
|
||||
assertEquals(2, set.size());
|
||||
Iterator it = set.iterator();
|
||||
it.next();
|
||||
Object o = it.next();
|
||||
assertNotNull(o);
|
||||
assertTrue(o instanceof TestBean);
|
||||
assertEquals("Sally", ((TestBean) o).getName());
|
||||
}
|
||||
|
||||
public void testMergeMapInConstructor() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMapInConstructor");
|
||||
Map map = bean.getSomeMap();
|
||||
assertEquals("Incorrect size", 3, map.size());
|
||||
assertEquals(map.get("Rob"), "Sally");
|
||||
assertEquals(map.get("Rod"), "Kerry");
|
||||
assertEquals(map.get("Juergen"), "Eva");
|
||||
}
|
||||
|
||||
public void testMergeMapWithInnerBeanAsMapEntryValueInConstructor() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMapOfRefsInConstructor");
|
||||
Map map = bean.getSomeMap();
|
||||
assertNotNull(map);
|
||||
assertEquals(2, map.size());
|
||||
assertNotNull(map.get("Rob"));
|
||||
assertTrue(map.get("Rob") instanceof TestBean);
|
||||
assertEquals("Sally", ((TestBean) map.get("Rob")).getName());
|
||||
}
|
||||
|
||||
public void testMergePropertiesInConstructor() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithPropsInConstructor");
|
||||
Properties props = bean.getSomeProperties();
|
||||
assertEquals("Incorrect size", 3, props.size());
|
||||
assertEquals(props.getProperty("Rob"), "Sally");
|
||||
assertEquals(props.getProperty("Rod"), "Kerry");
|
||||
assertEquals(props.getProperty("Juergen"), "Eva");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package org.springframework.beans.factory.xml;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.beans.TestBean;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
*/
|
||||
public class CollectionsWithDefaultTypesTests extends TestCase {
|
||||
|
||||
private XmlBeanFactory beanFactory;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
this.beanFactory = new XmlBeanFactory(new ClassPathResource("collectionsWithDefaultTypes.xml", getClass()));
|
||||
}
|
||||
|
||||
public void testListHasDefaultType() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("testBean");
|
||||
List list = bean.getSomeList();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object o = list.get(i);
|
||||
assertEquals("Value type is incorrect", Integer.class, o.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
public void testSetHasDefaultType() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("testBean");
|
||||
Set set = bean.getSomeSet();
|
||||
Iterator iterator = set.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Object o = iterator.next();
|
||||
assertEquals("Value type is incorrect", Integer.class, o.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
public void testMapHasDefaultKeyAndValueType() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("testBean");
|
||||
assertMap(bean.getSomeMap());
|
||||
}
|
||||
|
||||
public void testMapWithNestedElementsHasDefaultKeyAndValueType() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("testBean2");
|
||||
assertMap(bean.getSomeMap());
|
||||
}
|
||||
|
||||
private void assertMap(Map map) {
|
||||
for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry) iterator.next();
|
||||
assertEquals("Key type is incorrect", Integer.class, entry.getKey().getClass());
|
||||
assertEquals("Value type is incorrect", Boolean.class, entry.getValue().getClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.beans.factory.xml;
|
||||
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
*/
|
||||
public class GeneratedNameBean implements BeanNameAware {
|
||||
|
||||
private String beanName;
|
||||
|
||||
private GeneratedNameBean child;
|
||||
|
||||
public void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
public String getBeanName() {
|
||||
return beanName;
|
||||
}
|
||||
|
||||
public void setChild(GeneratedNameBean child) {
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public GeneratedNameBean getChild() {
|
||||
return child;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
|
||||
|
||||
<beans>
|
||||
|
||||
<bean class="org.springframework.beans.factory.xml.GeneratedNameBean">
|
||||
<property name="child">
|
||||
<bean class="org.springframework.beans.factory.xml.GeneratedNameBean"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean class="org.springframework.beans.factory.xml.GeneratedNameBean">
|
||||
<property name="child">
|
||||
<bean class="org.springframework.beans.factory.xml.GeneratedNameBean"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,205 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="parentWithList" class="org.springframework.beans.TestBean">
|
||||
<property name="someList">
|
||||
<list>
|
||||
<value>Rob Harrop</value>
|
||||
<value>Rod Johnson</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="childWithList" parent="parentWithList">
|
||||
<property name="someList">
|
||||
<list merge="true">
|
||||
<value>Juergen Hoeller</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="childWithListOfRefs" parent="parentWithList">
|
||||
<property name="someList">
|
||||
<list merge="true">
|
||||
<bean class="org.springframework.beans.TestBean"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="parentWithSet" class="org.springframework.beans.TestBean">
|
||||
<property name="someSet">
|
||||
<set>
|
||||
<value>Rob Harrop</value>
|
||||
</set>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="childWithSet" parent="parentWithSet">
|
||||
<property name="someSet">
|
||||
<set merge="true">
|
||||
<value>Sally Greenwood</value>
|
||||
</set>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="childWithSetOfRefs" parent="parentWithSet">
|
||||
<property name="someSet">
|
||||
<set merge="true">
|
||||
<bean class="org.springframework.beans.TestBean">
|
||||
<property name="name" value="Sally"/>
|
||||
</bean>
|
||||
</set>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="parentWithMap" class="org.springframework.beans.TestBean">
|
||||
<property name="someMap">
|
||||
<map>
|
||||
<entry key="Rob" value="Sall"/>
|
||||
<entry key="Juergen" value="Eva"/>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="childWithMap" parent="parentWithMap">
|
||||
<property name="someMap">
|
||||
<map merge="true">
|
||||
<entry key="Rod" value="Kerry"/>
|
||||
<entry key="Rob" value="Sally"/>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="childWithMapOfRefs" parent="parentWithMap">
|
||||
<property name="someMap">
|
||||
<map merge="true">
|
||||
<entry key="Rob">
|
||||
<bean class="org.springframework.beans.TestBean">
|
||||
<property name="name" value="Sally"/>
|
||||
</bean>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="parentWithProps" class="org.springframework.beans.TestBean">
|
||||
<property name="someProperties">
|
||||
<props>
|
||||
<prop key="Rob">Sall</prop>
|
||||
<prop key="Rod">Kerry</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="childWithProps" parent="parentWithProps">
|
||||
<property name="someProperties">
|
||||
<props merge="true">
|
||||
<prop key="Juergen">Eva</prop>
|
||||
<prop key="Rob">Sally</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="parentWithListInConstructor" class="org.springframework.beans.TestBean">
|
||||
<constructor-arg index="0">
|
||||
<list>
|
||||
<value>Rob Harrop</value>
|
||||
<value>Rod Johnson</value>
|
||||
</list>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="childWithListInConstructor" parent="parentWithListInConstructor">
|
||||
<constructor-arg index="0">
|
||||
<list merge="true">
|
||||
<value>Juergen Hoeller</value>
|
||||
</list>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="childWithListOfRefsInConstructor" parent="parentWithListInConstructor">
|
||||
<constructor-arg index="0">
|
||||
<list merge="true">
|
||||
<bean class="org.springframework.beans.TestBean"/>
|
||||
</list>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="parentWithSetInConstructor" class="org.springframework.beans.TestBean">
|
||||
<constructor-arg index="0">
|
||||
<set>
|
||||
<value>Rob Harrop</value>
|
||||
</set>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="childWithSetInConstructor" parent="parentWithSetInConstructor">
|
||||
<constructor-arg index="0">
|
||||
<set merge="true">
|
||||
<value>Sally Greenwood</value>
|
||||
</set>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="childWithSetOfRefsInConstructor" parent="parentWithSetInConstructor">
|
||||
<constructor-arg index="0">
|
||||
<set merge="true">
|
||||
<bean class="org.springframework.beans.TestBean">
|
||||
<property name="name" value="Sally"/>
|
||||
</bean>
|
||||
</set>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="parentWithMapInConstructor" class="org.springframework.beans.TestBean">
|
||||
<constructor-arg index="0">
|
||||
<map>
|
||||
<entry key="Rob" value="Sall"/>
|
||||
<entry key="Juergen" value="Eva"/>
|
||||
</map>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="childWithMapInConstructor" parent="parentWithMapInConstructor">
|
||||
<constructor-arg index="0">
|
||||
<map merge="true">
|
||||
<entry key="Rod" value="Kerry"/>
|
||||
<entry key="Rob" value="Sally"/>
|
||||
</map>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="childWithMapOfRefsInConstructor" parent="parentWithMapInConstructor">
|
||||
<constructor-arg index="0">
|
||||
<map merge="true">
|
||||
<entry key="Rob">
|
||||
<bean class="org.springframework.beans.TestBean">
|
||||
<property name="name" value="Sally"/>
|
||||
</bean>
|
||||
</entry>
|
||||
</map>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="parentWithPropsInConstructor" class="org.springframework.beans.TestBean">
|
||||
<constructor-arg index="0">
|
||||
<props>
|
||||
<prop key="Rob">Sall</prop>
|
||||
<prop key="Rod">Kerry</prop>
|
||||
</props>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="childWithPropsInConstructor" parent="parentWithPropsInConstructor">
|
||||
<constructor-arg index="0">
|
||||
<props merge="true">
|
||||
<prop key="Juergen">Eva</prop>
|
||||
<prop key="Rob">Sally</prop>
|
||||
</props>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
|
||||
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
|
||||
|
||||
<beans>
|
||||
<bean id="testBean" class="org.springframework.beans.TestBean">
|
||||
<property name="someList">
|
||||
<list value-type="java.lang.Integer">
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>3</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="someSet">
|
||||
<set value-type="java.lang.Integer">
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>3</value>
|
||||
</set>
|
||||
</property>
|
||||
<property name="someMap">
|
||||
<map key-type="java.lang.Integer" value-type="java.lang.Boolean">
|
||||
<entry key="1" value="true"/>
|
||||
<entry key="2" value="false"/>
|
||||
<entry key="3" value="false"/>
|
||||
<entry key="4" value="true"/>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="testBean2" class="org.springframework.beans.TestBean">
|
||||
<property name="someMap">
|
||||
<map key-type="java.lang.Integer" value-type="java.lang.Boolean">
|
||||
<entry>
|
||||
<key>
|
||||
<value>1</value>
|
||||
</key>
|
||||
<value>true</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>
|
||||
<value>2</value>
|
||||
</key>
|
||||
<value>false</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>
|
||||
<value>3</value>
|
||||
</key>
|
||||
<value>false</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>
|
||||
<value>4</value>
|
||||
</key>
|
||||
<value>true</value>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
Reference in New Issue
Block a user