ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r472761 - in /ant/core/trunk: WHATSNEW src/etc/testcases/taskdefs/optional/junit/matches.xml src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java
Date Thu, 09 Nov 2006 03:45:48 GMT
Author: antoine
Date: Wed Nov  8 19:45:48 2006
New Revision: 472761

URL: http://svn.apache.org/viewvc?view=rev&rev=472761
Log:
Incorrect recursion in DOMUtil.listChildNodes()
Bugzilla 40918.


Added:
    ant/core/trunk/src/etc/testcases/taskdefs/optional/junit/matches.xml
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java
Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?view=diff&rev=472761&r1=472760&r2=472761
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Wed Nov  8 19:45:48 2006
@@ -10,6 +10,9 @@
 * docletpath attribute of javadoc ignored.
   Bugzilla 40900.
 
+* Incorrect recursion in DOMUtil.listChildNodes()
+  Bugzilla 40918.
+
 Other changes:
 --------------
 

Added: ant/core/trunk/src/etc/testcases/taskdefs/optional/junit/matches.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/optional/junit/matches.xml?view=auto&rev=472761
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/optional/junit/matches.xml (added)
+++ ant/core/trunk/src/etc/testcases/taskdefs/optional/junit/matches.xml Wed Nov  8 19:45:48
2006
@@ -0,0 +1,8 @@
+<matches>
+  <foo>
+    <abc>
+      <foo/>
+      <foo/>
+    </abc>
+  </foo>
+</matches>
\ No newline at end of file

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java?view=diff&rev=472761&r1=472760&r2=472761
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java Wed
Nov  8 19:45:48 2006
@@ -73,7 +73,7 @@
                 }
                 if (recurse) {
                     NodeList recmatches = listChildNodes(child, filter, recurse);
-                    final int reclength = matches.getLength();
+                    final int reclength = recmatches.getLength();
                     for (int j = 0; j < reclength; j++) {
                         matches.addElement(recmatches.item(i));
                     }

Added: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java?view=auto&rev=472761
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java
(added)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java
Wed Nov  8 19:45:48 2006
@@ -0,0 +1,49 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.tools.ant.taskdefs.optional.junit;
+
+import junit.framework.TestCase;
+
+import javax.xml.parsers.DocumentBuilder;
+
+import org.apache.tools.ant.util.JAXPUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+public class DOMUtilTest extends TestCase {
+    public void testListChildNodes() throws SAXException, IOException {
+        DocumentBuilder db = JAXPUtils.getDocumentBuilder();
+        InputStream is = this.getClass().getClassLoader().getResourceAsStream("taskdefs/optional/junit/matches.xml");
+        Document doc = db.parse(is);
+        NodeList nl = DOMUtil.listChildNodes(doc.getFirstChild(), new FooNodeFilter(), true);
+        assertEquals(nl.getLength(), 3);
+    }
+    public class FooNodeFilter implements DOMUtil.NodeFilter {
+        public boolean accept(Node node) {
+            if (node.getNodeName().equals("foo")) {
+                return true;
+            }
+            return false;  //To change body of implemented methods use File | Settings |
File Templates.
+        }
+    }
+}



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


Mime
View raw message