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/11/22 23:22:35 UTC
svn commit: r1205194 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-api/src/main/java/org/apache/axiom/om/
axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/
axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/
axiom-impl/src/...
Author: veithen
Date: Tue Nov 22 22:22:33 2011
New Revision: 1205194
URL: http://svn.apache.org/viewvc?rev=1205194&view=rev
Log:
AXIOM-400: Make sure that OMFactory#createOMElement(String, OMNamespace, OMContainer) generates a namespace declaration if necessary for a null OMNamespace.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetDefaultNamespace2.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace2.java (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java
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/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.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-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetDefaultNamespace.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java?rev=1205194&r1=1205193&r2=1205194&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java Tue Nov 22 22:22:33 2011
@@ -60,11 +60,16 @@ public interface OMFactory {
/**
* Create an element with the given name and parent. If the specified {@link OMNamespace} has a
- * namespace URI but a <code>null</code> prefix, the method will use an appropriate prefix if a
- * corresponding namespace declaration is in scope on the parent or generate a new prefix if no
- * corresponding namespace declaration is in scope. If a new prefix is generated or if the
- * specified prefix and namespace URI are not bound in the scope of the parent element, the
- * method will add an appropriate namespace declaration to the new element.
+ * namespace URI but a <code>null</code> prefix, the method will reuse an existing prefix if a
+ * namespace declaration with a matching namespace URI is in scope on the parent or generate a
+ * new prefix if no such namespace declaration exists.
+ * <p>
+ * If a new prefix is generated or if the specified prefix and namespace URI are not bound in
+ * the scope of the parent element, the method will add an appropriate namespace declaration to
+ * the new element. Note that this may also occur if <code>null</code> is passed as
+ * {@link OMNamespace} parameter. In that case, if there is a default namespace declaration with
+ * a non empty namespace URI in the scope of the parent element, a namespace declaration needs
+ * to be added to the newly created element to override the default namespace.
*
* @param localName
* @param ns
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=1205194&r1=1205193&r2=1205194&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 Tue Nov 22 22:22:33 2011
@@ -130,9 +130,10 @@ public class ElementImpl extends ParentN
public ElementImpl(ParentNode parentNode, String tagName, OMNamespaceImpl ns,
OMFactory factory) {
- this((DocumentImpl) parentNode.getOwnerDocument(), tagName, ns, factory);
+ this((DocumentImpl) parentNode.getOwnerDocument(), tagName, null, factory);
parentNode.addChild(this);
this.done = true;
+ namespace = handleNamespace(ns);
}
public ElementImpl(ParentNode parentNode, String tagName, OMNamespaceImpl ns,
@@ -163,16 +164,27 @@ public class ElementImpl extends ParentN
}
private OMNamespace handleNamespace(OMNamespace ns) {
- String namespaceURI = ns.getNamespaceURI();
- String prefix = ns.getPrefix();
+ String namespaceURI = ns == null ? "" : ns.getNamespaceURI();
+ String prefix = ns == null ? "" : ns.getPrefix();
if (namespaceURI.length() == 0 && prefix != null && prefix.length() > 0) {
throw new IllegalArgumentException("Cannot create a prefixed element with an empty namespace name");
}
- OMNamespace namespace = findNamespace(namespaceURI, prefix);
- if (namespace == null) {
- namespace = declareNamespace(ns);
+ if (namespaceURI.length() == 0) {
+ // Special case: no namespace; we need to generate a namespace declaration only if
+ // there is a conflicting namespace declaration (i.e. a declaration for the default
+ // namespace with a non empty URI) is in scope
+ OMNamespace defaultNamespace = getDefaultNamespace();
+ if (defaultNamespace != null && defaultNamespace.getNamespaceURI().length() > 0) {
+ declareDefaultNamespace("");
+ }
+ return ns; // TODO: actually this should be null if we want to normalize the OMNamespace (see AXIOM-398)
+ } else {
+ OMNamespace namespace = findNamespace(namespaceURI, prefix);
+ if (namespace == null) {
+ namespace = declareNamespace(ns);
+ }
+ return namespace;
}
- return namespace;
}
// /
@@ -1077,10 +1089,7 @@ public class ElementImpl extends ParentN
}
public void setNamespace(OMNamespace namespace) {
- if (namespace != null) {
- namespace = handleNamespace(namespace);
- }
- this.namespace = namespace;
+ this.namespace = handleNamespace(namespace);
}
public void setNamespaceWithNoFindInCurrentScope(OMNamespace namespace) {
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java?rev=1205194&r1=1205193&r2=1205194&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java Tue Nov 22 22:22:33 2011
@@ -127,11 +127,7 @@ public class OMDOMFactory implements OMF
switch (((ParentNode) parent).getNodeType()) {
case Node.ELEMENT_NODE: { // We are adding a new child to an elem
- ElementImpl parentElem = (ElementImpl) parent;
- ElementImpl elem = new ElementImpl((DocumentImpl) parentElem
- .getOwnerDocument(), localName, (OMNamespaceImpl) ns, this);
- parentElem.appendChild(elem);
- return elem;
+ return new ElementImpl((ElementImpl) parent, localName, (OMNamespaceImpl) ns, this);
}
case Node.DOCUMENT_NODE: {
DocumentImpl docImpl = (DocumentImpl) parent;
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=1205194&r1=1205193&r2=1205194&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 Tue Nov 22 22:22:33 2011
@@ -135,9 +135,7 @@ public class OMElementImpl extends OMNod
throw new OMException("localname can not be null or empty");
}
this.localName = localName;
- if (ns != null) {
- setNamespace(ns);
- }
+ setNamespace(ns);
}
/**
@@ -148,7 +146,8 @@ public class OMElementImpl extends OMNod
*/
public OMElementImpl(QName qname, OMContainer parent, OMFactory factory)
throws OMException {
- this(qname.getLocalPart(), null, parent, factory);
+ super(parent, factory, true);
+ localName = qname.getLocalPart();
this.ns = handleNamespace(qname);
}
@@ -184,16 +183,27 @@ public class OMElementImpl extends OMNod
}
private OMNamespace handleNamespace(OMNamespace ns) {
- String namespaceURI = ns.getNamespaceURI();
- String prefix = ns.getPrefix();
+ String namespaceURI = ns == null ? "" : ns.getNamespaceURI();
+ String prefix = ns == null ? "" : ns.getPrefix();
if (namespaceURI.length() == 0 && prefix != null && prefix.length() > 0) {
throw new IllegalArgumentException("Cannot create a prefixed element with an empty namespace name");
}
- OMNamespace namespace = findNamespace(namespaceURI, prefix);
- if (namespace == null) {
- namespace = declareNamespace(ns);
+ if (namespaceURI.length() == 0) {
+ // Special case: no namespace; we need to generate a namespace declaration only if
+ // there is a conflicting namespace declaration (i.e. a declaration for the default
+ // namespace with a non empty URI) is in scope
+ OMNamespace defaultNamespace = getDefaultNamespace();
+ if (defaultNamespace != null && defaultNamespace.getNamespaceURI().length() > 0) {
+ declareDefaultNamespace("");
+ }
+ return ns; // TODO: actually this should be null if we want to normalize the OMNamespace (see AXIOM-398)
+ } else {
+ OMNamespace namespace = findNamespace(namespaceURI, prefix);
+ if (namespace == null) {
+ namespace = declareNamespace(ns);
+ }
+ return namespace;
}
- return namespace;
}
OMNamespace handleNamespace(String namespaceURI, String prefix) {
@@ -978,10 +988,7 @@ public class OMElementImpl extends OMNod
}
public void setNamespace(OMNamespace namespace) {
- if (namespace != null) {
- namespace = handleNamespace(namespace);
- }
- this.ns = namespace;
+ this.ns = handleNamespace(namespace);
this.qName = null;
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java?rev=1205194&r1=1205193&r2=1205194&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java Tue Nov 22 22:22:33 2011
@@ -240,7 +240,10 @@ public class OMSourcedElementImpl extend
* tree on demand, this first creates a builder
*/
private void forceExpand() {
- if (!isExpanded) {
+ // The dataSource != null is required because this method may be called indirectly
+ // by the constructor before the data source is set. After the constructor has completed,
+ // isExpanded is always true if dataSource is null.
+ if (!isExpanded && dataSource != null) {
if (isDebugEnabled) {
log.debug("forceExpand: expanding element " +
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=1205194&r1=1205193&r2=1205194&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 Tue Nov 22 22:22:33 2011
@@ -151,6 +151,7 @@ public class OMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.om.element.TestGetChildrenWithNameNextWithoutHasNext(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestGetChildrenWithNamespaceURI(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestGetDefaultNamespace(metaFactory));
+ addTest(new org.apache.axiom.ts.om.element.TestGetDefaultNamespace2(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestGetDescendants(metaFactory, true));
addTest(new org.apache.axiom.ts.om.element.TestGetDescendants(metaFactory, false));
addTest(new org.apache.axiom.ts.om.element.TestGetFirstChildWithName(metaFactory));
@@ -241,6 +242,9 @@ public class OMTestSuiteBuilder extends
}
addTest(new org.apache.axiom.ts.om.factory.TestCreateOMElementWithNonDefaultNamespace(metaFactory, creator));
addTest(new org.apache.axiom.ts.om.factory.TestCreateOMElementWithoutNamespace(metaFactory, creator));
+ if (creator.isSupportsContainer() && creator.isSupportsDefaultNamespace()) {
+ addTest(new org.apache.axiom.ts.om.factory.TestCreateOMElementWithoutNamespace2(metaFactory, creator));
+ }
}
addTest(new org.apache.axiom.ts.om.factory.TestCreateOMElementWithNullURIAndPrefix(metaFactory));
addTest(new org.apache.axiom.ts.om.factory.TestCreateOMNamespace(metaFactory));
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetDefaultNamespace.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetDefaultNamespace.java?rev=1205194&r1=1205193&r2=1205194&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetDefaultNamespace.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetDefaultNamespace.java Tue Nov 22 22:22:33 2011
@@ -18,6 +18,8 @@
*/
package org.apache.axiom.ts.om.element;
+import javax.xml.namespace.QName;
+
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMMetaFactory;
@@ -31,11 +33,11 @@ public class TestGetDefaultNamespace ext
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
- OMElement parent = factory.createOMElement("parent", "urn:test", "");
- OMElement child = factory.createOMElement("child", null, parent);
+ OMElement parent = factory.createOMElement("parent", "urn:ns1", "");
+ OMElement child = factory.createOMElement(new QName("urn:ns2", "child", "p"), parent);
OMNamespace ns = child.getDefaultNamespace();
assertNotNull(ns);
assertEquals("", ns.getPrefix());
- assertEquals("urn:test", ns.getNamespaceURI());
+ assertEquals("urn:ns1", ns.getNamespaceURI());
}
}
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetDefaultNamespace2.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetDefaultNamespace2.java?rev=1205194&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetDefaultNamespace2.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetDefaultNamespace2.java Tue Nov 22 22:22:33 2011
@@ -0,0 +1,50 @@
+/*
+ * 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 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 the behavior of {@link OMElement#getDefaultNamespace()} in the special case where the
+ * element has no namespace and was created as a child element of an element having a default
+ * namespace with a non empty namespace URI. In this case the element must have a namespace
+ * declaration that overrides the default namespace. Therefore
+ * {@link OMElement#getDefaultNamespace()} must return null.
+ * <p>
+ * This is a regression test for
+ * <a href="https://issues.apache.org/jira/browse/AXIOM-400">AXIOM-400</a>.
+ */
+public class TestGetDefaultNamespace2 extends AxiomTestCase {
+ public TestGetDefaultNamespace2(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory factory = metaFactory.getOMFactory();
+ OMElement parent = factory.createOMElement("parent", "urn:test", "");
+ OMElement child = factory.createOMElement("child", null, parent);
+ OMNamespace ns = child.getDefaultNamespace();
+ // TODO: need to specify if getDefaultNamespace should return null or ("","")
+ assertTrue(ns == null || ns.equals("", ""));
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetDefaultNamespace2.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace.java?rev=1205194&r1=1205193&r2=1205194&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace.java Tue Nov 22 22:22:33 2011
@@ -22,6 +22,11 @@ import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMMetaFactory;
+/**
+ * Tests the behavior of the <code>createOMElement</code> methods in {@link OMFactory} when
+ * requested to create an element without namespace and without parent. In this case, no namespace
+ * declaration is added to the created element.
+ */
public class TestCreateOMElementWithoutNamespace extends CreateOMElementTestCase {
public TestCreateOMElementWithoutNamespace(OMMetaFactory metaFactory, OMElementCreator variant) {
super(metaFactory, variant);
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace2.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace2.java?rev=1205194&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace2.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace2.java Tue Nov 22 22:22:33 2011
@@ -0,0 +1,56 @@
+/*
+ * 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} when
+ * requested to create an element without namespace as a child of an element that has a default
+ * namespace with a non empty namespace URI. In this case, a namespace declaration is added to the
+ * created element to override the default namespace.
+ * <p>
+ * This is a regression test for
+ * <a href="https://issues.apache.org/jira/browse/AXIOM-400">AXIOM-400</a>.
+ */
+public class TestCreateOMElementWithoutNamespace2 extends CreateOMElementTestCase {
+ public TestCreateOMElementWithoutNamespace2(OMMetaFactory metaFactory, OMElementCreator variant) {
+ super(metaFactory, variant);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory factory = metaFactory.getOMFactory();
+ OMElement parent = factory.createOMElement("parent",
+ factory.createOMNamespace("urn:test", ""));
+ OMElement child = variant.createOMElement(factory, parent, "test", "", "");
+ assertEquals("test", child.getLocalName());
+ assertNull(child.getNamespace());
+ Iterator it = child.getAllDeclaredNamespaces();
+ assertTrue(it.hasNext());
+ OMNamespace decl = (OMNamespace)it.next();
+ assertEquals("", decl.getPrefix());
+ assertEquals("", decl.getNamespaceURI());
+ assertFalse(it.hasNext());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace2.java
------------------------------------------------------------------------------
svn:eol-style = native