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 2002/09/24 22:50:08 UTC
cvs commit: jakarta-commons/digester/src/test/org/apache/commons/digester Test8.xml RuleTestCase.java
rdonkin 2002/09/24 13:50:08
Modified: digester/src/java/org/apache/commons/digester
CallParamRule.java
digester/src/test/org/apache/commons/digester
RuleTestCase.java
Added: digester/src/test/org/apache/commons/digester Test8.xml
Log:
Fix for bug #11693: CallMethod rule on nested indentical elements cause parameter confusion. Submitted by Emmanuel Bourg.
Revision Changes Path
1.8 +10 -6 jakarta-commons/digester/src/java/org/apache/commons/digester/CallParamRule.java
Index: CallParamRule.java
===================================================================
RCS file: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/CallParamRule.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CallParamRule.java 23 Mar 2002 17:45:57 -0000 1.7
+++ CallParamRule.java 24 Sep 2002 20:50:07 -0000 1.8
@@ -180,6 +180,8 @@
if (attributeName != null) {
bodyText = attributes.getValue(attributeName);
+ String parameters[] = (String[]) digester.peekParams();
+ parameters[paramIndex] = bodyText;
}
}
@@ -204,8 +206,10 @@
*/
public void end() throws Exception {
- String parameters[] = (String[]) digester.peekParams();
- parameters[paramIndex] = bodyText;
+ if (attributeName == null) {
+ String parameters[] = (String[]) digester.peekParams();
+ parameters[paramIndex] = bodyText;
+ }
}
1.21 +29 -4 jakarta-commons/digester/src/test/org/apache/commons/digester/RuleTestCase.java
Index: RuleTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/RuleTestCase.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- RuleTestCase.java 4 Sep 2002 18:01:16 -0000 1.20
+++ RuleTestCase.java 24 Sep 2002 20:50:07 -0000 1.21
@@ -830,4 +830,29 @@
}
+ /**
+ * Test nested CallMethod rules.
+ */
+ public void testCallMethod3() throws Exception {
+
+ // Configure the digester as required
+ StringBuffer word = new StringBuffer();
+ digester.push(word);
+ digester.addCallMethod("*/element", "append", 1);
+ digester.addCallParam("*/element", 0, "name");
+
+ // Parse our test input
+ Object root1 = null;
+ try {
+ // an exception will be thrown if the method can't be found
+ root1 = digester.parse(getInputStream("Test8.xml"));
+
+ } catch (Throwable t) {
+ // this means that the method can't be found and so the test fails
+ fail("Digester threw Exception: " + t);
+ }
+
+ assertEquals("Wrong method call order", "ABA", word.toString());
+
+ }
}
1.1 jakarta-commons/digester/src/test/org/apache/commons/digester/Test8.xml
Index: Test8.xml
===================================================================
<?xml version="1.0"?>
<toplevel>
<element name="A">
<element name="B">
<element name="A"/>
</element>
</element>
</toplevel>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>