You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2011/07/22 22:34:30 UTC

svn commit: r1149729 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/main/java/org/apache/axiom/om/ axiom-testsuite/src/main/java/org/apache/axiom/ts/ axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/

Author: veithen
Date: Fri Jul 22 20:34:29 2011
New Revision: 1149729

URL: http://svn.apache.org/viewvc?rev=1149729&view=rev
Log:
AXIOM-75: Explicitly support usage of remove() on the iterator returned by OMElement#getAllDeclaredNamespaces().

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetAllDeclaredNamespacesRemove.java   (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java?rev=1149729&r1=1149728&r2=1149729&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java Fri Jul 22 20:34:29 2011
@@ -205,6 +205,9 @@ public interface OMElement extends OMNod
      * <p>
      * It is expected that applications only rarely use {@link #getAllDeclaredNamespaces()}
      * directly.
+     * <p>
+     * The iterator returned by this method supports {@link Iterator#remove()} and that method can
+     * be used to remove a namespace declaration from this element.
      * 
      * @return An iterator over the {@link OMNamespace} items declared on this element. Note that
      *         the iterator may be invalidated by a call to {@link #declareNamespace(OMNamespace)},

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java?rev=1149729&r1=1149728&r2=1149729&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java Fri Jul 22 20:34:29 2011
@@ -94,6 +94,7 @@ public class OMTestSuiteBuilder extends 
         addTest(new org.apache.axiom.ts.om.element.TestGetAllAttributes1(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetAllAttributes2(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetAllDeclaredNamespaces(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestGetAllDeclaredNamespacesRemove(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetAttributeValueNonExisting(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetAttributeValueWithXmlPrefix1(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetAttributeValueWithXmlPrefix2(metaFactory));

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetAllDeclaredNamespacesRemove.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetAllDeclaredNamespacesRemove.java?rev=1149729&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetAllDeclaredNamespacesRemove.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetAllDeclaredNamespacesRemove.java Fri Jul 22 20:34:29 2011
@@ -0,0 +1,55 @@
+/*
+ * 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.om.element;
+
+import java.util.Iterator;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests that {@link Iterator#remove()} can be used on the iterator returned by
+ * {@link OMElement#getAllDeclaredNamespaces()} to remove a namespace declaration.
+ */
+public class TestGetAllDeclaredNamespacesRemove extends AxiomTestCase {
+    public TestGetAllDeclaredNamespacesRemove(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        OMElement element = factory.createOMElement("test", null);
+        element.declareNamespace("urn:a", "a");
+        element.declareNamespace("urn:b", "b");
+        element.declareNamespace("urn:c", "c");
+        for (Iterator it = element.getAllDeclaredNamespaces(); it.hasNext(); ) {
+            OMNamespace ns = (OMNamespace)it.next();
+            if (ns.getPrefix().equals("b")) {
+                it.remove();
+                break;
+            }
+        }
+        assertEquals("urn:a", element.findNamespaceURI("a").getNamespaceURI());
+        assertNull(element.findNamespaceURI("b"));
+        assertEquals("urn:c", element.findNamespaceURI("c").getNamespaceURI());
+    }
+}

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