You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ba...@apache.org on 2007/08/21 18:41:17 UTC

svn commit: r568192 - in /commons/proper/digester/trunk/src: java/org/apache/commons/digester/SetPropertyRule.java test/org/apache/commons/digester/SetPropertyRuleTestCase.java

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));
+    } 
+
 }
 
 



Re: svn commit: r568192 - in /commons/proper/digester/trunk/src: java/org/apache/commons/digester/SetPropertyRule.java test/org/apache/commons/digester/SetPropertyRuleTestCase.java

Posted by Henri Yandell <fl...@gmail.com>.
Hope no one minds my having committed this. I don't commit to Digester
very often, but as that one was on a list of interesting issues I'm
working through, I figured I'd go ahead and see if anyone was upset :)

Hen

On 8/21/07, bayard@apache.org <ba...@apache.org> wrote:
> 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));
> +    }
> +
>  }
>
>
>
>
>

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