[jboss-cvs] JBossAS SVN: r70518 - in projects/microcontainer/trunk/metatype/src: main/org/jboss/metatype/plugins/types and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Mar 6 16:34:43 EST 2008


Author: scott.stark at jboss.org
Date: 2008-03-06 16:34:43 -0500 (Thu, 06 Mar 2008)
New Revision: 70518

Added:
   projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/StringKey.java
Modified:
   projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/MapCompositeMetaType.java
   projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/DefaultMetaTypeFactory.java
   projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java
   projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/CompositeMetaTypeFactoryUnitTestCase.java
   projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/MapMetaTypeFactoryUnitTestCase.java
   projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/CompositeValueFactoryUnitTestCase.java
   projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/MapValueFactoryUnitTestCase.java
Log:
JBMICROCONT-238, Map<String,?> should map to a MapCompositeMetaType(MetaValue<?>) and java.util.Properties should map to a MapCompositeMetaType(MetaValue<String>)

Modified: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/MapCompositeMetaType.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/MapCompositeMetaType.java	2008-03-06 21:22:23 UTC (rev 70517)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/MapCompositeMetaType.java	2008-03-06 21:34:43 UTC (rev 70518)
@@ -50,6 +50,15 @@
    }
 
    /**
+    * Access the map value type.
+    * @return the map value type.
+    */
+   public MetaType getValueType()
+   {
+      return valueType;
+   }
+
+   /**
     * 
     * @param itemName
     */

Modified: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/DefaultMetaTypeFactory.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/DefaultMetaTypeFactory.java	2008-03-06 21:22:23 UTC (rev 70517)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/DefaultMetaTypeFactory.java	2008-03-06 21:34:43 UTC (rev 70518)
@@ -29,6 +29,7 @@
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 import java.util.WeakHashMap;
 
@@ -47,6 +48,7 @@
 import org.jboss.metatype.api.types.GenericMetaType;
 import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
 import org.jboss.metatype.api.types.ImmutableTableMetaType;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
 import org.jboss.metatype.api.types.MetaType;
 import org.jboss.metatype.api.types.MetaTypeFactory;
 import org.jboss.metatype.api.types.SimpleMetaType;
