hillion 02/03/19 05:43:55 Modified: sources/org/apache/batik/dom AbstractParentNode.java test-resources/org/apache/batik/dom dummyXML3.xml unitTesting.xml Added: test-sources/org/apache/batik/dom HasChildNodesTest.java ReplaceChildTest.java Log: Added DOM tests. Revision Changes Path 1.14 +3 -1 xml-batik/sources/org/apache/batik/dom/AbstractParentNode.java Index: AbstractParentNode.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractParentNode.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- AbstractParentNode.java 19 Mar 2002 09:25:40 -0000 1.13 +++ AbstractParentNode.java 19 Mar 2002 13:43:54 -0000 1.14 @@ -24,7 +24,7 @@ * This class implements the Node interface with support for children. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: AbstractParentNode.java,v 1.13 2002/03/19 09:25:40 hillion Exp $ + * @version $Id: AbstractParentNode.java,v 1.14 2002/03/19 13:43:54 hillion Exp $ */ public abstract class AbstractParentNode extends AbstractNode { @@ -175,7 +175,9 @@ nodeToBeRemoved(oldChild); // Node modification + System.out.println("LEN1: " + childNodes.getLength()); ExtendedNode result = childNodes.remove((ExtendedNode)oldChild); + System.out.println("LEN2: " + childNodes.getLength()); result.setParentNode(null); // Mutation event 1.2 +1 -0 xml-batik/test-resources/org/apache/batik/dom/dummyXML3.xml Index: dummyXML3.xml =================================================================== RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/dom/dummyXML3.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- dummyXML3.xml 19 Mar 2002 09:25:41 -0000 1.1 +++ dummyXML3.xml 19 Mar 2002 13:43:54 -0000 1.2 @@ -3,4 +3,5 @@ <elt2 id="elt2" attr2="value2" xmlns=""> Content </elt2> + <elt3/> </doc> 1.4 +21 -1 xml-batik/test-resources/org/apache/batik/dom/unitTesting.xml Index: unitTesting.xml =================================================================== RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/dom/unitTesting.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- unitTesting.xml 19 Mar 2002 09:25:41 -0000 1.3 +++ unitTesting.xml 19 Mar 2002 13:43:54 -0000 1.4 @@ -9,7 +9,7 @@ <!-- ========================================================================= --> <!-- @author [EMAIL PROTECTED] --> <!-- @author [EMAIL PROTECTED] --> -<!-- @version $Id: unitTesting.xml,v 1.3 2002/03/19 09:25:41 hillion Exp $ --> +<!-- @version $Id: unitTesting.xml,v 1.4 2002/03/19 13:43:54 hillion Exp $ --> <!-- ========================================================================= --> <testSuite id="dom.unitTesting" name="org.apache.batik.dom package - Unit Testing"> @@ -43,6 +43,26 @@ value="test-resources/org/apache/batik/dom/dummyXML3.xml" /> <arg class="java.lang.String" value="doc" /> <arg class="java.lang.String" value="elt2" /> + </test> + + <!-- ========================================================================== --> + <!-- hasChildNodes test --> + <!-- ========================================================================== --> + <test id="hasChildNodes" class="org.apache.batik.dom.HasChildNodesTest" > + <arg class="java.lang.String" + value="test-resources/org/apache/batik/dom/dummyXML3.xml" /> + <arg class="java.lang.String" value="doc" /> + <arg class="java.lang.String" value="root" /> + </test> + + <!-- ========================================================================== --> + <!-- replaceChild test --> + <!-- ========================================================================== --> + <test id="replaceChild" class="org.apache.batik.dom.ReplaceChildTest" > + <arg class="java.lang.String" + value="test-resources/org/apache/batik/dom/dummyXML3.xml" /> + <arg class="java.lang.String" value="doc" /> + <arg class="java.lang.String" value="root" /> </test> <!-- ========================================================================== --> 1.1 xml-batik/test-sources/org/apache/batik/dom/HasChildNodesTest.java Index: HasChildNodesTest.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.batik.dom; import org.w3c.dom.*; import java.io.*; import java.net.*; import org.apache.batik.dom.util.*; import org.apache.batik.util.*; import org.apache.batik.test.*; /** * This class tests the hasChildNodes method. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> * @version $Id: HasChildNodesTest.java,v 1.1 2002/03/19 13:43:55 hillion Exp $ */ public class HasChildNodesTest extends AbstractTest { public static String ERROR_GET_ELEMENT_BY_ID_FAILED = "error.get.element.by.id.failed"; public static String ENTRY_KEY_ID = "entry.key.id"; protected String testFileName; protected String rootTag; protected String targetId; public HasChildNodesTest(String file, String root, String id) { testFileName = file; rootTag = root; targetId = id; } public TestReport runImpl() throws Exception { String parser = XMLResourceDescriptor.getXMLParserClassName(); DocumentFactory df = new SAXDocumentFactory (GenericDOMImplementation.getDOMImplementation(), parser); File f = (new File(testFileName)); URL url = f.toURL(); Document doc = df.createDocument(null, rootTag, url.toString(), url.openStream()); Element e = doc.getElementById(targetId); if (e == null){ DefaultTestReport report = new DefaultTestReport(this); report.setErrorCode(ERROR_GET_ELEMENT_BY_ID_FAILED); report.addDescriptionEntry(ENTRY_KEY_ID, targetId); report.setPassed(false); return report; } while (e.hasChildNodes()) { e.removeChild(e.getFirstChild()); } return reportSuccess(); } } 1.1 xml-batik/test-sources/org/apache/batik/dom/ReplaceChildTest.java Index: ReplaceChildTest.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.batik.dom; import org.w3c.dom.*; import java.io.*; import java.net.*; import org.apache.batik.dom.util.*; import org.apache.batik.util.*; import org.apache.batik.test.*; /** * This class tests the hasChildNodes method. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> * @version $Id: ReplaceChildTest.java,v 1.1 2002/03/19 13:43:55 hillion Exp $ */ public class ReplaceChildTest extends AbstractTest { public static String ERROR_GET_ELEMENT_BY_ID_FAILED = "error.get.element.by.id.failed"; public static String ENTRY_KEY_ID = "entry.key.id"; protected String testFileName; protected String rootTag; protected String targetId; public ReplaceChildTest(String file, String root, String id) { testFileName = file; rootTag = root; targetId = id; } public TestReport runImpl() throws Exception { String parser = XMLResourceDescriptor.getXMLParserClassName(); DocumentFactory df = new SAXDocumentFactory (GenericDOMImplementation.getDOMImplementation(), parser); File f = (new File(testFileName)); URL url = f.toURL(); Document doc = df.createDocument(null, rootTag, url.toString(), url.openStream()); Element e = doc.getElementById(targetId); if (e == null){ DefaultTestReport report = new DefaultTestReport(this); report.setErrorCode(ERROR_GET_ELEMENT_BY_ID_FAILED); report.addDescriptionEntry(ENTRY_KEY_ID, targetId); report.setPassed(false); return report; } Element fc = null; for (Node n = e.getFirstChild(); n != null; n = n.getNextSibling()) { if (n.getNodeType() == n.ELEMENT_NODE) { fc = (Element)n; break; } } Element ne = doc.createElementNS(null, "elt4"); e.replaceChild(ne, fc); if (ne.getParentNode() != e || fc.getParentNode() != null) { DefaultTestReport report = new DefaultTestReport(this); report.setErrorCode(report.ERROR_TEST_FAILED); report.setPassed(false); return report; } return reportSuccess(); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]