[jboss-cvs] JBossAS SVN: r70031 - in projects/microcontainer/trunk/metatype/src: main/org/jboss/metatype/api/values and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Feb 22 04:44:03 EST 2008


Author: adrian at jboss.org
Date: 2008-02-22 04:44:03 -0500 (Fri, 22 Feb 2008)
New Revision: 70031

Added:
   projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/CompositeValue.java
   projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/MetaMapping.java
   projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/MetaTypeConstants.java
   projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/spi/values/MetaMapper.java
   projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestIgnoredCompositeItem.java
   projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestRenamedCompositeItem.java
   projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestIgnoredCompositeItem.java
   projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestMetaMapped.java
   projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestMetaMapper.java
   projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestRenamedCompositeItem.java
   projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/MetaMapperUnitTestCase.java
Modified:
   projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/CompositeKey.java
   projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/CompositeValueSupport.java
   projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/AbstractCompositeMetaType.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/AbstractMetaTypeTest.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/values/factory/test/CompositeValueFactoryUnitTestCase.java
   projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/UnwrapValueUnitTestCase.java
   projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/ValuesFactoryTestSuite.java
Log:
Add annotations for ignoring and aliasing properties in CompositeValues. Add a MetaMapper for mapping types. Fix a bug in the CompositeValue item processing

Modified: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/CompositeKey.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/CompositeKey.java	2008-02-22 08:31:32 UTC (rev 70030)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/CompositeKey.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -21,8 +21,10 @@
 */
 package org.jboss.metatype.api.annotations;
 
+import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
 
 /**
  * CompositeKey.
@@ -30,6 +32,7 @@
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision: 1.1 $
  */
