commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject cvs commit: jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/introspection TestDeclarativeIntrospection.java
Date Sun, 22 Feb 2004 17:09:08 GMT
rdonkin     2004/02/22 09:09:08

  Modified:    betwixt/src/java/org/apache/commons/betwixt/io Tag:
                        REFACTORING-BRANCH_2004-01-13 BeanRuleSet.java
               betwixt/src/java/org/apache/commons/betwixt/io/read Tag:
                        REFACTORING-BRANCH_2004-01-13 BeanBindAction.java
               betwixt/src/test/org/apache/commons/betwixt/introspection
                        Tag: REFACTORING-BRANCH_2004-01-13
                        TestDeclarativeIntrospection.java
  Log:
  Fixed a bug with maps.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.16.2.8  +4 -7      jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanRuleSet.java
  
  Index: BeanRuleSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanRuleSet.java,v
  retrieving revision 1.16.2.7
  retrieving revision 1.16.2.8
  diff -u -r1.16.2.7 -r1.16.2.8
  --- BeanRuleSet.java	21 Feb 2004 17:20:06 -0000	1.16.2.7
  +++ BeanRuleSet.java	22 Feb 2004 17:09:08 -0000	1.16.2.8
  @@ -60,8 +60,6 @@
    */
   package org.apache.commons.betwixt.io;
   
  -import java.beans.IntrospectionException;
  -
   import org.apache.commons.betwixt.BindingConfiguration;
   import org.apache.commons.betwixt.ElementDescriptor;
   import org.apache.commons.betwixt.XMLIntrospector;
  @@ -70,7 +68,6 @@
   import org.apache.commons.betwixt.io.read.MappingAction;
   import org.apache.commons.betwixt.io.read.ReadConfiguration;
   import org.apache.commons.betwixt.io.read.ReadContext;
  -import org.apache.commons.betwixt.io.read.SimpleTypeBindAction;
   import org.apache.commons.digester.Digester;
   import org.apache.commons.digester.Rule;
   import org.apache.commons.digester.RuleSet;
  
  
  
  No                   revision
  No                   revision
  1.1.2.6   +8 -7      jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/read/Attic/BeanBindAction.java
  
  Index: BeanBindAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/read/Attic/BeanBindAction.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- BeanBindAction.java	21 Feb 2004 16:58:58 -0000	1.1.2.5
  +++ BeanBindAction.java	22 Feb 2004 17:09:08 -0000	1.1.2.6
  @@ -176,8 +176,9 @@
   
           Object instance = null;
           Class beanClass = computedDescriptor.getSingularPropertyType();
  -
  -        if (beanClass != null) {
  +        // TODO: this is a bit of a workaround 
  +        // need to come up with a better way of doing maps
  +        if (beanClass != null && !Map.class.isAssignableFrom(beanClass)) {
   
               instance =
                   createBean(
  
  
  
  No                   revision
  No                   revision
  1.1.2.8   +38 -4     jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/introspection/Attic/TestDeclarativeIntrospection.java
  
  Index: TestDeclarativeIntrospection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/introspection/Attic/TestDeclarativeIntrospection.java,v
  retrieving revision 1.1.2.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- TestDeclarativeIntrospection.java	21 Feb 2004 13:39:06 -0000	1.1.2.7
  +++ TestDeclarativeIntrospection.java	22 Feb 2004 17:09:08 -0000	1.1.2.8
  @@ -361,4 +361,38 @@
           assertNotNull("Value should have an updater", valueDescriptor.getUpdater());
       }
       
  +    public void testConcreteMapNoWrap() throws Exception {
  +        XMLIntrospector introspector = new XMLIntrospector();
  +        introspector.getConfiguration().setWrapCollectionsInElement(false);
  +        XMLBeanInfo beanInfo = introspector.introspect(BeanWithConcreteMap.class);
  +        ElementDescriptor beanDescriptor = beanInfo.getElementDescriptor();
  +        
  +        ElementDescriptor[] beanChildDescriptors = beanDescriptor.getElementDescriptors();
  +        assertEquals("One Entry element", 1, beanChildDescriptors.length);
  +        
  +        ElementDescriptor entry = beanChildDescriptors[0];
  +        ElementDescriptor[] entryChildren = entry.getElementDescriptors();
  +        assertEquals("Expected key and entry elements", 2 , entryChildren.length);    
   
  +    }
  +    
  +    public void testConcreteMapWithWrap() throws Exception {
  +        XMLIntrospector introspector = new XMLIntrospector();
  +        introspector.getConfiguration().setWrapCollectionsInElement(true);
  +        XMLBeanInfo beanInfo = introspector.introspect(BeanWithConcreteMap.class);
  +        
  +        ElementDescriptor beanDescriptor = beanInfo.getElementDescriptor();
  +        
  +        ElementDescriptor[] beanChildDescriptors = beanDescriptor.getElementDescriptors();
  +        assertEquals("One wrapper element", 1, beanChildDescriptors.length);
  +        
  +        ElementDescriptor wrapper = beanChildDescriptors[0];
  +        ElementDescriptor[] wrapperChildren = wrapper.getElementDescriptors();
  +        assertEquals("One Entry element", 1, wrapperChildren.length);
  +        
  +        ElementDescriptor entry = wrapperChildren[0];
  +        ElementDescriptor[] entryChildren = entry.getElementDescriptors();
  +        assertEquals("Expected key and entry elements", 2 , entryChildren.length);
  +        
  +        
  +    }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message