commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r216221 - in /jakarta/commons/proper/betwixt/trunk/src: java/org/apache/commons/betwixt/digester/AddDefaultsRule.java test/org/apache/commons/betwixt/dotbetwixt/IgnoreAddersBean.java test/org/apache/commons/betwixt/dotbetwixt/TestLoopType.java
Date Wed, 13 Jul 2005 18:57:40 GMT
Author: rdonkin
Date: Wed Jul 13 11:57:39 2005
New Revision: 216221

URL: http://svn.apache.org/viewcvs?rev=216221&view=rev
Log:
Fix for add-adder coding error spotted byGlenn Goldenberg. Fixed for test case for simpliest
test case. Probably need to follow this up by more comprehensive test cases for complex cases.

Modified:
    jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/digester/AddDefaultsRule.java
    jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/dotbetwixt/IgnoreAddersBean.java
    jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/dotbetwixt/TestLoopType.java

Modified: jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/digester/AddDefaultsRule.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/digester/AddDefaultsRule.java?rev=216221&r1=216220&r2=216221&view=diff
==============================================================================
--- jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/digester/AddDefaultsRule.java
(original)
+++ jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/digester/AddDefaultsRule.java
Wed Jul 13 11:57:39 2005
@@ -66,7 +66,7 @@
         String addAddersAttributeValue = attributes.getValue("add-adders");
         if (addAddersAttributeValue != null)
         {
-            addProperties = Boolean.valueOf(addAddersAttributeValue).booleanValue();
+            addAdders = Boolean.valueOf(addAddersAttributeValue).booleanValue();
         }
         
         if (addProperties) {

Modified: jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/dotbetwixt/IgnoreAddersBean.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/dotbetwixt/IgnoreAddersBean.java?rev=216221&r1=216220&r2=216221&view=diff
==============================================================================
--- jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/dotbetwixt/IgnoreAddersBean.java
(original)
+++ jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/dotbetwixt/IgnoreAddersBean.java
Wed Jul 13 11:57:39 2005
@@ -17,6 +17,8 @@
 
 package org.apache.commons.betwixt.dotbetwixt;
 
+import java.util.ArrayList;
+
 /**
  * @author <a href='http://jakarta.apache.org/'>Jakarta Commons Team</a>
  * @version $Revision$
@@ -25,6 +27,7 @@
     
     private String alpha;
     private String beta;
+    private ArrayList gammas;
     
     public String getAlpha() {
         return alpha;
@@ -41,5 +44,13 @@
     public void setBeta(String string) {
         beta = string;
     }
+    
+    public ArrayList getGammas() {
+        return gammas;
+    }
 
+    public void addGamma(String gamma) {
+        gammas.add(gamma);
+    }
+    
 }

Modified: jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/dotbetwixt/TestLoopType.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/dotbetwixt/TestLoopType.java?rev=216221&r1=216220&r2=216221&view=diff
==============================================================================
--- jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/dotbetwixt/TestLoopType.java
(original)
+++ jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/dotbetwixt/TestLoopType.java
Wed Jul 13 11:57:39 2005
@@ -78,16 +78,31 @@
      
     }
     
-
+    /**
+     * Basic test for add-adders attribute of addDefaults tag.
+     * @throws Exception
+     */
     public void testIgnoredAdders() throws Exception {
         XMLIntrospector introspector = new XMLIntrospector();
+        // ignore adders bean uses a dot betwixt file with add-adders false
         XMLBeanInfo beanInfo = introspector.introspect(IgnoreAddersBean.class);
         ElementDescriptor ignoreDescriptor = beanInfo.getElementDescriptor();
         
         assertEquals("element name matches", "ignore", ignoreDescriptor.getLocalName());
         ElementDescriptor[] childDescriptors = ignoreDescriptor.getElementDescriptors();
-        assertEquals("number of child elements", 1, childDescriptors.length);
-                    
+        assertEquals("number of child elements", 2, childDescriptors.length);
+        for (int i=0; i<childDescriptors.length; i++) {
+            ElementDescriptor descriptor = childDescriptors[i];
+            if (descriptor.getLocalName().equals("gammas")) {
+                assertNull("Expected descriptor to be null since adders must be explicitly
listed.", descriptor.getUpdater()); 
+            }
+            else {
+                assertEquals("alpha", descriptor.getLocalName());
+            }
+        }
+        AttributeDescriptor[] attributes = ignoreDescriptor.getAttributeDescriptors();
+        assertEquals(1, attributes.length);
+        assertEquals("beta", attributes[0].getLocalName());
     }
     
     //TODO: complete these tests after refactoring the element descriptors produced is complete



---------------------------------------------------------------------
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