ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1337911 - in /webservices/commons/trunk/modules/axiom/modules: axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/ axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/
Date Sun, 13 May 2012 15:10:02 GMT
Author: veithen
Date: Sun May 13 15:10:02 2012
New Revision: 1337911

URL: http://svn.apache.org/viewvc?rev=1337911&view=rev
Log:
Fixed an issue in the Node#cloneNode method which didn't clone incomplete elements correctly.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestCloneNodeIncomplete.java
  (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java?rev=1337911&r1=1337910&r2=1337911&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
Sun May 13 15:10:02 2012
@@ -172,6 +172,9 @@ public abstract class NodeImpl implement
         } catch (CloneNotSupportedException e) {
             throw new RuntimeException("**Internal Error**" + e);
         }
+        
+        newnode.done = true;
+        newnode.builder = null;
 
         return newnode;
     }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java?rev=1337911&r1=1337910&r2=1337911&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
Sun May 13 15:10:02 2012
@@ -496,8 +496,8 @@ public abstract class ParentNode extends
 
         // Then, if deep, clone the kids too.
         if (deep) {
-            for (ChildNode child = firstChild; child != null;
-                 child = child.nextSibling) {
+            for (Node child = getFirstChild(); child != null;
+                 child = child.getNextSibling()) {
                 newnode.appendChild(child.cloneNode(true));
             }
         }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java?rev=1337911&r1=1337910&r2=1337911&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
Sun May 13 15:10:02 2012
@@ -41,6 +41,7 @@ public class OMDOMTestSuiteBuilder exten
         addTest(new org.apache.axiom.ts.omdom.document.TestImportNode(metaFactory));
         addTest(new org.apache.axiom.ts.omdom.element.TestAddAttributeReplace(metaFactory));
         addTest(new org.apache.axiom.ts.omdom.element.TestAddChildFromForeignDocument(metaFactory));
+        addTest(new org.apache.axiom.ts.omdom.element.TestCloneNodeIncomplete(metaFactory));
         addTest(new org.apache.axiom.ts.omdom.element.TestDetach(metaFactory));
         addTest(new org.apache.axiom.ts.omdom.element.TestGetNamespaceNormalized(metaFactory));
         addTest(new org.apache.axiom.ts.omdom.element.TestRemoveAttribute(metaFactory));

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestCloneNodeIncomplete.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestCloneNodeIncomplete.java?rev=1337911&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestCloneNodeIncomplete.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestCloneNodeIncomplete.java
Sun May 13 15:10:02 2012
@@ -0,0 +1,44 @@
+/*
+ * 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.axiom.ts.omdom.element;
+
+import java.io.StringReader;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.ts.AxiomTestCase;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Tests {@link Node#cloneNode(boolean)} on an element that is not completely built.
+ */
+public class TestCloneNodeIncomplete extends AxiomTestCase {
+    public TestCloneNodeIncomplete(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        Element element = (Element)OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(),
+                new StringReader("<root><child1/><child2/></root>")).getDocumentElement();
+        Element clone = (Element)element.cloneNode(true);
+        XMLAssert.assertXMLEqual(element.toString(), clone.toString());
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestCloneNodeIncomplete.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message