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 2012/05/13 12:28:51 UTC
svn commit: r1337831 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/
axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/
axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/ axiom-testsu...
Author: veithen
Date: Sun May 13 10:28:50 2012
New Revision: 1337831
URL: http://svn.apache.org/viewvc?rev=1337831&view=rev
Log:
Fixed a problem in OMFactory#createOMElement(String, OMNamespace, OMContainer) which was incorrectly reusing an existing prefix if the specified prefix is empty. That should only occur if the specified prefix is null.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope1.java
- copied, changed from r1337823, webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope2.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope3.java (with props)
Removed:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope.java
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1337831&r1=1337830&r2=1337831&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java Sun May 13 10:28:50 2012
@@ -185,7 +185,7 @@ public class ElementImpl extends ParentN
return null;
} else {
OMNamespace namespace = findNamespace(namespaceURI, prefix);
- if (namespace == null) {
+ if (namespace == null || (prefix != null && !namespace.getPrefix().equals(prefix))) {
namespace = declareNamespace(ns);
}
return namespace;
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java?rev=1337831&r1=1337830&r2=1337831&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java Sun May 13 10:28:50 2012
@@ -28,7 +28,7 @@ import org.apache.axiom.ts.om.container.
import org.apache.axiom.ts.om.document.TestDigest;
import org.apache.axiom.ts.om.element.TestGetChildrenWithName4;
import org.apache.axiom.ts.om.factory.TestCreateOMElementWithGeneratedPrefix;
-import org.apache.axiom.ts.om.factory.TestCreateOMElementWithNamespaceInScope;
+import org.apache.axiom.ts.om.factory.TestCreateOMElementWithNamespaceInScope1;
import org.apache.axiom.ts.om.node.TestInsertSiblingAfterOnChild;
import org.apache.axiom.ts.om.node.TestInsertSiblingBeforeOnChild;
@@ -42,8 +42,8 @@ public class OMImplementationTest extend
// TODO: DOOM's behavior differs from LLOM's behavior in this case
builder.exclude(TestCreateOMElementWithGeneratedPrefix.class, "(variant=QName*)");
- builder.exclude(TestCreateOMElementWithNamespaceInScope.class, "(variant=QName,OMContainer)");
- builder.exclude(TestCreateOMElementWithNamespaceInScope.class, "(variant=String,OMNamespace,OMContainer)");
+ builder.exclude(TestCreateOMElementWithNamespaceInScope1.class, "(variant=QName,OMContainer)");
+ builder.exclude(TestCreateOMElementWithNamespaceInScope1.class, "(variant=String,OMNamespace,OMContainer)");
// TODO: this case is not working because Axiom generates an XML declaration
// but uses another charset encoding to serialize the document
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=1337831&r1=1337830&r2=1337831&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java Sun May 13 10:28:50 2012
@@ -213,7 +213,7 @@ public class OMElementImpl extends OMNod
return null;
} else {
OMNamespace namespace = findNamespace(namespaceURI, prefix);
- if (namespace == null) {
+ if (namespace == null || (prefix != null && !namespace.getPrefix().equals(prefix))) {
namespace = declareNamespace(ns);
}
return namespace;
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java?rev=1337831&r1=1337830&r2=1337831&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java Sun May 13 10:28:50 2012
@@ -288,9 +288,11 @@ public class OMTestSuiteBuilder extends
}
}
if (variant.isSupportsContainer()) {
- addTest(new org.apache.axiom.ts.om.factory.TestCreateOMElementWithNamespaceInScope(metaFactory, variant));
+ addTest(new org.apache.axiom.ts.om.factory.TestCreateOMElementWithNamespaceInScope1(metaFactory, variant));
+ addTest(new org.apache.axiom.ts.om.factory.TestCreateOMElementWithNamespaceInScope2(metaFactory, variant));
}
if (variant.isSupportsContainer() && variant.isSupportsDefaultNamespace()) {
+ addTest(new org.apache.axiom.ts.om.factory.TestCreateOMElementWithNamespaceInScope3(metaFactory, variant));
addTest(new org.apache.axiom.ts.om.factory.TestCreateOMElementWithoutNamespace2(metaFactory, variant));
addTest(new org.apache.axiom.ts.om.factory.TestCreateOMElementWithoutNamespace3(metaFactory, variant));
}
Copied: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope1.java (from r1337823, webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope1.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope1.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope.java&r1=1337823&r2=1337831&rev=1337831&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope1.java Sun May 13 10:28:50 2012
@@ -31,8 +31,8 @@ import org.apache.axiom.om.OMNamespace;
* <code>createOMElement</code> must use the existing prefix. Note that this only applies if a
* parent is specified for the {@link OMElement} to be created.
*/
-public class TestCreateOMElementWithNamespaceInScope extends CreateOMElementTestCase {
- public TestCreateOMElementWithNamespaceInScope(OMMetaFactory metaFactory, CreateOMElementVariant variant) {
+public class TestCreateOMElementWithNamespaceInScope1 extends CreateOMElementTestCase {
+ public TestCreateOMElementWithNamespaceInScope1(OMMetaFactory metaFactory, CreateOMElementVariant variant) {
super(metaFactory, variant, null);
}
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope2.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope2.java?rev=1337831&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope2.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope2.java Sun May 13 10:28:50 2012
@@ -0,0 +1,48 @@
+/*
+ * 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 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;
+
+/**
+ * Tests the behavior of the <code>createOMElement</code> methods in {@link OMFactory} if a
+ * namespace prefix is given and an existing namespace declaration for the same URI but a different
+ * prefix is in scope. In this case, <code>createOMElement</code> must use the specified prefix and
+ * not the existing prefix.
+ */
+public class TestCreateOMElementWithNamespaceInScope2 extends CreateOMElementTestCase {
+ public TestCreateOMElementWithNamespaceInScope2(OMMetaFactory metaFactory, CreateOMElementVariant variant) {
+ super(metaFactory, variant, null);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory factory = metaFactory.getOMFactory();
+ OMElement parent = factory.createOMElement("parent", "urn:test", "p1");
+ OMElement child = variant.createOMElement(factory, parent, "child", "urn:test", "p2");
+ OMNamespace ns = factory.createOMNamespace("urn:test", "p2");
+ assertEquals(ns, child.getNamespace());
+ Iterator it = child.getAllDeclaredNamespaces();
+ assertTrue(it.hasNext());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope2.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope3.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope3.java?rev=1337831&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope3.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope3.java Sun May 13 10:28:50 2012
@@ -0,0 +1,48 @@
+/*
+ * 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 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;
+
+/**
+ * Tests the behavior of the <code>createOMElement</code> methods in {@link OMFactory} if an empty
+ * namespace prefix is given and an existing namespace declaration for the same URI but non empty
+ * prefix is in scope. In this case, <code>createOMElement</code> must use the empty prefix and not
+ * the existing prefix.
+ */
+public class TestCreateOMElementWithNamespaceInScope3 extends CreateOMElementTestCase {
+ public TestCreateOMElementWithNamespaceInScope3(OMMetaFactory metaFactory, CreateOMElementVariant variant) {
+ super(metaFactory, variant, null);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory factory = metaFactory.getOMFactory();
+ OMElement parent = factory.createOMElement("parent", "urn:test", "p");
+ OMElement child = variant.createOMElement(factory, parent, "child", "urn:test", "");
+ OMNamespace ns = factory.createOMNamespace("urn:test", "");
+ assertEquals(ns, child.getNamespace());
+ Iterator it = child.getAllDeclaredNamespaces();
+ assertTrue(it.hasNext());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNamespaceInScope3.java
------------------------------------------------------------------------------
svn:eol-style = native