commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r568192 - in /commons/proper/digester/trunk/src: java/org/apache/commons/digester/SetPropertyRule.java test/org/apache/commons/digester/SetPropertyRuleTestCase.java
Date Tue, 21 Aug 2007 16:41:17 GMT
Author: bayard
Date: Tue Aug 21 09:41:16 2007
New Revision: 568192

URL: http://svn.apache.org/viewvc?rev=568192&view=rev
Log:
Applying the patch from DIGESTER-114 - stopping an IllegalArgumentException when the element
has no attributes. After reviewing test and fix, it all looks good to me. 

Modified:
    commons/proper/digester/trunk/src/java/org/apache/commons/digester/SetPropertyRule.java
    commons/proper/digester/trunk/src/test/org/apache/commons/digester/SetPropertyRuleTestCase.java

Modified: commons/proper/digester/trunk/src/java/org/apache/commons/digester/SetPropertyRule.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/java/org/apache/commons/digester/SetPropertyRule.java?rev=568192&r1=568191&r2=568192&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/java/org/apache/commons/digester/SetPropertyRule.java
(original)
+++ commons/proper/digester/trunk/src/java/org/apache/commons/digester/SetPropertyRule.java
Tue Aug 21 09:41:16 2007
@@ -103,6 +103,10 @@
      */
     public void begin(Attributes attributes) throws Exception {
 
+        if (attributes.getLength() == 0 ) {
+            return;
+        }
+
         // Identify the actual property name and value to be used
         String actualName = null;
         String actualValue = null;

Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/SetPropertyRuleTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/SetPropertyRuleTestCase.java?rev=568192&r1=568191&r2=568192&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/SetPropertyRuleTestCase.java
(original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/SetPropertyRuleTestCase.java
Tue Aug 21 09:41:16 2007
@@ -201,6 +201,21 @@
         return new StringReader(xml);
     }
 
+    /**
+     * Test SetPropertyRule when matched XML element has no attributes.
+     * See: DIGESTER-114
+     */
+    public void testElementWithNoAttributes() throws Exception {
+        String TEST_XML_3 = "<?xml version='1.0'?><root><set/></root>";
+
+        // Set up the rules we need
+        digester.addObjectCreate("root", "org.apache.commons.digester.SimpleTestBean");
+        digester.addSetProperty("root/set", "name", "value");
+
+        // Parse the input - should not throw an exception
+        SimpleTestBean bean = (SimpleTestBean) digester.parse(xmlTestReader(TEST_XML_3));
+    } 
+
 }
 
 



Mime
View raw message