@@ -64,7 +66,8 @@
  * DefaultMetaTypeFactory.
  * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
  */
 public class DefaultMetaTypeFactory extends MetaTypeFactory
 {
@@ -183,7 +186,29 @@
          return generateCollection((ClassInfo) typeInfo);
       
       if (typeInfo.isMap())
-         return generateMap((ClassInfo) typeInfo);
+      {
+         // See if this is a Map<String,?> type
+         ClassInfo classInfo = (ClassInfo) typeInfo;
+         TypeInfo[] types = classInfo.getActualTypeArguments();
+         if (types != null)
+         {
+            TypeInfo keyType = types[0];
+            TypeInfo valueType = types[1];
+            if(keyType.getName().equals(String.class.getName()))
+            {
+               // Use MapCompositeMetaType
+               MetaType valueMetaType = resolve(valueType);
+               return new MapCompositeMetaType(valueMetaType);
+            }
+         }
+         // Map java.util.Properties to MapCompositeMetaType(SimpleMetaType.STRING)
+         else if(typeInfo.getName().equals(Properties.class.getName()))
+         {
+            return new MapCompositeMetaType(SimpleMetaType.STRING);
+         }
+         // No, return the general map type
+         return generateMap(classInfo);
+      }
       
       result = SimpleMetaType.isSimpleType(typeInfo.getName());
       if (result != null)


Property changes on: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/DefaultMetaTypeFactory.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision

Modified: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java	2008-03-06 21:22:23 UTC (rev 70517)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java	2008-03-06 21:34:43 UTC (rev 70518)
@@ -35,10 +35,12 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 import java.util.SortedSet;
 import java.util.Stack;
 import java.util.WeakHashMap;
+import java.util.Map.Entry;
 
 import org.jboss.beans.info.spi.BeanInfo;
 import org.jboss.beans.info.spi.PropertyInfo;
@@ -49,6 +51,7 @@
 import org.jboss.metatype.api.types.CompositeMetaType;
 import org.jboss.metatype.api.types.EnumMetaType;
 import org.jboss.metatype.api.types.GenericMetaType;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
 import org.jboss.metatype.api.types.MetaType;
 import org.jboss.metatype.api.types.MetaTypeFactory;
 import org.jboss.metatype.api.types.SimpleMetaType;
@@ -64,6 +67,7 @@
 import org.jboss.metatype.api.values.GenericValue;
 import org.jboss.metatype.api.values.GenericValueSupport;
 import org.jboss.metatype.api.values.InstanceFactory;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
 import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.MetaValueFactory;
 import org.jboss.metatype.api.values.SimpleValue;
@@ -395,6 +399,25 @@
       if (value == null)
          return null;
       
+      // See if this is a Map<String,?> type
+      if(type instanceof MapCompositeMetaType)
+      {
+         if((value instanceof Map) == false)
+            throw new RuntimeException("Expected Map value for: " + type+", was: "+(value != null ? value.getClass() : "null"));
+         Map<String,?> map = (Map<String,?>) value;
+         MapCompositeMetaType mapType = (MapCompositeMetaType) type;
+         MetaType mapValueType = mapType.getValueType();
+         MapCompositeValueSupport result = new MapCompositeValueSupport(mapValueType);
+         for(Entry<String,?> entry : map.entrySet())
+         {
+            Object entryValue = entry.getValue();
+            MetaValue entryMetaValue = internalCreate(entryValue, null, mapValueType);
+            result.put(entry.getKey(), entryMetaValue);
+         }
+         mapping.put(value, result);
+         return result;
+      }
+
       CompositeValueSupport result = new CompositeValueSupport(type);
       mapping.put(value, result);
 

Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/CompositeMetaTypeFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/CompositeMetaTypeFactoryUnitTestCase.java	2008-03-06 21:22:23 UTC (rev 70517)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/CompositeMetaTypeFactoryUnitTestCase.java	2008-03-06 21:34:43 UTC (rev 70518)
@@ -25,7 +25,7 @@
 import java.lang.reflect.Type;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 
 import junit.framework.Test;
@@ -34,9 +34,6 @@
 import org.jboss.metatype.api.types.MapCompositeMetaType;
 import org.jboss.metatype.api.types.MetaType;
 import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.MapCompositeValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
 import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
 import org.jboss.test.metatype.types.factory.support.TestIgnoredCompositeItem;
 import org.jboss.test.metatype.types.factory.support.TestRecursiveComposite;
@@ -139,28 +136,31 @@
 
    public HashMap<String, String> compositeSignature;
    /**
-    * JBMICROCONT-238
-    * TODO: Fixing this breaks other Map<String,?> tests expecting
-    * TableMetaType/TableValues
+    * JBMICROCONT-238, Map<String,?> should map to a MapCompositeMetaType(MetaValue<?>)
     * @throws Exception
     */
-   public void testMapComposite() throws Exception
+   public void testMapWithStringKeyComposite() throws Exception
    {
+      //Map<String,String> map = new HashMap<String,String>();
       Field field = getClass().getField("compositeSignature");
       Type mapSignature = field.getGenericType();
       CompositeMetaType result = assertInstanceOf(resolve(mapSignature), CompositeMetaType.class);
       MapCompositeMetaType expected = new MapCompositeMetaType(SimpleMetaType.STRING);
       
       testComposite(expected, result);
-
-      Map<String, MetaValue> itemValues = new HashMap<String, MetaValue>();
-      itemValues.put("key1", SimpleValueSupport.wrap("value1"));
-      itemValues.put("key2", SimpleValueSupport.wrap("value2"));
-      itemValues.put("key3", SimpleValueSupport.wrap("value3"));
-      MapCompositeValueSupport mapValue = new MapCompositeValueSupport(itemValues, expected);
-      assertEquals(SimpleValueSupport.wrap("value1"), mapValue.get("key1"));
-      assertEquals(SimpleValueSupport.wrap("value2"), mapValue.get("key2"));
-      assertEquals(SimpleValueSupport.wrap("value3"), mapValue.get("key3"));
    }
+   /**
+    * JBMICROCONT-238, java.util.Properties should map to a MapCompositeMetaType(MetaValue<String>)
+    * @throws Exception
+    */
+   public void testPropertiesComposite()
+      throws Exception
+   {
+      Type propertiesType = Properties.class;
+      CompositeMetaType result = assertInstanceOf(resolve(propertiesType), CompositeMetaType.class);
+      MapCompositeMetaType expected = new MapCompositeMetaType(SimpleMetaType.STRING);
+      testComposite(expected, result);
+      
+   }
 
 }

Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/MapMetaTypeFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/MapMetaTypeFactoryUnitTestCase.java	2008-03-06 21:22:23 UTC (rev 70517)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/MapMetaTypeFactoryUnitTestCase.java	2008-03-06 21:34:43 UTC (rev 70518)
@@ -34,12 +34,15 @@
 import org.jboss.metatype.api.types.TableMetaType;
 import org.jboss.metatype.plugins.types.DefaultMetaTypeFactory;
 import org.jboss.test.metatype.types.factory.support.TestSimpleComposite;
