You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rd...@apache.org on 2003/09/17 23:31:58 UTC

cvs commit: jakarta-commons/betwixt/src/test/org/apache/commons/betwixt TestBeanWriter.java

rdonkin     2003/09/17 14:31:58

  Modified:    betwixt/src/java/org/apache/commons/betwixt/digester
                        XMLIntrospectorHelper.java
               betwixt/src/test/org/apache/commons/betwixt
                        TestBeanWriter.java
  Log:
  Fixed bug when using writing a bean with an adder called add that adds to a collection. Submitted by Christoph Sturm.
  
  Revision  Changes    Path
  1.24      +3 -1      jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/XMLIntrospectorHelper.java
  
  Index: XMLIntrospectorHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/XMLIntrospectorHelper.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- XMLIntrospectorHelper.java	13 Jul 2003 21:28:10 -0000	1.23
  +++ XMLIntrospectorHelper.java	17 Sep 2003 21:31:58 -0000	1.24
  @@ -462,6 +462,8 @@
                           
                           if ( ( types.length == 1 ) || types.length == 2 ) {
                               String propertyName = Introspector.decapitalize( name.substring(3) );
  +                            if (propertyName.length() == 0)
  +                                continue;
                               if ( log.isTraceEnabled() ) {
                                   log.trace( name + "->" + propertyName );
                               }
  
  
  
  1.16      +28 -1     jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestBeanWriter.java
  
  Index: TestBeanWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestBeanWriter.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- TestBeanWriter.java	28 Jun 2003 10:34:28 -0000	1.15
  +++ TestBeanWriter.java	17 Sep 2003 21:31:58 -0000	1.16
  @@ -66,6 +66,7 @@
   import java.io.StringWriter;
   
   import java.util.ArrayList;
  +import java.util.Collection;
   
   import junit.framework.Test;
   import junit.framework.TestSuite;
  @@ -74,7 +75,6 @@
   import org.apache.commons.betwixt.io.BeanWriter;
   import org.apache.commons.betwixt.io.CyclicReferenceException;
   import org.apache.commons.logging.impl.SimpleLog;
  -import org.apache.commons.betwixt.digester.XMLIntrospectorHelper;
   import org.apache.commons.betwixt.strategy.CapitalizeNameMapper;
   import org.apache.commons.betwixt.strategy.HyphenatedNameMapper;
   
  @@ -669,6 +669,33 @@
                               parseString(out.getBuffer().toString()),
                               parseString(xml), 
                               true);
  +    }
  +    
  +    public void testBeanWriterWorksWithAnAddMethodAndACollection() throws Exception {
  +
  +        BeanWriter bw = new BeanWriter();
  +        try {
  +            bw.write(new BeanWithAddMethod());
  +        } catch (IllegalArgumentException e) {
  +            fail("BeanWriter fails when a method is just called add(<type>) and there is also a collection");
  +        }
  +    }
  +    
  +    // used in testBeanWriterWorksWithAnAddMethodAndACollection
  +    public static class BeanWithAddMethod {
  +        private Collection x;
  +        public void add(Object x)
  +        {
  +            // do nothing
  +        }
  +
  +        public Collection getX() {
  +            return x;
  +        }
  +
  +        public void setX(Collection x) {
  +            this.x = x;
  +        }        
       }
   }
   
  
  
  

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