[jboss-cvs] JBossAS SVN: r90098 - in projects/kernel/trunk/kernel/src/test: java/org/jboss/test/kernel/deployment/test and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jun 11 11:51:28 EDT 2009


Author: kabir.khan at jboss.com
Date: 2009-06-11 11:51:27 -0400 (Thu, 11 Jun 2009)
New Revision: 90098

Added:
   projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/support/BeanWithCollectionProperties.java
   projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/test/PreinstantiatedCollectionTestCase.java
   projects/kernel/trunk/kernel/src/test/resources/org/jboss/test/kernel/deployment/test/PreinstantiatedCollectionTestCase.xml
Log:
Add preinstantiate test case

Added: projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/support/BeanWithCollectionProperties.java
===================================================================
--- projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/support/BeanWithCollectionProperties.java	                        (rev 0)
+++ projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/support/BeanWithCollectionProperties.java	2009-06-11 15:51:27 UTC (rev 90098)
@@ -0,0 +1,165 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.deployment.support;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class BeanWithCollectionProperties
+{
+   Collection<String> collection = new ArrayList<String>();
+   Collection<String> preinstantiatedCollection = new ArrayList<String>();
+   List<String> list = new ArrayList<String>();
+   List<String> preinstantiatedList = new ArrayList<String>();
+   Set<String> set = new HashSet<String>();
+   Set<String> preinstantiatedSet = new HashSet<String>();
+   Map<String, String> map = new HashMap<String, String>();
+   Map<String, String> preinstantiatedMap = new HashMap<String, String>();
+   String[] array = new String[] {"Pre"};
+   String[] preinstantiatedArray = new String[] {"Pre"};
+
+   //Array?
+   
+   public BeanWithCollectionProperties()
+   {
+      collection.add("Pre");
+      preinstantiatedCollection.add("Pre");
+      list.add("Pre");
+      preinstantiatedList.add("Pre");
+      set.add("Pre");
+      preinstantiatedSet.add("Pre");
+      map.put("Pre", "Pre");
+      preinstantiatedMap.put("Pre", "Pre");
+   }
+   
+   public Collection<String> getCollection()
+   {
+      return collection;
+   }
+
+   public void setCollection(Collection<String> collection)
+   {
+      this.collection = collection;
+   }
+   
+   public Collection<String> getPreinstantiatedCollection()
+   {
+      return preinstantiatedCollection;
+   }
+   
+   public void setPreinstantiatedCollection(Collection<String> preinstantiatedCollection)
+   {
+      this.preinstantiatedCollection = preinstantiatedCollection;
+   }
+   
+   public List<String> getList()
+   {
+      return list;
+   }
+   
+   public void setList(List<String> list)
+   {
+      this.list = list;
+   }
+   
+   public List<String> getPreinstantiatedList()
+   {
+      return preinstantiatedList;
+   }
+   
+   public void setPreinstantiatedList(List<String> preinstantiatedList)
+   {
+      this.preinstantiatedList = preinstantiatedList;
+   }
+   
+   public Set<String> getSet()
+   {
+      return set;
+   }
+   
+   public void setSet(Set<String> set)
+   {
+      this.set = set;
+   }
+   
+   public Set<String> getPreinstantiatedSet()
+   {
+      return preinstantiatedSet;
+   }
+   
+   public void setPreinstantiatedSet(Set<String> preinstantiatedSet)
+   {
+      this.preinstantiatedSet = preinstantiatedSet;
+   }
+   
+   public Map<String, String> getMap()
+   {
+      return map;
+   }
+   
+   public void setMap(Map<String, String> map)
+   {
+      this.map = map;
+   }
+   
+   public Map<String, String> getPreinstantiatedMap()
+   {
+      return preinstantiatedMap;
+   }
+   
+   public void setPreinstantiatedMap(Map<String, String> preinstantiatedMap)
+   {
+      this.preinstantiatedMap = preinstantiatedMap;
+   }
+
+   public String[] getArray()
+   {
+      return array;
+   }
+
+   public void setArray(String[] array)
+   {
+      this.array = array;
+   }
+
+   public String[] getPreinstantiatedArray()
+   {
+      return preinstantiatedArray;
+   }
+
+   public void setPreinstantiatedArray(String[] preinstantiatedArray)
+   {
+      this.preinstantiatedArray = preinstantiatedArray;
+   }
+   
+   
+}

