[jboss-cvs] JBossAS SVN: r71057 - in projects/microcontainer/trunk/kernel/src: tests/org/jboss/test/kernel/config/support and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Mar 20 09:13:05 EDT 2008
Author: alesj
Date: 2008-03-20 09:13:05 -0400 (Thu, 20 Mar 2008)
New Revision: 71057
Added:
projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testCustomCollectionPreInstantiated2.xml
projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testCustomListPreInstantiated2.xml
projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testCustomMapPreInstantiated2.xml
projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testCustomSetPreInstantiated2.xml
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/SimplerBean.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PreInstantiatedFieldsTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PreInstantiatedFieldsXMLTestCase.java
Modified:
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/SimpleBean.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigTestSuite.java
Log:
Field injection and preinstantiated collections.
Added: projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testCustomCollectionPreInstantiated2.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testCustomCollectionPreInstantiated2.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testCustomCollectionPreInstantiated2.xml 2008-03-20 13:13:05 UTC (rev 71057)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ <bean name="SimpleBean" class="org.jboss.test.kernel.config.support.SimplerBean" access-mode="ALL">
+ <constructor>
+ <parameter class="java.lang.String">string1</parameter>
+ </constructor>
+ <property name="preInstantiatedCollection">
+ <collection elementClass="java.lang.String">
+ <value>string2</value>
+ <value>string2</value>
+ <value>string1</value>
+ </collection>
+ </property>
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testCustomListPreInstantiated2.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testCustomListPreInstantiated2.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testCustomListPreInstantiated2.xml 2008-03-20 13:13:05 UTC (rev 71057)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ <bean name="SimpleBean" class="org.jboss.test.kernel.config.support.SimplerBean" access-mode="ALL">
+ <constructor>
+ <parameter class="java.lang.String">string1</parameter>
+ </constructor>
+ <property name="preInstantiatedList">
+ <list elementClass="java.lang.String">
+ <value>string2</value>
+ <value>string2</value>
+ <value>string1</value>
+ </list>
+ </property>
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testCustomMapPreInstantiated2.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testCustomMapPreInstantiated2.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testCustomMapPreInstantiated2.xml 2008-03-20 13:13:05 UTC (rev 71057)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ <bean name="SimpleBean" class="org.jboss.test.kernel.config.support.SimplerBean" access-mode="ALL">
+ <constructor>
+ <parameter>string1</parameter>
+ <parameter>string2</parameter>
+ </constructor>
+ <property name="preInstantiatedMap">
+ <map keyClass="java.lang.String" valueClass="java.lang.String">
+ <entry><key>string2</key><value>string1</value></entry>
+ </map>
+ </property>
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testCustomSetPreInstantiated2.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testCustomSetPreInstantiated2.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testCustomSetPreInstantiated2.xml 2008-03-20 13:13:05 UTC (rev 71057)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ <bean name="SimpleBean" class="org.jboss.test.kernel.config.support.SimplerBean" access-mode="ALL">
+ <constructor>
+ <parameter class="java.lang.String">string1</parameter>
+ </constructor>
+ <property name="preInstantiatedSet">
+ <set elementClass="java.lang.String">
+ <value>string2</value>
+ <value>string2</value>
+ <value>string1</value>
+ </set>
+ </property>
+ </bean>
+</deployment>
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/SimpleBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/SimpleBean.java 2008-03-20 13:10:06 UTC (rev 71056)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/SimpleBean.java 2008-03-20 13:13:05 UTC (rev 71057)
@@ -38,9 +38,9 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision$
*/
-public class SimpleBean implements Serializable
+public class SimpleBean extends SimplerBean implements Serializable
{
- public enum Alphabet {A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, X, Y, Z};
+ public enum Alphabet {A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, X, Y, Z}
// Constants -----------------------------------------------------
@@ -120,21 +120,12 @@
/** collection */
private Collection<?> collection;
- /** preInstantiated */
- private CustomCollection preInstantiatedCollection = new CustomCollection(true);
-
/** set */
private Set<?> set;
- /** preInstantiated */
- private CustomSet preInstantiatedSet = new CustomSet(true);
-
/** list */
private List<?> list;
- /** preInstantiated */
- private CustomList preInstantiatedList = new CustomList(true);
-
/** array */
private Object[] array;
@@ -144,9 +135,6 @@
/** map */
private Map<?,?> map;
- /** preInstantiated */
- private CustomMap preInstantiatedMap = new CustomMap(true);
-
/** Overloaded property */
private String overloadedProperty;
@@ -177,17 +165,15 @@
public SimpleBean(String string)
{
+ super(string);
constructorUsed = string;
aString = string;
- preInstantiatedCollection.add(string);
- preInstantiatedList.add(string);
- preInstantiatedSet.add(string);
preInstantiatedArray = new Object[]{string};
}
public SimpleBean(String string1, String string2)
{
- preInstantiatedMap.put(string1, string2);
+ super(string1, string2);
}
public SimpleBean(Integer integer)
@@ -485,11 +471,6 @@
this.set = set;
}
- public CustomSet getPreInstantiatedSet()
- {
- return preInstantiatedSet;
- }
-
public void setPreInstantiatedSet(CustomSet preInstantiatedSet)
{
this.preInstantiatedSet = preInstantiatedSet;
@@ -515,11 +496,6 @@
this.collection = collection;
}
- public CustomCollection getPreInstantiatedCollection()
- {
- return preInstantiatedCollection;
- }
-
public void setPreInstantiatedCollection(CustomCollection preInstantiatedCollection)
{
this.preInstantiatedCollection = preInstantiatedCollection;
@@ -545,11 +521,6 @@
this.list = list;
}
- public CustomList getPreInstantiatedList()
- {
- return preInstantiatedList;
- }
-
public void setPreInstantiatedList(CustomList preInstantiatedList)
{
this.preInstantiatedList = preInstantiatedList;
@@ -605,11 +576,6 @@
this.map = map;
}
- public CustomMap getPreInstantiatedMap()
- {
- return preInstantiatedMap;
- }
-
public void setPreInstantiatedMap(CustomMap preInstantiatedMap)
{
this.preInstantiatedMap = preInstantiatedMap;
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/SimplerBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/SimplerBean.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/SimplerBean.java 2008-03-20 13:13:05 UTC (rev 71057)
@@ -0,0 +1,82 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.config.support;
+
+import java.io.Serializable;
+
+/**
+ * A simpler bean
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SimplerBean implements Serializable
+{
+ private static final long serialVersionUID = -2041055615016745994L;
+
+ /** preInstantiated */
+ protected CustomCollection preInstantiatedCollection = new CustomCollection(true);
+
+ /** preInstantiated */
+ protected CustomSet preInstantiatedSet = new CustomSet(true);
+
+ /** preInstantiated */
+ protected CustomList preInstantiatedList = new CustomList(true);
+
+ /** preInstantiated */
+ protected CustomMap preInstantiatedMap = new CustomMap(true);
+
+ public SimplerBean()
+ {
+ }
+
+ public SimplerBean(String string)
+ {
+ preInstantiatedCollection.add(string);
+ preInstantiatedList.add(string);
+ preInstantiatedSet.add(string);
+ }
+
+ public SimplerBean(String key, String value)
+ {
+ preInstantiatedMap.put(key, value);
+ }
+
+ public CustomCollection getPreInstantiatedCollection()
+ {
+ return preInstantiatedCollection;
+ }
+
+ public CustomSet getPreInstantiatedSet()
+ {
+ return preInstantiatedSet;
+ }
+
+ public CustomList getPreInstantiatedList()
+ {
+ return preInstantiatedList;
+ }
+
+ public CustomMap getPreInstantiatedMap()
+ {
+ return preInstantiatedMap;
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigTestSuite.java 2008-03-20 13:10:06 UTC (rev 71056)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigTestSuite.java 2008-03-20 13:13:05 UTC (rev 71057)
@@ -87,6 +87,8 @@
suite.addTest(ValueTrimTestCase.suite());
suite.addTest(ValueTrimXMLTestCase.suite());
suite.addTest(ValueTrimAnnotationTestCase.suite());
+ suite.addTest(PreInstantiatedFieldsTestCase.suite());
+ suite.addTest(PreInstantiatedFieldsXMLTestCase.suite());
return suite;
}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PreInstantiatedFieldsTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PreInstantiatedFieldsTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PreInstantiatedFieldsTestCase.java 2008-03-20 13:13:05 UTC (rev 71057)
@@ -0,0 +1,267 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.config.test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractCollectionMetaData;
+import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
+import org.jboss.beans.metadata.plugins.StringValueMetaData;
+import org.jboss.beans.metadata.plugins.AbstractListMetaData;
+import org.jboss.beans.metadata.plugins.AbstractMapMetaData;
+import org.jboss.beans.metadata.plugins.AbstractSetMetaData;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
+import org.jboss.beans.info.spi.BeanAccessMode;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.test.kernel.config.support.CustomCollection;
+import org.jboss.test.kernel.config.support.SimplerBean;
+import org.jboss.test.kernel.config.support.CustomList;
+import org.jboss.test.kernel.config.support.CustomMap;
+import org.jboss.test.kernel.config.support.CustomSet;
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * Preinstantiated fields test cases.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PreInstantiatedFieldsTestCase extends AbstractKernelConfigTest
+{
+ String string1 = "string1";
+ String string2 = "string2";
+
+ public PreInstantiatedFieldsTestCase(String name)
+ {
+ super(name);
+ }
+
+ public PreInstantiatedFieldsTestCase(String name, boolean xmltest)
+ {
+ super(name, xmltest);
+ }
+
+ public static Test suite()
+ {
+ return suite(PreInstantiatedFieldsTestCase.class);
+ }
+
+ /**
+ * Default setup with security manager enabled
+ *
+ * @param clazz the class
+ * @return the delegate
+ * @throws Exception for any error
+ */
+ public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
+ {
+ AbstractTestDelegate delegate = new AbstractTestDelegate(clazz);
+ delegate.enableSecurity = false;
+ return delegate;
+ }
+
+ public void testCustomCollectionPreInstantiated2() throws Throwable
+ {
+ SimplerBean bean = customCollectionPreInstantiated();
+ assertNotNull(bean);
+
+ Collection<?> result = bean.getPreInstantiatedCollection();
+ assertNotNull("Should be a collection", result);
+ assertTrue("Not a CustomCollection: " + result.getClass(), result instanceof CustomCollection);
+ assertTrue("Not preinstantiated", ((CustomCollection) result).getPreInstantiated());
+
+ ArrayList<Object> expected = new ArrayList<Object>();
+ expected.add(string1);
+ expected.add(string2);
+ expected.add(string2);
+ expected.add(string1);
+ assertEquals(expected, result);
+ }
+
+ protected SimplerBean customCollectionPreInstantiated() throws Throwable
+ {
+ Kernel kernel = bootstrap();
+ KernelController controller = kernel.getController();
+
+ AbstractBeanMetaData bmd = new AbstractBeanMetaData("test1", SimplerBean.class.getName());
+ bmd.setAccessMode(BeanAccessMode.ALL);
+ HashSet<PropertyMetaData> properties = new HashSet<PropertyMetaData>();
+ bmd.setProperties(properties);
+
+ StringValueMetaData vmd1 = new StringValueMetaData(string1);
+ StringValueMetaData vmd2 = new StringValueMetaData(string2);
+ StringValueMetaData vmd3 = new StringValueMetaData(string1);
+
+ AbstractCollectionMetaData smd = new AbstractCollectionMetaData();
+ smd.setElementType("java.lang.String");
+ smd.add(vmd1);
+ smd.add(vmd2);
+ smd.add(vmd2); // tests duplicates
+ smd.add(vmd3); // tests duplicates
+
+ AbstractPropertyMetaData pmd = new AbstractPropertyMetaData("preInstantiatedCollection", smd);
+ properties.add(pmd);
+
+ return (SimplerBean) instantiate(controller, bmd);
+ }
+
+ public void testCustomListPreInstantiated2() throws Throwable
+ {
+ SimplerBean bean = customListPreInstantiated();
+ assertNotNull(bean);
+
+ List<?> result = bean.getPreInstantiatedList();
+ assertNotNull("Should be a list", result);
+ assertTrue("Not a CustomList: " + result.getClass(), result instanceof CustomList);
+ assertTrue("Not preinstantiated", ((CustomList) result).getPreInstantiated());
+
+ ArrayList<Object> expected = new ArrayList<Object>();
+ expected.add(string1);
+ expected.add(string2);
+ expected.add(string2);
+ expected.add(string1);
+ assertEquals(expected, result);
+ }
+
+ protected SimplerBean customListPreInstantiated() throws Throwable
+ {
+ Kernel kernel = bootstrap();
+ KernelController controller = kernel.getController();
+
+ AbstractBeanMetaData bmd = new AbstractBeanMetaData("test1", SimplerBean.class.getName());
+ bmd.setAccessMode(BeanAccessMode.ALL);
+ HashSet<PropertyMetaData> properties = new HashSet<PropertyMetaData>();
+ bmd.setProperties(properties);
+
+ StringValueMetaData vmd1 = new StringValueMetaData(string1);
+ StringValueMetaData vmd2 = new StringValueMetaData(string2);
+ StringValueMetaData vmd3 = new StringValueMetaData(string1);
+
+ AbstractListMetaData smd = new AbstractListMetaData();
+ smd.setElementType("java.lang.String");
+ smd.add(vmd1);
+ smd.add(vmd2);
+ smd.add(vmd2); // tests duplicates
+ smd.add(vmd3); // tests duplicates
+
+ AbstractPropertyMetaData pmd1 = new AbstractPropertyMetaData("preInstantiatedList", smd);
+ properties.add(pmd1);
+
+ return (SimplerBean) instantiate(controller, bmd);
+ }
+
+ public void testCustomMapPreInstantiated2() throws Throwable
+ {
+ SimplerBean bean = customMapPreInstantiated();
+ assertNotNull(bean);
+
+ Map<?,?> result = bean.getPreInstantiatedMap();
+ assertNotNull("Should be a map", result);
+ assertTrue("Not a CustomMap: " + result.getClass(), result instanceof CustomMap);
+ assertTrue("Not preinstantiated", ((CustomMap) result).getPreInstantiated());
+
+ Map<Object, Object> expected = new HashMap<Object, Object>();
+ expected.put(string1, string2);
+ expected.put(string2, string1);
+ assertEquals(expected, result);
+ }
+
+ protected SimplerBean customMapPreInstantiated() throws Throwable
+ {
+ Kernel kernel = bootstrap();
+ KernelController controller = kernel.getController();
+
+ AbstractBeanMetaData bmd = new AbstractBeanMetaData("test1", SimplerBean.class.getName());
+ bmd.setAccessMode(BeanAccessMode.ALL);
+ HashSet<PropertyMetaData> properties = new HashSet<PropertyMetaData>();
+ bmd.setProperties(properties);
+
+ StringValueMetaData kmd1 = new StringValueMetaData(string1);
+ StringValueMetaData kmd2 = new StringValueMetaData(string2);
+ StringValueMetaData vmd1 = new StringValueMetaData(string2);
+ StringValueMetaData vmd2 = new StringValueMetaData(string1);
+
+ AbstractMapMetaData smd = new AbstractMapMetaData();
+ smd.setKeyType("java.lang.String");
+ smd.setValueType("java.lang.String");
+ smd.put(kmd1, vmd1);
+ smd.put(kmd2, vmd2);
+
+ AbstractPropertyMetaData pmd = new AbstractPropertyMetaData("preInstantiatedMap", smd);
+ properties.add(pmd);
+
+ return (SimplerBean) instantiate(controller, bmd);
+ }
+
+ public void testCustomSetPreInstantiated2() throws Throwable
+ {
+ SimplerBean bean = customSetPreInstantiated();
+ assertNotNull(bean);
+
+ Set<?> result = bean.getPreInstantiatedSet();
+ assertNotNull("Should be a set", result);
+ assertTrue("Not a CustomSet: " + result.getClass(), result instanceof CustomSet);
+ assertTrue("Not preinstantiated", ((CustomSet) result).getPreInstantiated());
+
+ HashSet<Object> expected = new HashSet<Object>();
+ expected.add(string1);
+ expected.add(string2);
+ expected.add(string2);
+ expected.add(string1);
+ assertEquals(expected, result);
+ }
+
+ protected SimplerBean customSetPreInstantiated() throws Throwable
+ {
+ Kernel kernel = bootstrap();
+ KernelController controller = kernel.getController();
+
+ AbstractBeanMetaData bmd = new AbstractBeanMetaData("test1", SimplerBean.class.getName());
+ bmd.setAccessMode(BeanAccessMode.ALL);
+ HashSet<PropertyMetaData> properties = new HashSet<PropertyMetaData>();
+ bmd.setProperties(properties);
+
+ StringValueMetaData vmd1 = new StringValueMetaData(string1);
+ StringValueMetaData vmd2 = new StringValueMetaData(string2);
+ StringValueMetaData vmd3 = new StringValueMetaData(string1);
+
+ AbstractSetMetaData smd = new AbstractSetMetaData();
+ smd.setElementType("java.lang.String");
+ smd.add(vmd1);
+ smd.add(vmd2);
+ smd.add(vmd2); // tests duplicates
+ smd.add(vmd3); // tests duplicates
+
+ AbstractPropertyMetaData pmd = new AbstractPropertyMetaData("preInstantiatedSet", smd);
+ properties.add(pmd);
+
+ return (SimplerBean) instantiate(controller, bmd);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PreInstantiatedFieldsXMLTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PreInstantiatedFieldsXMLTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PreInstantiatedFieldsXMLTestCase.java 2008-03-20 13:13:05 UTC (rev 71057)
@@ -0,0 +1,68 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.config.test;
+
+import junit.framework.Test;
+import org.jboss.test.kernel.config.support.SimplerBean;
+import org.jboss.test.kernel.config.support.XMLUtil;
+
+/**
+ * Preinstantiated fields xml test cases.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PreInstantiatedFieldsXMLTestCase extends PreInstantiatedFieldsTestCase
+{
+ public PreInstantiatedFieldsXMLTestCase(String name)
+ {
+ super(name, true);
+ }
+
+ public static Test suite()
+ {
+ return suite(PreInstantiatedFieldsXMLTestCase.class);
+ }
+
+ protected SimplerBean customCollectionPreInstantiated() throws Throwable
+ {
+ XMLUtil util = bootstrapXML(true);
+ return (SimplerBean) util.getBean("SimpleBean");
+ }
+
+ protected SimplerBean customListPreInstantiated() throws Throwable
+ {
+ XMLUtil util = bootstrapXML(true);
+ return (SimplerBean) util.getBean("SimpleBean");
+ }
+
+ protected SimplerBean customMapPreInstantiated() throws Throwable
+ {
+ XMLUtil util = bootstrapXML(true);
+ return (SimplerBean) util.getBean("SimpleBean");
+ }
+
+ protected SimplerBean customSetPreInstantiated() throws Throwable
+ {
+ XMLUtil util = bootstrapXML(true);
+ return (SimplerBean) util.getBean("SimpleBean");
+ }
+}
More information about the jboss-cvs-commits
mailing list