+import org.jboss.test.metatype.values.factory.support.StringKey;
 
 /**
- * MapMetaTypeFactoryUnitTestCase.
+ * Test of Maps with non-String keys as TableMetaType/TableMetaValue.
+ * Map<String,?> uses MapCompositeMetaType(MetaValue<?>).
  * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
  */
 public class MapMetaTypeFactoryUnitTestCase extends AbstractMetaTypeFactoryTest
 {
@@ -68,7 +71,7 @@
     * 
     * @return the signature
     */
-   public Map<String, Integer> simpleMap()
+   public Map<StringKey, Integer> simpleMap()
    {
       return null;
    }
@@ -88,7 +91,7 @@
     * 
     * @return the signature
     */
-   public Map<String, TestSimpleComposite> compositeValueMap()
+   public Map<StringKey, TestSimpleComposite> compositeValueMap()
    {
       return null;
    }
@@ -100,7 +103,7 @@
     */
    public void testSimpleMap() throws Exception
    {
-      testMap("simpleMap", String.class, Integer.class);
+      testMap("simpleMap", StringKey.class, Integer.class);
    }
 
    /**
@@ -120,7 +123,7 @@
     */
    public void testCompositeValueMap() throws Exception
    {
-      testMap("compositeValueMap", String.class, TestSimpleComposite.class);
+      testMap("compositeValueMap", StringKey.class, TestSimpleComposite.class);
    }
    
    /**


Property changes on: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/MapMetaTypeFactoryUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision

Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/StringKey.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/StringKey.java	                        (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/StringKey.java	2008-03-06 21:34:43 UTC (rev 70518)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.metatype.values.factory.support;
+
+/**
+ * A string like key used in the MapValueFactoryUnitTestCase,
+ * MapMetaTypeFactoryUnitTestCase.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class StringKey
+{
+   private String key;
+
+   public StringKey(String key)
+   {
+      super();
+      this.key = key;
+   }
+
+   public String getKey()
+   {
+      return key;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      final int PRIME = 31;
+      int result = 1;
+      result = PRIME * result + ((key == null) ? 0 : key.hashCode());
+      return result;
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (this == obj)
+         return true;
+      if (obj == null)
+         return false;
+      if (getClass() != obj.getClass())
+         return false;
+      final StringKey other = (StringKey) obj;
+      if (key == null)
+      {
+         if (other.key != null)
+            return false;
+      } else if (!key.equals(other.key))
+         return false;
+      return true;
+   }
+
+}


Property changes on: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/StringKey.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/CompositeValueFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/CompositeValueFactoryUnitTestCase.java	2008-03-06 21:22:23 UTC (rev 70517)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/CompositeValueFactoryUnitTestCase.java	2008-03-06 21:34:43 UTC (rev 70518)
@@ -21,12 +21,20 @@
 */
 package org.jboss.test.metatype.values.factory.test;
 
+import java.lang.reflect.Field;
+import java.lang.reflect.Type;
 import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
 import org.jboss.metatype.api.types.SimpleMetaType;
 import org.jboss.metatype.api.values.CompositeValue;
 import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
 import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.SimpleValueSupport;
 import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
@@ -152,4 +160,52 @@
       getLog().debug("Composite Value: " + actual);
       assertEquals(expected, actual);
    }
