ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1703998 - in /webservices/axiom/trunk: aspects/core-aspects/src/main/java/org/apache/axiom/core/ aspects/dom-aspects/src/main/java/org/apache/axiom/dom/ aspects/fom-aspects/src/main/java/org/apache/axiom/fom/ aspects/om-aspects/src/main/ja...
Date Sat, 19 Sep 2015 12:15:29 GMT
Author: veithen
Date: Sat Sep 19 12:15:29 2015
New Revision: 1703998

URL: http://svn.apache.org/viewvc?rev=1703998&view=rev
Log:
Fix some issues in the code responsible for removing attributes.

Added:
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestRemoveAttributeNode.java
  (with props)
Modified:
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributeIterator.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/DetachPolicy.java
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java
    webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/Policies.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Policies.java
    webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributeIterator.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributeIterator.java?rev=1703998&r1=1703997&r2=1703998&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributeIterator.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributeIterator.java
Sat Sep 19 12:15:29 2015
@@ -25,18 +25,20 @@ import java.util.NoSuchElementException;
 final class AttributeIterator<T extends CoreAttribute,S> implements Iterator<S>
{
     private final Class<T> type;
     private final Mapper<T,S> mapper;
+    private final DetachPolicy detachPolicy;
     private CoreAttribute currentAttribute;
     private CoreAttribute nextAttribute;
     private boolean nextAttributeSet;
     
-    private AttributeIterator(CoreAttribute firstAttribute, Class<T> type, Mapper<T,S>
mapper) {
+    private AttributeIterator(CoreAttribute firstAttribute, Class<T> type, Mapper<T,S>
mapper, DetachPolicy detachPolicy) {
         this.type = type;
         this.mapper = mapper;
+        this.detachPolicy = detachPolicy;
         nextAttribute = firstAttribute;
         nextAttributeSet = true;
     }
     
-    static <T extends CoreAttribute,S> Iterator<S> create(CoreElement element,
Class<T> type, Mapper<T,S> mapper) {
+    static <T extends CoreAttribute,S> Iterator<S> create(CoreElement element,
Class<T> type, Mapper<T,S> mapper, DetachPolicy detachPolicy) {
         CoreAttribute attribute = element.coreGetFirstAttribute();
         while (attribute != null && !type.isInstance(attribute)) {
             attribute = attribute.coreGetNextAttribute();
@@ -44,7 +46,7 @@ final class AttributeIterator<T extends
         if (attribute == null) {
             return Collections.<S>emptyList().iterator();
         } else {
-            return new AttributeIterator<T,S>(attribute, type, mapper);
+            return new AttributeIterator<T,S>(attribute, type, mapper, detachPolicy);
         }
     }
     
@@ -78,7 +80,7 @@ final class AttributeIterator<T extends
         } else {
             // Ensure that the next attribute is known before we remove the current one.
             hasNext();
-            currentAttribute.coreRemove();
+            currentAttribute.coreRemove(detachPolicy);
             currentAttribute = null;
         }
     }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java?rev=1703998&r1=1703997&r2=1703998&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java
Sat Sep 19 12:15:29 2015
@@ -34,23 +34,15 @@ public interface CoreAttribute extends N
     boolean coreHasOwnerElement();
     
     /**
-     * Remove this attribute from its owner element. The attribute will keep its current
owner
-     * document.
+     * Remove this attribute from its owner element.
      * 
+     * @param detachPolicy
+     *            the detach policy that determines the new owner document for the attribute
      * @return <code>true</code> if the attribute had an owner element and has
been removed from
      *         that element; <code>false</code> if the attribute didn't have
an owner element and no
      *         changes have been made
      */
-    boolean coreRemove();
-    
-    /**
-     * Remove this attribute from its owner element and assign it to a new owner document.
The owner
-     * document will always be changed, even if the attribute has no owner element.
-     * 
-     * @return <code>true</code> if the attribute had an owner element and has
been removed from
-     *         that element; <code>false</code> if the attribute didn't have
an owner element
-     */
-    boolean coreRemove(CoreDocument document);
+    boolean coreRemove(DetachPolicy detachPolicy);
     
     /**
      * Get the attribute immediately following the current attribute.

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj?rev=1703998&r1=1703997&r2=1703998&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj
Sat Sep 19 12:15:29 2015
@@ -96,19 +96,11 @@ public aspect CoreAttributeSupport {
         nextAttribute = attr;
     }
 
-    public final boolean CoreAttribute.coreRemove() {
-        return remove(false, null);
-    }
-
-    public final boolean CoreAttribute.coreRemove(CoreDocument document) {
-        return remove(true, document);
-    }
-
-    private boolean CoreAttribute.remove(boolean newOwnerDocument, CoreDocument ownerDocument)
{
+    public final boolean CoreAttribute.coreRemove(DetachPolicy detachPolicy) {
         if (owner instanceof CoreElement) {
             CoreElement ownerElement = (CoreElement)owner;
             CoreAttribute previousAttr = coreGetPreviousAttribute();
-            owner = newOwnerDocument ? ownerDocument : coreGetOwnerDocument(false); // TODO:
create?
+            owner = detachPolicy.getNewOwnerDocument(ownerElement);
             if (previousAttr == null) {
                 ownerElement.internalSetFirstAttribute(nextAttribute);
             } else {
@@ -117,9 +109,6 @@ public aspect CoreAttributeSupport {
             nextAttribute = null;
             return true;
         } else {
-            if (newOwnerDocument) {
-                owner = ownerDocument;
-            }
             return false;
         }
     }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java?rev=1703998&r1=1703997&r2=1703998&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
Sat Sep 19 12:15:29 2015
@@ -157,9 +157,9 @@ public interface CoreElement extends Cor
      * @return <code>true</code> if a matching attribute was found (and has been
removed),
      *         <code>false</code> if no matching attribute was found
      */
-    boolean coreRemoveAttribute(AttributeMatcher matcher, String namespaceURI, String name);
+    boolean coreRemoveAttribute(AttributeMatcher matcher, String namespaceURI, String name,
DetachPolicy detachPolicy);
     
-    <T extends CoreAttribute,S> Iterator<S> coreGetAttributesByType(Class<T>
type, Mapper<T,S> mapper);
+    <T extends CoreAttribute,S> Iterator<S> coreGetAttributesByType(Class<T>
type, Mapper<T,S> mapper, DetachPolicy detachPolicy);
     
     /**
      * Look up the namespace URI associated to the given prefix.

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj?rev=1703998&r1=1703997&r2=1703998&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
Sat Sep 19 12:15:29 2015
@@ -78,7 +78,7 @@ public aspect CoreElementSupport {
 //                        throw new UnsupportedOperationException();
                         return attr;
                     } else {
-                        attr.coreRemove();
+                        attr.coreRemove(null); // TODO
                         return attr;
                     }
                 case CLONE:
@@ -168,18 +168,18 @@ public aspect CoreElementSupport {
         }
     }
 
-    public final boolean CoreElement.coreRemoveAttribute(AttributeMatcher matcher, String
namespaceURI, String name) {
+    public final boolean CoreElement.coreRemoveAttribute(AttributeMatcher matcher, String
namespaceURI, String name, DetachPolicy detachPolicy) {
         CoreAttribute att = coreGetAttribute(matcher, namespaceURI, name);
         if (att != null) {
-            att.coreRemove();
+            att.coreRemove(detachPolicy);
             return true;
         } else {
             return false;
         }
     }
 
-    public final <T extends CoreAttribute,S> Iterator<S> CoreElement.coreGetAttributesByType(Class<T>
type, Mapper<T,S> mapper) {
-        return AttributeIterator.create(this, type, mapper);
+    public final <T extends CoreAttribute,S> Iterator<S> CoreElement.coreGetAttributesByType(Class<T>
type, Mapper<T,S> mapper, DetachPolicy detachPolicy) {
+        return AttributeIterator.create(this, type, mapper, detachPolicy);
     }
 
     public abstract String CoreElement.getImplicitNamespaceURI(String prefix);

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/DetachPolicy.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/DetachPolicy.java?rev=1703998&r1=1703997&r2=1703998&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/DetachPolicy.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/DetachPolicy.java
Sat Sep 19 12:15:29 2015
@@ -19,17 +19,18 @@
 package org.apache.axiom.core;
 
 /**
- * Determines how child nodes are detached.
+ * Determines how nodes are detached from an object model tree.
  */
 public interface DetachPolicy {
     /**
-     * Get the new owner document for the child node (or group of child nodes) to be detached.
This
-     * method is called before any child node is detached.
+     * Get the new owner document for the node (or group of child nodes) to be detached.
This method
+     * is called before any node is detached.
      * 
-     * @param parent
-     *            the parent of the child node (or group of child nodes) to be detached
+     * @param owner
+     *            The owner of the node (or group of child nodes) to be detached. For child
nodes,
+     *            this is the parent node. For attributes, this is the owner element.
      * @return the new owner document or <code>null</code> to (lazily) create
a new owner document
-     *         for each child node
+     *         for the node(s)
      */
-    CoreDocument getNewOwnerDocument(CoreParentNode parent);
+    CoreDocument getNewOwnerDocument(CoreParentNode owner);
 }

Modified: webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj?rev=1703998&r1=1703997&r2=1703998&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj
Sat Sep 19 12:15:29 2015
@@ -164,22 +164,22 @@ public aspect DOMElementSupport {
         if (attr.coreGetOwnerElement() != this) {
             throw DOMExceptionTranslator.newDOMException(DOMException.NOT_FOUND_ERR);
         } else {
-            attr.coreRemove();
+            attr.coreRemove(Policies.DETACH_POLICY);
         }
         return attr;
     }
 
     public final void DOMElement.removeAttribute(String name) throws DOMException {
         // Specs: "If no attribute with this name is found, this method has no effect."
-        coreRemoveAttribute(Policies.DOM1_ATTRIBUTE_MATCHER, null, name);
+        coreRemoveAttribute(Policies.DOM1_ATTRIBUTE_MATCHER, null, name, Policies.DETACH_POLICY);
     }
 
     public final void DOMElement.removeAttributeNS(String namespaceURI, String localName)
throws DOMException {
         // Specs: "If no attribute with this local name and namespace URI is found, this
method has no effect."
         if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) {
-            coreRemoveAttribute(Policies.NAMESPACE_DECLARATION_MATCHER, null, localName.equals(XMLConstants.XMLNS_ATTRIBUTE)
? "" : localName);
+            coreRemoveAttribute(Policies.NAMESPACE_DECLARATION_MATCHER, null, localName.equals(XMLConstants.XMLNS_ATTRIBUTE)
? "" : localName, Policies.DETACH_POLICY);
         } else {
-            coreRemoveAttribute(Policies.DOM2_ATTRIBUTE_MATCHER, namespaceURI == null ? ""
: namespaceURI, localName);
+            coreRemoveAttribute(Policies.DOM2_ATTRIBUTE_MATCHER, namespaceURI == null ? ""
: namespaceURI, localName, Policies.DETACH_POLICY);
         }
     }
     

Modified: webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java?rev=1703998&r1=1703997&r2=1703998&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java
(original)
+++ webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java
Sat Sep 19 12:15:29 2015
@@ -36,8 +36,8 @@ public final class Policies {
     private Policies() {}
     
     public static final DetachPolicy DETACH_POLICY = new DetachPolicy() {
-        public CoreDocument getNewOwnerDocument(CoreParentNode parent) {
-            return parent.coreGetOwnerDocument(true);
+        public CoreDocument getNewOwnerDocument(CoreParentNode owner) {
+            return owner.coreGetOwnerDocument(true);
         }
     };
     

Modified: webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/Policies.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/Policies.java?rev=1703998&r1=1703997&r2=1703998&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/Policies.java
(original)
+++ webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/Policies.java
Sat Sep 19 12:15:29 2015
@@ -28,7 +28,7 @@ public final class Policies {
     private Policies() {}
     
     public static final DetachPolicy DETACH_POLICY = new DetachPolicy() {
-        public CoreDocument getNewOwnerDocument(CoreParentNode parent) {
+        public CoreDocument getNewOwnerDocument(CoreParentNode owner) {
             return null;
         }
     };

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj?rev=1703998&r1=1703997&r2=1703998&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj
Sat Sep 19 12:15:29 2015
@@ -317,7 +317,7 @@ public aspect AxiomElementSupport {
     
     @SuppressWarnings("rawtypes")
     public final Iterator AxiomElement.getAllAttributes() {
-        return coreGetAttributesByType(AxiomAttribute.class, attributeIdentityMapper);
+        return coreGetAttributesByType(AxiomAttribute.class, attributeIdentityMapper, Policies.DETACH_POLICY);
     }
     
     public final OMAttribute AxiomElement.getAttribute(QName qname) {
@@ -344,7 +344,7 @@ public aspect AxiomElementSupport {
         if (attr.getOwner() != this) {
             throw new OMException("The attribute is not owned by this element");
         }
-        ((AxiomAttribute)attr).coreRemove(null);
+        ((AxiomAttribute)attr).coreRemove(Policies.DETACH_POLICY);
     }
 
     public final OMNamespace AxiomElement.addNamespaceDeclaration(String uri, String prefix)
{
@@ -372,7 +372,7 @@ public aspect AxiomElementSupport {
     
     @SuppressWarnings("rawtypes")
     public final Iterator AxiomElement.getAllDeclaredNamespaces() {
-        return coreGetAttributesByType(AxiomNamespaceDeclaration.class, NamespaceDeclarationMapper.INSTANCE);
+        return coreGetAttributesByType(AxiomNamespaceDeclaration.class, NamespaceDeclarationMapper.INSTANCE,
Policies.DETACH_POLICY);
     }
 
     public final OMNamespace AxiomElement.declareNamespace(OMNamespace namespace) {

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Policies.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Policies.java?rev=1703998&r1=1703997&r2=1703998&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Policies.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Policies.java
Sat Sep 19 12:15:29 2015
@@ -35,7 +35,7 @@ public final class Policies {
     private Policies() {}
     
     public static final DetachPolicy DETACH_POLICY = new DetachPolicy() {
-        public CoreDocument getNewOwnerDocument(CoreParentNode parent) {
+        public CoreDocument getNewOwnerDocument(CoreParentNode owner) {
             return null;
         }
     };

Modified: webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMElement.java?rev=1703998&r1=1703997&r2=1703998&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
(original)
+++ webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
Sat Sep 19 12:15:29 2015
@@ -211,7 +211,7 @@ public class FOMElement extends FOMChild
 
     public <T extends Element> T setAttributeValue(QName qname, String value) {
         if (value == null) {
-            coreRemoveAttribute(Policies.ATTRIBUTE_MATCHER, qname.getNamespaceURI(), qname.getLocalPart());
+            coreRemoveAttribute(Policies.ATTRIBUTE_MATCHER, qname.getNamespaceURI(), qname.getLocalPart(),
Policies.DETACH_POLICY);
         } else {
             coreSetAttribute(Policies.ATTRIBUTE_MATCHER, qname.getNamespaceURI(), qname.getLocalPart(),
qname.getPrefix(), value);
         }

Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java?rev=1703998&r1=1703997&r2=1703998&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
(original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
Sat Sep 19 12:15:29 2015
@@ -54,6 +54,7 @@ public class OMDOMTestSuiteBuilder exten
         addTest(new org.apache.axiom.ts.omdom.element.TestGetNamespaceNormalized(metaFactory));
         addTest(new org.apache.axiom.ts.omdom.element.TestInsertBeforeIncomplete(metaFactory));
         addTest(new org.apache.axiom.ts.omdom.element.TestRemoveAttribute(metaFactory));
+        addTest(new org.apache.axiom.ts.omdom.element.TestRemoveAttributeNode(metaFactory));
         addTest(new org.apache.axiom.ts.omdom.element.TestRemoveAttributeNSNamespaceDeclaration(metaFactory));
         addTest(new org.apache.axiom.ts.omdom.element.TestRemoveChildIncomplete(metaFactory));
         addTest(new org.apache.axiom.ts.omdom.element.TestReplaceChildFirstIncomplete(metaFactory));

Added: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestRemoveAttributeNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestRemoveAttributeNode.java?rev=1703998&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestRemoveAttributeNode.java
(added)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestRemoveAttributeNode.java
Sat Sep 19 12:15:29 2015
@@ -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.axiom.ts.omdom.element;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.ts.AxiomTestCase;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+
+/**
+ * Tests that after calling {@link Element#removeAttributeNode(Attr)} the removed attribute
has the
+ * same owner document as the element. This test case uses a scenario where the element is
created
+ * using the Axiom API, i.e. where the owner document is created lazily.
+ */
+public class TestRemoveAttributeNode extends AxiomTestCase {
+    public TestRemoveAttributeNode(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    @Override
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        OMElement element = factory.createOMElement("test", null);
+        OMAttribute attr = element.addAttribute("attr", "value", null);
+        ((Element)element).removeAttributeNode((Attr)attr);
+        assertThat(((Attr)attr).getOwnerDocument()).isSameAs(((Element)element).getOwnerDocument());
+    }
+}

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



Mime
View raw message