+ at Target({ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
 public @interface CompositeKey
 {

Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/CompositeValue.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/CompositeValue.java	                        (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/CompositeValue.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -0,0 +1,44 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.metatype.api.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * CompositeKey.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at Target({ElementType.METHOD})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface CompositeValue
+{
+   /** The item name */
+   String name() default MetaTypeConstants.DEFAULT;
+
+   /** Whether to ignore this item */
+   boolean ignore() default false;
+}

Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/MetaMapping.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/MetaMapping.java	                        (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/MetaMapping.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -0,0 +1,43 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.metatype.api.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.jboss.metatype.spi.values.MetaMapper;
+
+/**
+ * MetaMapper.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at Target({ElementType.TYPE})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface MetaMapping
+{
+   /** The meta mapper */
+   Class<? extends MetaMapper<?>> value();
+}

Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/MetaTypeConstants.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/MetaTypeConstants.java	                        (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/MetaTypeConstants.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -0,0 +1,34 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.metatype.api.annotations;
+
+/**
+ * MetaTypeConstants.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface MetaTypeConstants
+{
+   /** A default value */
+   public static final String DEFAULT = "##DEFAULT";
+}

Modified: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/CompositeValueSupport.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/CompositeValueSupport.java	2008-02-22 08:31:32 UTC (rev 70030)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/CompositeValueSupport.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -85,7 +85,7 @@
       if (itemNames.length != itemValues.length)
          throw new IllegalArgumentException("itemNames has size " + itemNames.length + " but itemValues has size " + itemValues.length);
 
-      Set<String> compositeNames = metaType.keySet();
+      Set<String> compositeNames = metaType.itemSet();
       int compositeNameSize = compositeNames.size();
       if (itemNames.length > compositeNameSize)
          throw new IllegalArgumentException("itemNames has size " + itemNames.length + " but composite type has size " + compositeNameSize);
@@ -292,7 +292,7 @@
       if (items == null)
          items = Collections.emptyMap();
 
-      Set<String> compositeNames = metaType.keySet();
+      Set<String> compositeNames = metaType.itemSet();
       int compositeNameSize = compositeNames.size();
       if (items.size() > compositeNameSize)
          throw new IllegalArgumentException("items has size " + items.size() + " but composite type has size " + compositeNameSize);

Modified: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/AbstractCompositeMetaType.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/AbstractCompositeMetaType.java	2008-02-22 08:31:32 UTC (rev 70030)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/AbstractCompositeMetaType.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -275,7 +275,7 @@
    {
       StringBuilder buffer = new StringBuilder(getClass().getSimpleName());
       buffer.append('{').append(getTypeName());
-      Iterator<String> thisNames = keySet().iterator();
+      Iterator<String> thisNames = itemSet().iterator();
       if (thisNames.hasNext())
       {
          buffer.append(" items=");

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-02-22 08:31:32 UTC (rev 70030)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/DefaultMetaTypeFactory.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -37,8 +37,11 @@
 import org.jboss.config.plugins.property.PropertyConfiguration;
 import org.jboss.config.spi.Configuration;
 import org.jboss.metatype.api.annotations.CompositeKey;
+import org.jboss.metatype.api.annotations.CompositeValue;
 import org.jboss.metatype.api.annotations.Generic;
+import org.jboss.metatype.api.annotations.MetaTypeConstants;
 import org.jboss.metatype.api.types.ArrayMetaType;
+import org.jboss.metatype.api.types.CollectionMetaType;
 import org.jboss.metatype.api.types.CompositeMetaType;
 import org.jboss.metatype.api.types.EnumMetaType;
 import org.jboss.metatype.api.types.GenericMetaType;
@@ -48,8 +51,8 @@
 import org.jboss.metatype.api.types.MetaTypeFactory;
 import org.jboss.metatype.api.types.SimpleMetaType;
 import org.jboss.metatype.api.types.TableMetaType;
-import org.jboss.metatype.api.types.CollectionMetaType;
 import org.jboss.metatype.spi.types.MetaTypeBuilder;
+import org.jboss.metatype.spi.values.MetaMapper;
 import org.jboss.reflect.spi.ArrayInfo;
 import org.jboss.reflect.spi.ClassInfo;
 import org.jboss.reflect.spi.EnumConstantInfo;
@@ -158,6 +161,10 @@
       if (result != null)
          return result;
 
+      MetaMapper<?> mapper = MetaMapper.getMetaMapper(typeInfo);
+      if (mapper != null)
+         return mapper.getMetaType();
+      
       result = isGeneric(typeInfo);
       if (result != null)
          return result;
@@ -344,9 +351,21 @@
       {
          for (PropertyInfo property : properties)
          {
+            // Do we ignore this property?
+            CompositeValue compositeValue = property.getUnderlyingAnnotation(CompositeValue.class);
+            if (compositeValue != null && compositeValue.ignore())
+               continue;
+            
             String name = property.getName();
             if ("class".equals(name) == false)
             {
+               if (compositeValue != null)
+               {
+                  String compositeValueName = compositeValue.name();
+                  if (MetaTypeConstants.DEFAULT.equals(compositeValueName) == false)
+                     name = compositeValueName;
+               }
+
                TypeInfo itemTypeInfo = property.getType();
                MetaType<?> metaType = resolve(itemTypeInfo);
                result.addItem(name, name, metaType);

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-02-22 08:31:32 UTC (rev 70030)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -71,6 +71,7 @@
 import org.jboss.metatype.api.values.TableValue;
 import org.jboss.metatype.api.values.TableValueSupport;
 import org.jboss.metatype.plugins.types.DefaultMetaTypeFactory;
+import org.jboss.metatype.spi.values.MetaMapper;
 import org.jboss.metatype.spi.values.MetaValueBuilder;
 import org.jboss.reflect.plugins.introspection.ParameterizedClassInfo;
 import org.jboss.reflect.spi.ArrayInfo;
@@ -412,7 +413,7 @@
          throw new RuntimeException("Error retrieving BeanInfo for " + type);
       }
 
-      for (String name : type.keySet())
+      for (String name : type.itemSet())
       {
          MetaType<?> itemType = type.getType(name);
          Object itemValue;
@@ -523,6 +524,10 @@
       if (metaValue == null)
          return null;
 
+      MetaMapper<?> mapper = MetaMapper.getMetaMapper(type);
+      if (mapper != null)
+         return mapper.unwrapMetaValue(metaValue);
+      
       MetaType<?> metaType = metaValue.getMetaType();
 
       if (metaType.isSimple())
@@ -681,7 +686,7 @@
             return Proxy.newProxyInstance(clazz.getClassLoader(), interfaces, handler);            
          }
          Object bean = createNewInstance(beanInfo);
-         for (String name : compositeMetaType.keySet())
+         for (String name : compositeMetaType.itemSet())
          {
             MetaValue itemValue = compositeValue.get(name);
             PropertyInfo propertyInfo = beanInfo.getProperty(name);
@@ -947,8 +952,16 @@
       try
       {
          MetaValue result = isBuilder(metaType, type, value, mapping);
+
          if (result == null)
          {
+            MetaMapper<Object> mapper = (MetaMapper) MetaMapper.getMetaMapper(type);
+            if (mapper != null)
+               result = mapper.createMetaValue(metaType, value);
+         }
+
+         if (result == null)
+         {
             if (metaType.isSimple())
                result = createSimpleValue((SimpleMetaType<Serializable>) metaType, (Serializable) value);
             else if (metaType.isEnum())

Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/spi/values/MetaMapper.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/spi/values/MetaMapper.java	                        (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/spi/values/MetaMapper.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -0,0 +1,129 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.metatype.spi.values;
+
+import java.lang.reflect.Type;
+
+import org.jboss.metatype.api.annotations.MetaMapping;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.MetaTypeFactory;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.reflect.spi.TypeInfoFactory;
+
+/**
+ * MetaMapper.
+ * 
+ * @param <T> the mapped type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class MetaMapper<T>
+{
+   /** The metatype factory */
+   private static final MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance();
+   
+   /**
+    * Get a metamapper for a type info
+    * 
+    * @param typeInfo the type info
+    * @return the metamapper or null if there isn't one
+    */
+   public static final MetaMapper<?> getMetaMapper(TypeInfo typeInfo)
+   {
+      if (typeInfo instanceof ClassInfo == false)
+         return null;
+      
+      ClassInfo classInfo = (ClassInfo) typeInfo;
+      MetaMapper<?> mapper = typeInfo.getAttachment(MetaMapper.class);
+      if (mapper != null)
+         return mapper;
+
+      MetaMapping mapping = classInfo.getUnderlyingAnnotation(MetaMapping.class);
+      if (mapping == null)
+         return null;
+      
+      try
+      {
+         TypeInfoFactory factory = classInfo.getTypeInfoFactory();
+         ClassInfo mapperClass = (ClassInfo) factory.getTypeInfo(mapping.value());
+         ConstructorInfo constructor = mapperClass.getDeclaredConstructor(null);
+         mapper = (MetaMapper<?>) constructor.newInstance(null);
+         typeInfo.setAttachment(MetaMapper.class.getName(), mapper);
+         return mapper;
+      }
+      catch (Error e)
+      {
+         throw e;
+      }
+      catch (RuntimeException e)
+      {
+         throw e;
+      }
+      catch (Throwable t)
+      {
+         throw new RuntimeException("Error creating MetaMapper " + mapping + " for " + typeInfo.getName());
+      }
+   }
+   
+   /**
+    * Override this method to map to a specific type
+    * 
+    * @return the type
+    */
+   public Type mapToType()
+   {
+      return null;
+   }
+   
+   /**
+    * Override this method to create your own metatype
+    * 
+    * @return the metatype
+    */
+   public MetaType<?> getMetaType()
+   {
+      Type type = mapToType();
+      if (type == null)
+         throw new IllegalStateException("You haven't overridden getMetaType() or mapToType()");
+      return metaTypeFactory.resolve(type);
+   }
+   
+   /**
+    * Create the meta value
+    * 
+    * @param metaType the metatype
+    * @param object
+    * @return the meta value
+    */
+   public abstract MetaValue createMetaValue(MetaType<?> metaType, T object);
+   
+   /**
+    * Unwrap the metavalue
+    * 
+    * @param metaValue the meta value
+    * @return the object
+    */
+   public abstract T unwrapMetaValue(MetaValue metaValue);
+}

Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/AbstractMetaTypeTest.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/AbstractMetaTypeTest.java	2008-02-22 08:31:32 UTC (rev 70030)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/AbstractMetaTypeTest.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -282,7 +282,7 @@
     */
    protected void printComposite(String context, CompositeMetaType type)
    {
-      getLog().debug(context + " className=" + type.getClassName() + " typeName=" + type.getTypeName() + " description=" + type.getDescription() + " items=" + type.keySet());
+      getLog().debug(context + " className=" + type.getClassName() + " typeName=" + type.getTypeName() + " description=" + type.getDescription() + " keys=" + type.keySet() + " items=" + type.itemSet());
    }
 
    /**

Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestIgnoredCompositeItem.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestIgnoredCompositeItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestIgnoredCompositeItem.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -0,0 +1,82 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.metatype.types.factory.support;
+
+import org.jboss.metatype.api.annotations.CompositeKey;
+import org.jboss.metatype.api.annotations.CompositeValue;
+
+/**
+ * TestIgnoredCompositeItem.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestIgnoredCompositeItem
+{
+   /** The id */
+   private String id;
+   
+   /** The ignored */
+   private Object ignored;
+   
+   /**
+    * Get the id
+    * 
+    * @return the id
+    */
+   @CompositeKey
+   public String getId()
+   {
+      return id;
+   }
+
+   /**
+    * Set the id
+    * 
+    * @param id the id
+    */
+   public void setId(String id)
+   {
+      this.id = id;
+   }
+
+   /**
+    * Get the ignored.
+    * 
+    * @return the ignored.
+    */
+   public Object getIgnored()
+   {
+      return ignored;
+   }
+
+   /**
+    * Set the ignored.
+    * 
+    * @param ignored the ignored.
+    */
+   @CompositeValue(ignore=true)
+   public void setIgnored(Object ignored)
+   {
+      this.ignored = ignored;
+   }
+}

Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestRenamedCompositeItem.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestRenamedCompositeItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestRenamedCompositeItem.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -0,0 +1,82 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.metatype.types.factory.support;
+
+import org.jboss.metatype.api.annotations.CompositeKey;
+import org.jboss.metatype.api.annotations.CompositeValue;
+
+/**
+ * TestRenamedCompositeItem.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestRenamedCompositeItem
+{
+   /** The id */
+   private String id;
+   
+   /** The renamed */
+   private String value;
+   
+   /**
+    * Get the id
+    * 
+    * @return the id
+    */
+   @CompositeKey
+   public String getId()
+   {
+      return id;
+   }
+
+   /**
+    * Set the id
+    * 
+    * @param id the id
+    */
+   public void setId(String id)
+   {
+      this.id = id;
+   }
+
+   /**
+    * Get the value.
+    * 
+    * @return the value.
+    */
+   public String getValue()
+   {
+      return value;
+   }
+
+   /**
+    * Set the value.
+    * 
+    * @param value the value.
+    */
+   @CompositeValue(name="renamed")
+   public void setValue(String value)
+   {
+      this.value = value;
+   }
+}

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-02-22 08:31:32 UTC (rev 70030)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/CompositeMetaTypeFactoryUnitTestCase.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -28,7 +28,9 @@
 import org.jboss.metatype.api.types.MetaType;
 import org.jboss.metatype.api.types.SimpleMetaType;
 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;
+import org.jboss.test.metatype.types.factory.support.TestRenamedCompositeItem;
 import org.jboss.test.metatype.types.factory.support.TestSimpleComposite;
 
 import junit.framework.Test;
@@ -97,4 +99,33 @@
       
       testComposite(expected, actual);
    }
+   
+   public void testIgnoredItem() throws Exception
+   {
+      MetaType<?> result = resolve(TestIgnoredCompositeItem.class);
+      CompositeMetaType actual = assertInstanceOf(result, CompositeMetaType.class);
+
+      MutableCompositeMetaType expected = new MutableCompositeMetaType(TestIgnoredCompositeItem.class.getName(), TestIgnoredCompositeItem.class.getName());
+      expected.addItem("id", "id", SimpleMetaType.STRING);
+      Set<String> keys = Collections.singleton("id");
+      expected.setKeys(keys);
+      expected.freeze();
+      
+      testComposite(expected, actual);
+   }
+   
+   public void testRenamedItem() throws Exception
+   {
+      MetaType<?> result = resolve(TestRenamedCompositeItem.class);
+      CompositeMetaType actual = assertInstanceOf(result, CompositeMetaType.class);
+      
+      MutableCompositeMetaType expected = new MutableCompositeMetaType(TestRenamedCompositeItem.class.getName(), TestRenamedCompositeItem.class.getName());
+      expected.addItem("id", "id", SimpleMetaType.STRING);
+      expected.addItem("renamed", "renamed", SimpleMetaType.STRING);
+      Set<String> keys = Collections.singleton("id");
+      expected.setKeys(keys);
+      expected.freeze();
+      
+      testComposite(expected, actual);
+   }
 }

Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestIgnoredCompositeItem.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestIgnoredCompositeItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestIgnoredCompositeItem.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -0,0 +1,82 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.metatype.values.factory.support;
+
+import org.jboss.metatype.api.annotations.CompositeKey;
+import org.jboss.metatype.api.annotations.CompositeValue;
+
+/**
+ * TestIgnoredCompositeItem.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestIgnoredCompositeItem
+{
+   /** The id */
+   private String id;
+   
+   /** The ignored */
+   private Object ignored;
+   
+   /**
+    * Get the id
+    * 
+    * @return the id
+    */
+   @CompositeKey
+   public String getId()
+   {
+      return id;
+   }
+
+   /**
+    * Set the id
+    * 
+    * @param id the id
+    */
+   public void setId(String id)
+   {
+      this.id = id;
+   }
+
+   /**
+    * Get the ignored.
+    * 
+    * @return the ignored.
+    */
+   public Object getIgnored()
+   {
+      return ignored;
+   }
+
+   /**
+    * Set the ignored.
+    * 
+    * @param ignored the ignored.
+    */
+   @CompositeValue(ignore=true)
+   public void setIgnored(Object ignored)
+   {
+      this.ignored = ignored;
+   }
+}

Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestMetaMapped.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestMetaMapped.java	                        (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestMetaMapped.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.metatype.values.factory.support;
+
+import org.jboss.metatype.api.annotations.MetaMapping;
+
+/**
+ * TestMetaMapped.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at MetaMapping(TestMetaMapper.class)
+public class TestMetaMapped
+{
+   private String value;
+   
+   public TestMetaMapped(String value)
+   {
+      this.value = value;
+   }
+   
+   public String getValue()
+   {
+      return value;
+   }
+}

Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestMetaMapper.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestMetaMapper.java	                        (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestMetaMapper.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -0,0 +1,61 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.metatype.values.factory.support;
+
+import java.lang.reflect.Type;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.MetaMapper;
+
+/**
+ * TestMetaMapper.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestMetaMapper extends MetaMapper<TestMetaMapped>
+{
+   @Override
+   public Type mapToType()
+   {
+      return String.class;
+   }
+
+   public MetaValue createMetaValue(MetaType<?> metaType, TestMetaMapped object)
+   {
+      return SimpleValueSupport.wrap(object.getValue());
+   }
+
+   public TestMetaMapped unwrapMetaValue(MetaValue metaValue)
+   {
+      if (SimpleMetaType.STRING.equals(metaValue.getMetaType()) == false)
+         throw new IllegalArgumentException("Not a string: " + metaValue);
+      
+      SimpleValue<?> simple = (SimpleValue<?>) metaValue;
+      String value = (String) simple.getValue();
+      return new TestMetaMapped(value);
+   }
+}

Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestRenamedCompositeItem.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestRenamedCompositeItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestRenamedCompositeItem.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -0,0 +1,93 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.metatype.values.factory.support;
+
+import org.jboss.metatype.api.annotations.CompositeKey;
+import org.jboss.metatype.api.annotations.CompositeValue;
+
+/**
+ * TestRenamedCompositeItem.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestRenamedCompositeItem
+{
+   /** The id */
+   private String id;
+   
+   /** The renamed */
+   private String value;
+   
+   /**
+    * Get the id
+    * 
+    * @return the id
+    */
+   @CompositeKey
+   public String getId()
+   {
+      return id;
+   }
+
+   /**
+    * Set the id
+    * 
+    * @param id the id
+    */
+   public void setId(String id)
+   {
+      this.id = id;
+   }
+
+   /**
+    * Get the value.
+    * 
+    * @return the value.
+    */
+   public String getValue()
+   {
+      return value;
+   }
+
+   /**
+    * Set the value.
+    * 
+    * @param value the value.
+    */
+   @CompositeValue(name="renamed")
+   public void setValue(String value)
+   {
+      this.value = value;
+   }
+   
+   public String getRenamed()
+   {
+      return value;
+   }
+   
+   @CompositeValue(ignore=true)
+   public void setRenamed(String value)
+   {
+      this.value = value;
+   }
+}

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-02-22 08:31:32 UTC (rev 70030)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/CompositeValueFactoryUnitTestCase.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -30,7 +30,9 @@
 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.values.factory.support.TestIgnoredCompositeItem;
 import org.jboss.test.metatype.values.factory.support.TestRecursiveComposite;
+import org.jboss.test.metatype.values.factory.support.TestRenamedCompositeItem;
 import org.jboss.test.metatype.values.factory.support.TestSimpleComposite;
 
 import junit.framework.Test;
@@ -108,4 +110,46 @@
       getLog().debug("Composite Value: " + actual);
       assertEquals(expected, actual);
    }
+
+   public void testIgnoreItem() throws Exception
+   {
+      MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestIgnoredCompositeItem.class.getName(), TestIgnoredCompositeItem.class.getName());
+      compositeType.addItem("id", "id", SimpleMetaType.STRING);
+      Set<String> keys = Collections.singleton("id");
+      compositeType.setKeys(keys);
+      compositeType.freeze();
+
+      CompositeValueSupport expected = new CompositeValueSupport(compositeType);
+      expected.set("id", SimpleValueSupport.wrap("Hello"));
+      
+      TestIgnoredCompositeItem object = new TestIgnoredCompositeItem();
+      object.setId("Hello");
+      object.setIgnored("Ignored?");
+      MetaValue result = createMetaValue(object);
+      CompositeValue actual = assertInstanceOf(result, CompositeValue.class);
+      getLog().debug("Composite Value: " + actual);
+      assertEquals(expected, actual);
+   }
+
+   public void testRenameItem() throws Exception
+   {
+      MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestRenamedCompositeItem.class.getName(), TestRenamedCompositeItem.class.getName());
+      compositeType.addItem("id", "id", SimpleMetaType.STRING);
+      compositeType.addItem("renamed", "renamed", SimpleMetaType.STRING);
+      Set<String> keys = Collections.singleton("id");
+      compositeType.setKeys(keys);
+      compositeType.freeze();
+
+      CompositeValueSupport expected = new CompositeValueSupport(compositeType);
+      expected.set("id", SimpleValueSupport.wrap("Hello"));
+      expected.set("renamed", SimpleValueSupport.wrap("Renamed"));
+      
+      TestRenamedCompositeItem object = new TestRenamedCompositeItem();
+      object.setId("Hello");
+      object.setValue("Renamed");
+      MetaValue result = createMetaValue(object);
+      CompositeValue actual = assertInstanceOf(result, CompositeValue.class);
+      getLog().debug("Composite Value: " + actual);
+      assertEquals(expected, actual);
+   }
 }

Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/MetaMapperUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/MetaMapperUnitTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/MetaMapperUnitTestCase.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -0,0 +1,63 @@
+/*
+* 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.metatype.values.factory.test;
+
+import junit.framework.Test;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.test.metatype.values.factory.support.TestMetaMapped;
+
+/**
+ * MetaMapperUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MetaMapperUnitTestCase extends AbstractMetaValueFactoryTest
+{
+   public static Test suite()
+   {
+      return suite(MetaMapperUnitTestCase.class);
+   }
+   
+   public MetaMapperUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testMetaMapper() throws Exception
+   {
+      MetaType<?> metaType = resolve(TestMetaMapped.class);
+      assertEquals(SimpleMetaType.STRING, metaType);
+      
+      TestMetaMapped test = new TestMetaMapped("Hello");
+      MetaValue value = createMetaValue(test);
+      MetaValue stringHello = createMetaValue("Hello");
+      assertEquals(stringHello, value);
+      
+      Object unwrapped = unwrapMetaValue(value, TestMetaMapped.class);
+      TestMetaMapped result = assertInstanceOf(unwrapped, TestMetaMapped.class);
+      assertEquals("Hello", result.getValue());
+   }
+}

Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/UnwrapValueUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/UnwrapValueUnitTestCase.java	2008-02-22 08:31:32 UTC (rev 70030)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/UnwrapValueUnitTestCase.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -34,11 +34,14 @@
 import java.util.Set;
 
 import junit.framework.Test;
+
 import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.test.metatype.values.factory.support.SimpleCompositeInterface;
 import org.jboss.test.metatype.values.factory.support.TestEnum;
 import org.jboss.test.metatype.values.factory.support.TestGeneric;
+import org.jboss.test.metatype.values.factory.support.TestIgnoredCompositeItem;
 import org.jboss.test.metatype.values.factory.support.TestRecursiveSimpleComposite;
+import org.jboss.test.metatype.values.factory.support.TestRenamedCompositeItem;
 import org.jboss.test.metatype.values.factory.support.TestSimpleComposite;
 import org.jboss.test.metatype.values.factory.support.TestSimpleCompositeInterface;
 
@@ -261,6 +264,34 @@
       checkSingle(map, mapType);
    }
 
+   public void testIgnoreItemUnwrap()
+   {
+      TestIgnoredCompositeItem ignored = new TestIgnoredCompositeItem();
+      ignored.setId("Id");
+      ignored.setIgnored("Ignored?");
+
+      MetaValue metaValue = createMetaValue(ignored);
+      assertNotNull(metaValue);
+      Object unwrapped = unwrapMetaValue(metaValue, TestIgnoredCompositeItem.class);
+      TestIgnoredCompositeItem result = assertInstanceOf(unwrapped, TestIgnoredCompositeItem.class);
+      assertEquals("Id", result.getId());
+      assertNull(result.getIgnored());
+   }
+
+   public void testRenamedItemUnwrap()
+   {
+      TestRenamedCompositeItem renamedCompositeItem = new TestRenamedCompositeItem();
+      renamedCompositeItem.setId("Id");
+      renamedCompositeItem.setValue("Renamed");
+
+      MetaValue metaValue = createMetaValue(renamedCompositeItem);
+      assertNotNull(metaValue);
+      Object unwrapped = unwrapMetaValue(metaValue, TestRenamedCompositeItem.class);
+      TestRenamedCompositeItem result = assertInstanceOf(unwrapped, TestRenamedCompositeItem.class);
+      assertEquals("Id", result.getId());
+      assertEquals("Renamed", result.getValue());
+   }
+   
    public Map<Integer, String> compositeValueMap()
    {
       return null;

Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/ValuesFactoryTestSuite.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/ValuesFactoryTestSuite.java	2008-02-22 08:31:32 UTC (rev 70030)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/ValuesFactoryTestSuite.java	2008-02-22 09:44:03 UTC (rev 70031)
@@ -61,6 +61,7 @@
       suite.addTest(CompositeValueFactoryUnitTestCase.suite());
       suite.addTest(AnnotationValueFactoryUnitTestCase.suite());
       suite.addTest(UnwrapValueUnitTestCase.suite());
+      suite.addTest(MetaMapperUnitTestCase.suite());
 
       return suite;
    }




More information about the jboss-cvs-commits mailing list