+   
+   public HashMap<String, String> compositeSignature;
+   /**
+    * JBMICROCONT-238, Map<String,?> should map to a MapCompositeValueSupport(MetaValue<?>)
+    * @throws Exception
+    */
+   public void testMapWithStringKeyComposite() throws Exception
+   {
+      Field field = getClass().getField("compositeSignature");
+      Type mapSignature = field.getGenericType();
+      
+      Map<String, String> values = new HashMap<String, String>();
+      values.put("key1", "value1");
+      values.put("key2", "value2");
+      values.put("key3", "value3");
+      MapCompositeValueSupport expected = new MapCompositeValueSupport(SimpleMetaType.STRING);
+      expected.put("key1", SimpleValueSupport.wrap("value1"));
+      expected.put("key2", SimpleValueSupport.wrap("value2"));
+      expected.put("key3", SimpleValueSupport.wrap("value3"));
+      MetaValue result = createMetaValue(values, mapSignature);
+      CompositeValue actual = assertInstanceOf(result, CompositeValue.class);
+      getLog().debug("Composite Value: " + actual);
+      assertEquals(expected, actual);
+
+   }
+   /**
+    * JBMICROCONT-238, java.util.Properties should map to a MapCompositeValueSupport(MetaValue<String>)
+    * @throws Exception
+    */
+   public void testPropertiesComposite()
+      throws Exception
+   {
+      Type propertiesType = Properties.class;
+
+      Properties values = new Properties();
+      values.put("key1", "value1");
+      values.put("key2", "value2");
+      values.put("key3", "value3");
+
+      MapCompositeValueSupport expected = new MapCompositeValueSupport(SimpleMetaType.STRING);
+      expected.put("key1", SimpleValueSupport.wrap("value1"));
+      expected.put("key2", SimpleValueSupport.wrap("value2"));
+      expected.put("key3", SimpleValueSupport.wrap("value3"));
+      MetaValue result = createMetaValue(values, propertiesType);
+      CompositeValue actual = assertInstanceOf(result, CompositeValue.class);
+      getLog().debug("Composite Value: " + actual);
+      assertEquals(expected, actual);
+   }
 }

Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/MapValueFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/MapValueFactoryUnitTestCase.java	2008-03-06 21:22:23 UTC (rev 70517)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/MapValueFactoryUnitTestCase.java	2008-03-06 21:34:43 UTC (rev 70518)
@@ -42,12 +42,15 @@
 import org.jboss.metatype.api.values.TableValueSupport;
 import org.jboss.metatype.plugins.types.DefaultMetaTypeFactory;
 import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
+import org.jboss.test.metatype.values.factory.support.StringKey;
 import org.jboss.test.metatype.values.factory.support.TestSimpleComposite;
 
 /**
- * MapValueFactoryUnitTestCase.
+ * Test of Maps with non-String keys as TableMetaType/TableMetaValue.
+ * Map<String,?> uses MapCompositeMetaType(MetaValue<?>).
  * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
  * @version $Revision: 1.1 $
  */
 public class MapValueFactoryUnitTestCase extends AbstractMetaValueFactoryTest
@@ -77,11 +80,11 @@
     * 
     * @return the value
     */
-   public Map<String, Integer> simpleMap()
+   public Map<StringKey, Integer> simpleMap()
    {
-      Map<String, Integer> result = new LinkedHashMap<String, Integer>();
-      result.put("Hello", new Integer(1));
-      result.put("Goodbye", new Integer(2));
+      Map<StringKey, Integer> result = new LinkedHashMap<StringKey, Integer>();
+      result.put(new StringKey("Hello"), new Integer(1));
+      result.put(new StringKey("Goodbye"), new Integer(2));
       return result;
    }
 
@@ -103,11 +106,11 @@
     * 
     * @return the value
     */
-   public Map<String, TestSimpleComposite> compositeValueMap()
+   public Map<StringKey, TestSimpleComposite> compositeValueMap()
    {
-      Map<String, TestSimpleComposite> result = new LinkedHashMap<String, TestSimpleComposite>();
-      result.put("Hello", new TestSimpleComposite("Hello"));
-      result.put("Goodbye", new TestSimpleComposite("Goodbye"));
+      Map<StringKey, TestSimpleComposite> result = new LinkedHashMap<StringKey, TestSimpleComposite>();
+      result.put(new StringKey("Hello"), new TestSimpleComposite("Hello"));
+      result.put(new StringKey("Goodbye"), new TestSimpleComposite("Goodbye"));
       return result;
    }
 
