hillion 02/05/30 09:42:34 Modified: sources/org/apache/batik/dom AbstractElement.java test-resources/org/apache/batik/dom unitTesting.xml Added: test-sources/org/apache/batik/dom CloneElementTest.java Log: - Fixed Element.cloneNode(false) + test. Revision Changes Path 1.18 +2 -2 xml-batik/sources/org/apache/batik/dom/AbstractElement.java Index: AbstractElement.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractElement.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- AbstractElement.java 17 May 2002 12:06:29 -0000 1.17 +++ AbstractElement.java 30 May 2002 16:42:34 -0000 1.18 @@ -29,7 +29,7 @@ * This class implements the {@link org.w3c.dom.Element} interface. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: AbstractElement.java,v 1.17 2002/05/17 12:06:29 vhardy Exp $ + * @version $Id: AbstractElement.java,v 1.18 2002/05/30 16:42:34 hillion Exp $ */ public abstract class AbstractElement extends AbstractParentChildNode @@ -410,7 +410,7 @@ if (attributes != null) { NamedNodeMap map = attributes; for (int i = map.getLength() - 1; i >= 0; i--) { - AbstractAttr aa = (AbstractAttr)map.item(i).cloneNode(false); + AbstractAttr aa = (AbstractAttr)map.item(i).cloneNode(true); if (aa instanceof AbstractAttrNS) { ae.setAttributeNodeNS(aa); } else { 1.8 +12 -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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- unitTesting.xml 17 May 2002 13:36:11 -0000 1.7 +++ unitTesting.xml 30 May 2002 16:42:34 -0000 1.8 @@ -9,7 +9,7 @@ <!-- ========================================================================= --> <!-- @author [EMAIL PROTECTED] --> <!-- @author [EMAIL PROTECTED] --> -<!-- @version $Id: unitTesting.xml,v 1.7 2002/05/17 13:36:11 hillion Exp $ --> +<!-- @version $Id: unitTesting.xml,v 1.8 2002/05/30 16:42:34 hillion Exp $ --> <!-- ========================================================================= --> <testSuite id="dom.unitTesting" name="org.apache.batik.dom package - Unit Testing"> @@ -26,6 +26,17 @@ <property name="ParserClassName" class="java.lang.String" value="org.apache.crimson.parser.XMLReaderImpl" /> + </test> + + <!-- ========================================================================== --> + <!-- cloneNode test --> + <!-- ========================================================================== --> + <test id="cloneElement" + class="org.apache.batik.dom.svg.CloneElementTest" > + <arg class="java.lang.String" + value="test-resources/org/apache/batik/dom/dummyXML3.xml" /> + <arg class="java.lang.String" value="root" /> + <arg class="java.lang.String" value="elt2" /> </test> <!-- ========================================================================== --> 1.1 xml-batik/test-sources/org/apache/batik/dom/CloneElementTest.java Index: CloneElementTest.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.svg; import org.w3c.dom.*; import java.io.*; import java.net.*; import org.apache.batik.dom.*; import org.apache.batik.dom.util.*; import org.apache.batik.util.*; import org.apache.batik.test.*; /** * This class tests the non-deep cloneNode method for elements. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> * @version $Id: CloneElementTest.java,v 1.1 2002/05/30 16:42:34 hillion Exp $ */ public class CloneElementTest extends AbstractTest { protected String testFileName; protected String rootTag; protected String targetId; public CloneElementTest(String file, String root, String id) { testFileName = file; rootTag = root; targetId = id; } public TestReport runImpl() throws Exception { String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXDocumentFactory 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 celt = (Element)e.cloneNode(false); NamedNodeMap attrs = e.getAttributes(); for (int i = 0; i < attrs.getLength(); i++) { Node attr = attrs.item(i); String ns = attr.getNamespaceURI(); String name = (ns == null) ? attr.getNodeName() : attr.getLocalName(); String val = attr.getNodeValue(); String val2 = celt.getAttributeNS(ns, name); if (!val.equals(val2)) { DefaultTestReport report = new DefaultTestReport(this); report.setErrorCode("error.attr.comparison.failed"); report.addDescriptionEntry("entry.attr.name", name); report.addDescriptionEntry("entry.attr.value1", val); report.addDescriptionEntry("entry.attr.value2", val2); report.setPassed(false); return report; } } return reportSuccess(); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]