vgritsenko 2005/03/30 19:46:02
Modified: java/src/org/apache/xindice/xml/dom NodeListImpl.java Added: java/tests/src/org/apache/xindice/xml/dom NodeListTest.java Log: add test for Bug #31402 Revision Changes Path 1.1 xml-xindice/java/tests/src/org/apache/xindice/xml/dom/NodeListTest.java Index: NodeListTest.java =================================================================== /* * Copyright 2005 The Apache Software Foundation. * * Licensed 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. * * CVS $Id: NodeListTest.java,v 1.1 2005/03/31 03:46:02 vgritsenko Exp $ */ package org.apache.xindice.xml.dom; import org.apache.xindice.xml.dom.traversal.TreeWalkerImpl; import junit.framework.TestCase; import org.w3c.dom.Node; import org.w3c.dom.DOMException; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.w3c.dom.traversal.NodeFilter; import org.w3c.dom.traversal.TreeWalker; /** * Tests NodeListImpl class * * @version CVS $Revision: 1.1 $, $Date: 2005/03/31 03:46:02 $ */ public class NodeListTest extends TestCase { private static final String XML = "<a>" + "<b/>" + "<c>" + "<d/>" + "</c>" + "<i/>" + "</a>"; private Node dom; public void setUp() throws Exception { dom = DOMParser.toDocument(XML).getDocumentElement(); } public void testElementsByTagName() throws Exception { Element element = (Element) this.dom.getFirstChild().getNextSibling(); assertEquals("c", element.getTagName()); NodeList list = element.getElementsByTagName("i"); assertEquals(0, list.getLength()); list = element.getElementsByTagName("d"); assertEquals(1, list.getLength()); assertEquals("d", ((Element) list.item(0)).getTagName()); } } 1.7 +5 -6 xml-xindice/java/src/org/apache/xindice/xml/dom/NodeListImpl.java Index: NodeListImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/dom/NodeListImpl.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- NodeListImpl.java 8 Feb 2004 03:11:56 -0000 1.6 +++ NodeListImpl.java 31 Mar 2005 03:46:02 -0000 1.7 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,6 @@ * * CVS $Id$ */ - package org.apache.xindice.xml.dom; import org.w3c.dom.Node; @@ -30,7 +29,7 @@ */ public class NodeListImpl extends ArrayList implements NodeList { - protected NodeImpl owner = null; + protected NodeImpl owner; public NodeListImpl(NodeImpl owner) { this.owner = owner; @@ -48,7 +47,7 @@ public final Node item(int index) { try { return (Node) get(index); - } catch (IndexOutOfBoundsException ioobe) { + } catch (IndexOutOfBoundsException e) { return null; } }