@@ -120,9 +123,9 @@
    {
       Method method = getClass().getMethod("simpleMap", null);
       Type collectionType = method.getGenericReturnType();
-      Map<String, Integer> map = simpleMap();
+      Map<StringKey, Integer> map = simpleMap();
       
-      MetaType keyType = resolve(String.class);
+      CompositeMetaType keyType = (CompositeMetaType) resolve(StringKey.class);
       MetaType valueType = resolve(Integer.class);
       MetaType[] itemTypes = { keyType, valueType };
       String entryName = Map.Entry.class.getName();
@@ -132,10 +135,14 @@
       TableValue expected = new TableValueSupport(tableType);
       String[] itemNames = DefaultMetaTypeFactory.MAP_ITEM_NAMES;
       
-      MetaValue[] itemValues = new MetaValue[] { SimpleValueSupport.wrap("Hello"), SimpleValueSupport.wrap(new Integer(1)) };
+      MetaValue[] keyValues1 = {SimpleValueSupport.wrap("Hello")};
+      CompositeValueSupport key1 = new CompositeValueSupport(keyType, new String[]{"key"}, keyValues1);
+      MetaValue[] itemValues = new MetaValue[] {key1, SimpleValueSupport.wrap(new Integer(1)) };
       expected.put(new CompositeValueSupport(entryType, itemNames, itemValues));
 
-      itemValues = new MetaValue[] { SimpleValueSupport.wrap("Goodbye"), SimpleValueSupport.wrap(new Integer(2)) };
+      MetaValue[] keyValues2 = {SimpleValueSupport.wrap("Goodbye")};
+      CompositeValueSupport key2 = new CompositeValueSupport(keyType, new String[]{"key"}, keyValues2);
+      itemValues = new MetaValue[] { key2, SimpleValueSupport.wrap(new Integer(2)) };
       expected.put(new CompositeValueSupport(entryType, itemNames, itemValues));
 
       MetaValue result = createMetaValue(map, collectionType);
@@ -196,9 +203,9 @@
    {
       Method method = getClass().getMethod("compositeValueMap", null);
       Type collectionType = method.getGenericReturnType();
-      Map<String, TestSimpleComposite> map = compositeValueMap();
+      Map<StringKey, TestSimpleComposite> map = compositeValueMap();
       
-      MetaType keyType = resolve(String.class);
+      CompositeMetaType keyType = (CompositeMetaType) resolve(StringKey.class);
       MetaType valueType = resolve(TestSimpleComposite.class);
       MetaType[] itemTypes = { keyType, valueType };
       String entryName = Map.Entry.class.getName();
@@ -215,11 +222,15 @@
       String[] compositeNames = { "something" };
       CompositeValue compositeValue = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Hello") });
       
-      MetaValue[] itemValues = new MetaValue[] { SimpleValueSupport.wrap("Hello"), compositeValue };
+      MetaValue[] keyValues1 = {SimpleValueSupport.wrap("Hello")};
+      CompositeValueSupport key1 = new CompositeValueSupport(keyType, new String[]{"key"}, keyValues1);
+      MetaValue[] itemValues = new MetaValue[] { key1, compositeValue };
       expected.put(new CompositeValueSupport(entryType, itemNames, itemValues));
 
+      MetaValue[] keyValues2 = {SimpleValueSupport.wrap("Goodbye")};
+      CompositeValueSupport key2 = new CompositeValueSupport(keyType, new String[]{"key"}, keyValues2);
       compositeValue = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Goodbye") });
-      itemValues = new MetaValue[] { SimpleValueSupport.wrap("Goodbye"), compositeValue };
+      itemValues = new MetaValue[] { key2, compositeValue };
       expected.put(new CompositeValueSupport(entryType, itemNames, itemValues));
 
       MetaValue result = createMetaValue(map, collectionType);




More information about the jboss-cvs-commits mailing list