ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1700265 - in /webservices/axiom/trunk: aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/ aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/ testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om...
Date Mon, 31 Aug 2015 15:41:58 GMT
Author: veithen
Date: Mon Aug 31 15:41:58 2015
New Revision: 1700265

URL: http://svn.apache.org/r1700265
Log:
Fix a weird namespace issue.

Added:
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope4.java
  (with props)
Modified:
    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/factory/AxiomNodeFactorySupport.aj
    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/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=1700265&r1=1700264&r2=1700265&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
Mon Aug 31 15:41:58 2015
@@ -458,11 +458,6 @@ public aspect AxiomElementSupport {
      * the prefix of a known namespace URI.
      */
     private OMNamespace AxiomElement.findDeclaredNamespace(String uri, String prefix) {
-        // Seems weird, but necessary for compatibility with older versions
-        if (uri != null && prefix != null && prefix.length() == 0) {
-            prefix = null;
-        }
-        
         CoreAttribute attr = coreGetFirstAttribute();
         while (attr != null) {
             if (attr instanceof AxiomNamespaceDeclaration) {

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactorySupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactorySupport.aj?rev=1700265&r1=1700264&r2=1700265&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactorySupport.aj
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactorySupport.aj
Mon Aug 31 15:41:58 2015
@@ -260,7 +260,7 @@ public aspect AxiomNodeFactorySupport {
             // The goal here is twofold:
             //  * check if the namespace needs to be declared;
             //  * locate an existing OMNamespace object, so that we can avoid creating a
new one.
-            OMNamespace ns = element.findNamespace(namespaceURI, prefix);
+            OMNamespace ns = element.findNamespace(namespaceURI, prefix.length() == 0 ? null
: prefix);
             if (ns == null) {
                 if ("".equals(prefix)) {
                     prefix = OMSerializerUtil.getNextNSPrefix();

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=1700265&r1=1700264&r2=1700265&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
Mon Aug 31 15:41:58 2015
@@ -452,6 +452,7 @@ public class OMTestSuiteBuilder extends
             }
             if (variant.isSupportsContainer() && variant.isSupportsDefaultNamespace())
{
                 addTest(new org.apache.axiom.ts.om.factory.TestCreateOMElementWithNamespaceInScope3(metaFactory,
variant));
+                addTest(new org.apache.axiom.ts.om.factory.TestCreateOMElementWithNamespaceInScope4(metaFactory,
variant));
             }
         }
         if (supportsOMSourcedElement) {

Added: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope4.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope4.java?rev=1700265&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope4.java
(added)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope4.java
Mon Aug 31 15:41:58 2015
@@ -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.om.factory;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+
+/**
+ * Tests a scenario that gave incorrect results in previous Axiom versions because
+ * {@link OMElement#findNamespace(String, String)} interpreted an empty prefix in the same
way as
+ * <code>null</code>.
+ */
+public class TestCreateOMElementWithNamespaceInScope4 extends CreateOMElementTestCase {
+    public TestCreateOMElementWithNamespaceInScope4(OMMetaFactory metaFactory, CreateOMElementVariant
variant) {
+        super(metaFactory, variant, null);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        OMElement parent = factory.createOMElement("parent", "urn:test", "a");
+        parent.declareDefaultNamespace("urn:test");
+        OMElement child = variant.createOMElement(factory, parent, "child", "urn:test", "");
+        assertThat(child.getAllDeclaredNamespaces().hasNext()).isFalse();
+    }
+}

Propchange: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope4.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message