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 2017/06/04 09:49:51 UTC

svn commit: r1797563 - in /webservices/axiom/trunk: aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/ axiom-api/src/main/java/org/apache/axiom/om/ src/site/markdown/release-notes/ testing/axiom-testsuite/src/main/java/org/apache/axiom/ts...

Author: veithen
Date: Sun Jun  4 09:49:51 2017
New Revision: 1797563

URL: http://svn.apache.org/viewvc?rev=1797563&view=rev
Log:
AXIOM-375: Remove the legacy behavior for declareNamespace.

Added:
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareNamespaceWithEmptyPrefix.java
      - copied, changed from r1797562, webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareNamespaceWithGeneratedPrefix2.java
Removed:
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareNamespaceWithGeneratedPrefix2.java
Modified:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomElementSupport.aj
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
    webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomElementSupport.aj?rev=1797563&r1=1797562&r2=1797563&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomElementSupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomElementSupport.aj Sun Jun  4 09:49:51 2017
@@ -68,16 +68,12 @@ import org.apache.axiom.util.namespace.M
 import org.apache.axiom.util.stax.XMLStreamIOException;
 import org.apache.axiom.util.stax.XMLStreamReaderUtils;
 import org.apache.axiom.util.xml.QNameCache;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  * Utility class with default implementations for some of the methods defined by the
  * {@link OMElement} interface.
  */
 public aspect AxiomElementSupport {
-    private static final Log log = LogFactory.getLog(AxiomElementSupport.class);
-    
     public final void AxiomElement.initName(String localName, OMNamespace ns, boolean generateNSDecl) {
         internalSetLocalName(localName);
         internalSetNamespace(generateNSDecl ? NSUtil.handleNamespace(this, ns, false, true) : ns);
@@ -397,12 +393,7 @@ public aspect AxiomElementSupport {
     }
 
     public final OMNamespace AxiomElement.declareNamespace(String uri, String prefix) {
-        if ("".equals(prefix)) {
-            log.warn("Deprecated usage of OMElement#declareNamespace(String,String) with empty prefix");
-            prefix = generatePrefix(uri);
-        }
-        OMNamespaceImpl ns = new OMNamespaceImpl(uri, prefix);
-        return declareNamespace(ns);
+        return declareNamespace(new OMNamespaceImpl(uri, prefix));
     }
 
     public final OMNamespace AxiomElement.declareDefaultNamespace(String uri) {

Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java?rev=1797563&r1=1797562&r2=1797563&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java Sun Jun  4 09:49:51 2017
@@ -94,18 +94,14 @@ public interface OMElement extends OMNod
     /**
      * Add a namespace declaration for the given namespace URI to this element, optionally
      * generating a prefix for that namespace.
-     * <p>
-     * Note that this method can't be used to declare a default namespace. For that purpose use
-     * {@link #declareDefaultNamespace(String)} or {@link #declareNamespace(OMNamespace)}.
      * 
      * @param uri
      *            The namespace to declare in the current scope. The caller is expected to ensure
      *            that the URI is a valid namespace name.
      * @param prefix
      *            The prefix to associate with the given namespace. The caller is expected to ensure
-     *            that this is a valid XML prefix. If <code>null</code> or the empty string is
-     *            given, a prefix will be auto-generated. <b>Please note that using the empty string
-     *            for this purpose is deprecated and will no longer be supported in Axiom 1.3.</b>
+     *            that this is a valid XML prefix. If <code>null</code> is
+     *            given, a prefix will be auto-generated.
      * @return the created namespace information item
      * @throws IllegalArgumentException
      *             if an attempt is made to bind a prefix to the empty namespace name

Modified: webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md?rev=1797563&r1=1797562&r2=1797563&view=diff
==============================================================================
--- webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md (original)
+++ webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md Sun Jun  4 09:49:51 2017
@@ -84,6 +84,10 @@ Changes in this release
 
 [AXIOM-11]: https://issues.apache.org/jira/browse/AXIOM-11
 
+*   The legacy behavior for `declareNamesapce` (where an empty prefix is
+    interpreted in the same way as a null value) is no longer supported.
+    See [AXIOM-375][].
+
 *   Elements no longer store line number information, and the corresponding
     methods on the `OMElement` interface have been deprecated.
 
@@ -200,4 +204,5 @@ Changes in this release
 *   The `axiom-c14n` artifact has been removed without replacement. Use DOOM
     together with [Apache Santuario](http://santuario.apache.org/) instead.
 
+[AXIOM-375]: https://issues.apache.org/jira/browse/AXIOM-375
 [AXIOM-474]: https://issues.apache.org/jira/browse/AXIOM-474

Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java?rev=1797563&r1=1797562&r2=1797563&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java Sun Jun  4 09:49:51 2017
@@ -275,8 +275,8 @@ public class OMTestSuiteBuilder extends
         addTest(new org.apache.axiom.ts.om.element.TestDeclareNamespace1(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestDeclareNamespaceInvalid1(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestDeclareNamespaceInvalid2(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestDeclareNamespaceWithEmptyPrefix(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestDeclareNamespaceWithGeneratedPrefix1(metaFactory));
-        addTest(new org.apache.axiom.ts.om.element.TestDeclareNamespaceWithGeneratedPrefix2(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestDeclareNamespaceWithGeneratedPrefix3(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestDetachWithDifferentBuilder(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestDigestWithNamespace(metaFactory));

Copied: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareNamespaceWithEmptyPrefix.java (from r1797562, webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareNamespaceWithGeneratedPrefix2.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareNamespaceWithEmptyPrefix.java?p2=webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareNamespaceWithEmptyPrefix.java&p1=webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareNamespaceWithGeneratedPrefix2.java&r1=1797562&r2=1797563&rev=1797563&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareNamespaceWithGeneratedPrefix2.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareNamespaceWithEmptyPrefix.java Sun Jun  4 09:49:51 2017
@@ -18,6 +18,8 @@
  */
 package org.apache.axiom.ts.om.element;
 
+import static com.google.common.truth.Truth.assertThat;
+
 import java.util.Iterator;
 
 import javax.xml.namespace.QName;
@@ -29,12 +31,14 @@ import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.ts.AxiomTestCase;
 
 /**
- * Tests that {@link OMElement#declareNamespace(String, String)} generates a new prefix if the
+ * Tests the behavior of {@link OMElement#declareNamespace(String, String)}
+ * with an empty prefix.
+ * generates a new prefix if the
  * specified prefix is empty. Note that this behavior will change in Axiom 1.3 (see
  * <a href="https://issues.apache.org/jira/browse/AXIOM-373">AXIOM-373</a>).
  */
-public class TestDeclareNamespaceWithGeneratedPrefix2 extends AxiomTestCase {
-    public TestDeclareNamespaceWithGeneratedPrefix2(OMMetaFactory metaFactory) {
+public class TestDeclareNamespaceWithEmptyPrefix extends AxiomTestCase {
+    public TestDeclareNamespaceWithEmptyPrefix(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
 
@@ -43,13 +47,12 @@ public class TestDeclareNamespaceWithGen
         OMFactory factory = metaFactory.getOMFactory();
         OMElement element = factory.createOMElement(new QName("test"));
         OMNamespace ns = element.declareNamespace("urn:ns", "");
-        assertEquals("urn:ns", ns.getNamespaceURI());
-        assertNotNull(ns.getPrefix());
-        assertTrue(ns.getPrefix().length() > 0);
+        assertThat(ns.getNamespaceURI()).isEqualTo("urn:ns");
+        assertThat(ns.getPrefix()).isEmpty();
         Iterator<OMNamespace> it = element.getAllDeclaredNamespaces();
-        assertTrue(it.hasNext());
+        assertThat(it.hasNext()).isTrue();
         OMNamespace ns2 = it.next();
-        assertEquals(ns, ns2);
-        assertFalse(it.hasNext());
+        assertThat(ns2).isEqualTo(ns);
+        assertThat(it.hasNext()).isFalse();
     }
 }