jstrachan    02/02/19 07:31:30

  Modified:    betwixt  build.xml
               betwixt/src/java/org/apache/commons/betwixt
                        XMLIntrospector.java
               betwixt/src/java/org/apache/commons/betwixt/digester
                        AddDefaultsRule.java AttributeRule.java
               betwixt/src/test/org/apache/commons/betwixt
                        TestRSSRoundTrip.java TestXMLBeanInfoDigester.java
               betwixt/src/test/org/apache/commons/digester/rss
                        Channel.betwixt
  Added:       betwixt/src/test/org/apache/commons/digester/rss
                        Image.betwixt
  Log:
  Managed to get all the unit test cases working again, including the RSS round trip 
test that tests RSS -> digester -> betwixt -> RSS - > digester -> betwixt -> RSS round 
trip works without loss of information.
  
  Revision  Changes    Path
  1.13      +9 -3      jakarta-commons-sandbox/betwixt/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/betwixt/build.xml,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- build.xml 19 Feb 2002 06:10:26 -0000      1.12
  +++ build.xml 19 Feb 2002 15:31:30 -0000      1.13
  @@ -3,7 +3,7 @@
   
   <!--
           "Digester" component of the Jakarta Commons Subproject
  -        $Id: build.xml,v 1.12 2002/02/19 06:10:26 jstrachan Exp $
  +        $Id: build.xml,v 1.13 2002/02/19 15:31:30 jstrachan Exp $
   -->
   
   
  @@ -247,7 +247,6 @@
      description="Run all unit test cases">
       <java classname="org.apache.commons.betwixt.TestAll" fork="yes" 
failonerror="${test.failonerror}">
         <classpath refid="test.classpath"/>
  -      <sysproperty key="org.apache.commons.logging.simplelog.defaultlog" 
value="error"/>
       </java>
     </target>
   
  @@ -255,7 +254,6 @@
         description="Runs sample bean write">
       <java classname="org.apache.commons.betwixt.TestBeanWriter" fork="yes">
         <classpath refid="test.classpath"/>
  -      <sysproperty key="org.apache.commons.logging.log" 
value="org.apache.commons.logging.impl.SimpleLog"/>
         <sysproperty key="org.apache.commons.logging.simplelog.defaultlog" 
value="info"/>
       </java>
      </target>
  @@ -283,6 +281,14 @@
         <sysproperty 
key="org.apache.commons.logging.simplelog.log.org.apache.commons.digester.Digester" 
value="warn"/>
         <sysproperty 
key="org.apache.commons.logging.simplelog.log.org.apache.commons.digester.Digester.sax"
 value="warn"/>
         <sysproperty key="org.apache.commons.logging.simplelog.defaultlog" 
value="debug"/>
  +    </java>
  +   </target>
  +
  +   <target name="test.rss" depends="compile.tests" 
  +      description="Runs the RSS round trip unit tests">
  +    <java classname="org.apache.commons.betwixt.TestRSSRoundTrip" fork="yes">
  +      <classpath refid="test.classpath"/>
  +      <sysproperty key="org.apache.commons.logging.simplelog.defaultlog" 
value="info"/>
       </java>
      </target>
   
  
  
  
  1.17      +8 -6      
jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java
  
  Index: XMLIntrospector.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- XMLIntrospector.java      19 Feb 2002 06:10:26 -0000      1.16
  +++ XMLIntrospector.java      19 Feb 2002 15:31:30 -0000      1.17
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java,v
 1.16 2002/02/19 06:10:26 jstrachan Exp $
  - * $Revision: 1.16 $
  - * $Date: 2002/02/19 06:10:26 $
  + * $Header: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java,v
 1.17 2002/02/19 15:31:30 jstrachan Exp $
  + * $Revision: 1.17 $
  + * $Date: 2002/02/19 15:31:30 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: XMLIntrospector.java,v 1.16 2002/02/19 06:10:26 jstrachan Exp $
  + * $Id: XMLIntrospector.java,v 1.17 2002/02/19 15:31:30 jstrachan Exp $
    */
   package org.apache.commons.betwixt;
   
  @@ -99,7 +99,7 @@
     * Later requests for the same class will return the cached value.</p>
     *
     * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
  -  * @version $Revision: 1.16 $
  +  * @version $Revision: 1.17 $
     */
   public class XMLIntrospector {
   
  @@ -175,7 +175,9 @@
           }
           if (xmlInfo == null) {
               // lets see if we can find an XML descriptor first
  -            log.info( "Attempting to lookup an XML descriptor for class: " + aClass 
);
  +            if ( log.isDebugEnabled() ) {
  +                log.debug( "Attempting to lookup an XML descriptor for class: " + 
aClass );
  +            }
               
               xmlInfo = findByXMLDescriptor( aClass );
               if ( xmlInfo == null ) {
  
  
  
  1.2       +5 -3      
jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/AddDefaultsRule.java
  
  Index: AddDefaultsRule.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/AddDefaultsRule.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AddDefaultsRule.java      19 Feb 2002 06:10:26 -0000      1.1
  +++ AddDefaultsRule.java      19 Feb 2002 15:31:30 -0000      1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/AddDefaultsRule.java,v
 1.1 2002/02/19 06:10:26 jstrachan Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/19 06:10:26 $
  + * $Header: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/AddDefaultsRule.java,v
 1.2 2002/02/19 15:31:30 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/02/19 15:31:30 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: AddDefaultsRule.java,v 1.1 2002/02/19 06:10:26 jstrachan Exp $
  + * $Id: AddDefaultsRule.java,v 1.2 2002/02/19 15:31:30 jstrachan Exp $
    */
   package org.apache.commons.betwixt.digester;
   
  @@ -87,7 +87,7 @@
     * to the current element.</p>
     *
     * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public class AddDefaultsRule extends RuleSupport {
   
  @@ -144,6 +144,8 @@
       protected void addDescriptor( NodeDescriptor nodeDescriptor ) throws 
SAXException {
           Object top = digester.peek();
           if ( top instanceof XMLBeanInfo ) {
  +            log.warn( "It is advisable to put an <addDefaults/> element inside an 
<element> tag" );
  +            
               XMLBeanInfo beanInfo = (XMLBeanInfo) top;
               // if there is already a root element descriptor then use it
               // otherwise use this descriptor
  
  
  
  1.2       +20 -17    
jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/AttributeRule.java
  
  Index: AttributeRule.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/AttributeRule.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AttributeRule.java        19 Feb 2002 06:10:26 -0000      1.1
  +++ AttributeRule.java        19 Feb 2002 15:31:30 -0000      1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/AttributeRule.java,v
 1.1 2002/02/19 06:10:26 jstrachan Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/19 06:10:26 $
  + * $Header: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/AttributeRule.java,v
 1.2 2002/02/19 15:31:30 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/02/19 15:31:30 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: AttributeRule.java,v 1.1 2002/02/19 06:10:26 jstrachan Exp $
  + * $Id: AttributeRule.java,v 1.2 2002/02/19 15:31:30 jstrachan Exp $
    */
   package org.apache.commons.betwixt.digester;
   
  @@ -88,7 +88,7 @@
   /** <p><code>AttributeRule</code> the digester Rule for parsing the 
&lt;attribute&gt; elements.</p>
     *
     * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public class AttributeRule extends RuleSupport {
   
  @@ -173,23 +173,26 @@
       
       /** Set the Expression and Updater from a bean property name */
       protected void configureDescriptor(AttributeDescriptor attributeDescriptor) {
  -        String name = attributeDescriptor.getPropertyName();
  -        try {
  -            BeanInfo beanInfo = Introspector.getBeanInfo( getBeanClass());
  -            PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
  -            if ( descriptors != null ) {
  -                for ( int i = 0, size = descriptors.length; i < size; i++ ) {
  -                    PropertyDescriptor descriptor = descriptors[i];
  -                    if ( name.equals( descriptor.getName() ) ) {
  -                        XMLIntrospectorHelper.configureProperty( 
attributeDescriptor, descriptor );
  -                        getProcessedPropertyNameSet().add( name );
  -                        break;
  +        Class beanClass = getBeanClass();
  +        if ( beanClass != null ) {
  +            String name = attributeDescriptor.getPropertyName();
  +            try {
  +                BeanInfo beanInfo = Introspector.getBeanInfo( beanClass );
  +                PropertyDescriptor[] descriptors = 
beanInfo.getPropertyDescriptors();
  +                if ( descriptors != null ) {
  +                    for ( int i = 0, size = descriptors.length; i < size; i++ ) {
  +                        PropertyDescriptor descriptor = descriptors[i];
  +                        if ( name.equals( descriptor.getName() ) ) {
  +                            XMLIntrospectorHelper.configureProperty( 
attributeDescriptor, descriptor );
  +                            getProcessedPropertyNameSet().add( name );
  +                            break;
  +                        }
                       }
                   }
               }
  -        }
  -        catch (Exception e) {
  -            log.warn( "Caught introspection exception", e );
  +            catch (Exception e) {
  +                log.warn( "Caught introspection exception", e );
  +            }
           }
       }    
   }
  
  
  
  1.2       +10 -7     
jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/TestRSSRoundTrip.java
  
  Index: TestRSSRoundTrip.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/TestRSSRoundTrip.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestRSSRoundTrip.java     19 Feb 2002 06:10:27 -0000      1.1
  +++ TestRSSRoundTrip.java     19 Feb 2002 15:31:30 -0000      1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/TestRSSRoundTrip.java,v
 1.1 2002/02/19 06:10:27 jstrachan Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/19 06:10:27 $
  + * $Header: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/TestRSSRoundTrip.java,v
 1.2 2002/02/19 15:31:30 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/02/19 15:31:30 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: TestRSSRoundTrip.java,v 1.1 2002/02/19 06:10:27 jstrachan Exp $
  + * $Id: TestRSSRoundTrip.java,v 1.2 2002/02/19 15:31:30 jstrachan Exp $
    */
   package org.apache.commons.betwixt;
   
  @@ -85,7 +85,7 @@
     * to check that the document is parseable again.
     *
     * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public class TestRSSRoundTrip extends AbstractTestCase {
       
  @@ -116,7 +116,7 @@
           write( bean, buffer );
           
           // now lets try parse again
  -        String text = buffer.toString();
  +        String text = buffer.toString();        
           bean = digester.parse( new StringReader( text ) );
           
           // managed to parse it again!
  @@ -126,7 +126,10 @@
           write( bean, buffer );
           
           String text2 = buffer.toString();
  -        
  +
  +        // if the two strings are equal then we've done a full round trip
  +        // with the XML staying the same. Though the original source XML
  +        // could well be different
           assertEquals( "Round trip value should remain unchanged", text, text2 );
       }
       
  
  
  
  1.3       +7 -8      
jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/TestXMLBeanInfoDigester.java
  
  Index: TestXMLBeanInfoDigester.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/TestXMLBeanInfoDigester.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestXMLBeanInfoDigester.java      19 Feb 2002 06:10:27 -0000      1.2
  +++ TestXMLBeanInfoDigester.java      19 Feb 2002 15:31:30 -0000      1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/TestXMLBeanInfoDigester.java,v
 1.2 2002/02/19 06:10:27 jstrachan Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/19 06:10:27 $
  + * $Header: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/TestXMLBeanInfoDigester.java,v
 1.3 2002/02/19 15:31:30 jstrachan Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/02/19 15:31:30 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: TestXMLBeanInfoDigester.java,v 1.2 2002/02/19 06:10:27 jstrachan Exp $
  + * $Id: TestXMLBeanInfoDigester.java,v 1.3 2002/02/19 15:31:30 jstrachan Exp $
    */
   package org.apache.commons.betwixt;
   
  @@ -74,7 +74,7 @@
   /** Test harness for the Digester of XMLBeanInfo
     *
     * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
  -  * @version $Revision: 1.2 $
  +  * @version $Revision: 1.3 $
     */
   public class TestXMLBeanInfoDigester extends AbstractTestCase {
       
  @@ -104,15 +104,14 @@
           ElementDescriptor descriptor = info.getElementDescriptor();
           
           assertTrue( "Found root element descriptor", descriptor != null );
  -        assertEquals( "Element name correct", "channel", descriptor.getLocalName() 
);
  +        assertEquals( "Element name correct", "rss", descriptor.getLocalName() );
           
           ElementDescriptor[] elements = descriptor.getElementDescriptors();
           
           assertTrue( "Found elements", elements != null && elements.length > 0 );
           
           descriptor = elements[0];
  -        assertEquals( "Element name correct", "title", descriptor.getLocalName() );
  -        assertEquals( "Element property correct", "title", 
descriptor.getPropertyName() );
  +        assertEquals( "Element name correct", "channel", descriptor.getLocalName() 
);
       }
   }
   
  
  
  
  1.2       +4 -3      
jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/digester/rss/Channel.betwixt
  
  Index: Channel.betwixt
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/digester/rss/Channel.betwixt,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Channel.betwixt   19 Feb 2002 06:10:27 -0000      1.1
  +++ Channel.betwixt   19 Feb 2002 15:31:30 -0000      1.2
  @@ -1,11 +1,12 @@
   <?xml version="1.0" encoding="UTF-8" ?>
   <info primitiveTypes="element">
     <element name="rss">
  -    <attribute name="version" value="0.91"/>
  +    <attribute name="version" property="version"/>
       <element name="channel">
  -      <element name="title" property="title"/>
  +      <element name="title"  property="title"/>
         <element name="item"  property="items"/>
  +      <element name="textinput"  property="textInput"/>
  +      <addDefaults/>
       </element>
  -    <addDefaults/>
     </element>
   </info>
  
  
  
  1.1                  
jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/digester/rss/Image.betwixt
  
  Index: Image.betwixt
  ===================================================================
  <?xml version="1.0" encoding="UTF-8" ?>
  <info primitiveTypes="element">
    <element name="image">
      <element name="url" property="URL"/>
      <addDefaults/>
    </element>
  </info>
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to