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/20 13:03:30 UTC
svn commit: r1340671 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/
axiom-testsuite/src/main/java/org/apache/axiom/ts/om/
axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelemen...
Author: veithen
Date: Sun May 20 11:03:30 2012
New Revision: 1340671
URL: http://svn.apache.org/viewvc?rev=1340671&view=rev
Log:
AXIOM-420: Fixed an issue that occurs with elements using a default namespace declared on an ancestor.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteStartElementWithDefaultNamespaceDeclaredOnParent.java (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.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-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java?rev=1340671&r1=1340670&r2=1340671&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java Sun May 20 11:03:30 2012
@@ -109,8 +109,9 @@ public class PushOMBuilder extends Abstr
root.validateName(prefix, localName, namespaceURI);
parent = root;
} else {
- // We don't pass the namespace here in order to avoid creation of a namespace declaration
- parent = factory.createOMElement(localName, null, parent);
+ // We use the createOMElement variant that takes a OMXMLParserWrapper parameter and
+ // don't pass the namespace. This avoids creation of a namespace declaration.
+ parent = factory.createOMElement(localName, null, parent, null);
}
if (ns != null) {
parent.setNamespaceWithNoFindInCurrentScope(ns);
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=1340671&r1=1340670&r2=1340671&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 20 11:03:30 2012
@@ -399,6 +399,7 @@ public class OMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.om.sourcedelement.push.TestWriteNamespace(metaFactory, "", "urn:test"));
addTest(new org.apache.axiom.ts.om.sourcedelement.push.TestWriteNamespace(metaFactory, "p", "urn:test"));
addTest(new org.apache.axiom.ts.om.sourcedelement.push.TestWriteStartElementAutoPrefix(metaFactory));
+ addTest(new org.apache.axiom.ts.om.sourcedelement.push.TestWriteStartElementWithDefaultNamespaceDeclaredOnParent(metaFactory));
}
addTest(new org.apache.axiom.ts.om.pi.TestDigest(metaFactory));
addTest(new org.apache.axiom.ts.om.text.TestBase64Streaming(metaFactory));
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteStartElementWithDefaultNamespaceDeclaredOnParent.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteStartElementWithDefaultNamespaceDeclaredOnParent.java?rev=1340671&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteStartElementWithDefaultNamespaceDeclaredOnParent.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteStartElementWithDefaultNamespaceDeclaredOnParent.java Sun May 20 11:03:30 2012
@@ -0,0 +1,62 @@
+/*
+ * 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.sourcedelement.push;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.ds.AbstractPushOMDataSource;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests that {@link XMLStreamWriter#writeStartElement(String, String, String)} creates the correct
+ * {@link OMElement} if the element uses a default namespace declared on the parent.
+ */
+public class TestWriteStartElementWithDefaultNamespaceDeclaredOnParent extends AxiomTestCase {
+ public TestWriteStartElementWithDefaultNamespaceDeclaredOnParent(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory factory = metaFactory.getOMFactory();
+ OMElement element = factory.createOMElement(new AbstractPushOMDataSource() {
+ public void serialize(XMLStreamWriter writer) throws XMLStreamException {
+ writer.writeStartElement("", "root", "urn:test");
+ writer.writeDefaultNamespace("urn:test");
+ writer.setDefaultNamespace("urn:test");
+ writer.writeStartElement("", "child", "urn:test");
+ writer.writeCharacters("test");
+ writer.writeEndElement();
+ writer.writeEndElement();
+ }
+
+ public boolean isDestructiveWrite() {
+ return false;
+ }
+ });
+ OMElement child = element.getFirstElement();
+ assertNull(child.getPrefix());
+ assertEquals("urn:test", child.getNamespaceURI());
+ assertEquals("child", child.getLocalName());
+ assertFalse(child.getAllDeclaredNamespaces().hasNext());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteStartElementWithDefaultNamespaceDeclaredOnParent.java
------------------------------------------------------------------------------
svn:eol-style = native