Added: projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/test/PreinstantiatedCollectionTestCase.java
===================================================================
--- projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/test/PreinstantiatedCollectionTestCase.java	                        (rev 0)
+++ projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/deployment/test/PreinstantiatedCollectionTestCase.java	2009-06-11 15:51:27 UTC (rev 90098)
@@ -0,0 +1,127 @@
+/*
+* 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.deployment.test;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.Test;
+
+import org.jboss.test.kernel.deployment.support.BeanWithCollectionProperties;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+
+/**
+ * GetInstanceTestCase
+ *
+ * @author <a href="mailto:kabir.khan at jboss.com">Kabir Khan</a>
+ */
+public class PreinstantiatedCollectionTestCase extends MicrocontainerTest
+{
+   public PreinstantiatedCollectionTestCase(String name) throws Throwable
+   {
+      super(name, true);
+   }
+
+   public static Test suite()
+   {
+      return suite(PreinstantiatedCollectionTestCase.class);
+   }
+
+   public void testGetInstance() throws Throwable
+   {
+      BeanWithCollectionProperties bean = assertBean("Bean", BeanWithCollectionProperties.class);
+      
+      Collection<String> collection = bean.getCollection();
+      assertDefaultCollection(collection);
+      
+      Collection<String> preinstantiatedCollection = bean.getPreinstantiatedCollection();
+      assertPreinstantiateCollection(preinstantiatedCollection);
+      
+      List<String> list = bean.getList();
+      assertDefaultCollection(list);
+      
+      List<String> preinstantiatedList = bean.getPreinstantiatedList();
+      assertPreinstantiateCollection(preinstantiatedList);
+      
+      Set<String> set = bean.getSet();
+      assertDefaultCollection(set);
+      
+      Set<String> preinstantiatedSet = bean.getPreinstantiatedSet();
+      assertPreinstantiateCollection(preinstantiatedSet);
+      
+      String[] array = bean.getArray();
+      assertNotNull(array);
+      assertDefaultCollection(Arrays.asList(array));
+      
+      String[] preinstantiatedArray = bean.getPreinstantiatedArray();
+      assertNotNull(preinstantiatedArray);
+      assertPreinstantiateCollection(Arrays.asList(preinstantiatedArray));
+      
+      Map<String, String> map = bean.getMap();
+      assertDefaultMap(map);
+      
+      Map<String, String> preInstantiatedMap = bean.getPreinstantiatedMap();
+      assertPreinstantiateMap(preInstantiatedMap);
+   }
+
+   private void assertDefaultCollection(Collection<String> collection)
+   {
+      assertCollection(collection, "Pre", "One", "Two");
+   }
+   
+   private void assertPreinstantiateCollection(Collection collection)
+   {
+      assertCollection(collection, "One", "Two");
+   }
+   
+   private void assertCollection(Collection<String> collection, String...values)
+   {
+      assertNotNull(collection);
+      assertEquals(values.length, collection.size());
+      for (String s : values)
+      {
+         assertTrue(collection.contains(s));
+      }
+   }
+   
+   private void assertDefaultMap(Map<String, String> map)
+   {
+      assertMap(map,"Pre", "One", "Two");
+   }
+   
+   private void assertPreinstantiateMap(Map<String, String> map)
+   {
+      assertMap(map, "One", "Two");
+   }
+   
+   private void assertMap(Map<String, String> map, String...values)
+   {
+      assertNotNull(map);
+      for (String s : values)
+      {
+         assertEquals(s, map.get(s));
+      }
+   }
+}
\ No newline at end of file

Added: projects/kernel/trunk/kernel/src/test/resources/org/jboss/test/kernel/deployment/test/PreinstantiatedCollectionTestCase.xml
===================================================================
--- projects/kernel/trunk/kernel/src/test/resources/org/jboss/test/kernel/deployment/test/PreinstantiatedCollectionTestCase.xml	                        (rev 0)
+++ projects/kernel/trunk/kernel/src/test/resources/org/jboss/test/kernel/deployment/test/PreinstantiatedCollectionTestCase.xml	2009-06-11 15:51:27 UTC (rev 90098)
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <bean name="Bean" class="org.jboss.test.kernel.deployment.support.BeanWithCollectionProperties">
+      <property name="collection">
+         <list elementClass="java.lang.String">
+            <value>One</value>
+            <value>Two</value>
+         </list>
+      </property>
+      <property name="preinstantiatedCollection" preinstantiate="false">
+         <list elementClass="java.lang.String">
+            <value>One</value>
+            <value>Two</value>
+         </list>
+      </property>
+      <property name="list">
+         <list elementClass="java.lang.String">
+            <value>One</value>
+            <value>Two</value>
+         </list>
+      </property>
+      <property name="preinstantiatedList" preinstantiate="false">
+         <list elementClass="java.lang.String">
+            <value>One</value>
+            <value>Two</value>
+         </list>
+      </property>
+      <property name="set">
+         <set elementClass="java.lang.String">
+            <value>One</value>
+            <value>Two</value>
+         </set>
+      </property>
+      <property name="preinstantiatedSet" preinstantiate="false">
+         <set elementClass="java.lang.String">
+            <value>One</value>
+            <value>Two</value>
+         </set>
+      </property>
+      <property name="array">
+         <array elementClass="java.lang.String">
+            <value>One</value>
+            <value>Two</value>
+         </array>
+      </property>
+      <property name="preinstantiatedArray" preinstantiate="false">
+         <array elementClass="java.lang.String">
+            <value>One</value>
+            <value>Two</value>
+         </array>
+      </property>
+      <property name="map">
+         <map keyClass="java.lang.String" valueClass="java.lang.String">
+            <entry>
+               <key>One</key>
+               <value>One</value>
+            </entry>
+            <entry>
+               <key>Two</key>
+               <value>Two</value>
+            </entry>
+         </map>
+      </property>
+      <property name="preinstantiatedMap" preinstantiate="false"> <!--  false - Excludes Pre from existing bean / true includes it -->
+         <map keyClass="java.lang.String" valueClass="java.lang.String">
+            <entry>
+               <key>One</key>
+               <value>One</value>
+            </entry>
+            <entry>
+               <key>Two</key>
+               <value>Two</value>
+            </entry>
+         </map>
+      </property>
+      
+      
+   </bean>
+</deployment>




More information about the jboss-cvs-commits mailing list