Author: veithen
Date: Wed Dec 21 11:07:33 2011
New Revision: 1221676
URL: http://svn.apache.org/viewvc?rev=1221676&view=rev
Log:
* AXIOM-384: Also add a getPrefix() convenience method to make the API more
consistent.
* Fixed an issue in the getPrefix() method of DOOM's Element implementation,
which was not DOM compliant.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetPrefixWithDefaultNamespace.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestGetPrefixWithNamespace.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestGetPrefixWithoutNamespace.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithDefaultNamespace.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithNamespace.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithoutNamespace.java
(with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNamedInformationItem.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/DOMCompatibilityTest.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/soap/DOMCompatibilityTest.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.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-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.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
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNamedInformationItem.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNamedInformationItem.java?rev=1221676&r1=1221675&r2=1221676&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNamedInformationItem.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNamedInformationItem.java
Wed Dec 21 11:07:33 2011
@@ -60,12 +60,22 @@ public interface OMNamedInformationItem
QName getQName();
/**
- * Get the namespace URI of the information item. Note that the contract
of this method is
+ * Get the prefix of this information item. Note that the contract of this
method is identical
+ * to DOM's {@link org.w3c.dom.Node#getPrefix()} (when called on an {@link
org.w3c.dom.Element}
+ * or {@link org.w3c.dom.Attr}).
+ *
+ * @return the prefix of the information item or <code>null</code> if the
information item has
+ * no prefix
+ */
+ String getPrefix();
+
+ /**
+ * Get the namespace URI of this information item. Note that the contract
of this method is
* identical to DOM's {@link org.w3c.dom.Node#getNamespaceURI()} (when
called on an
* {@link org.w3c.dom.Element} or {@link org.w3c.dom.Attr}).
*
- * @return the namespace URI of the information item or <code>null</code>
if the element has no
- * namespace
+ * @return the namespace URI of the information item or <code>null</code>
if the information
+ * item has no namespace
*/
String getNamespaceURI();
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/DOMCompatibilityTest.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/DOMCompatibilityTest.java?rev=1221676&r1=1221675&r2=1221676&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/DOMCompatibilityTest.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/DOMCompatibilityTest.java
Wed Dec 21 11:07:33 2011
@@ -46,7 +46,8 @@ public class DOMCompatibilityTest extend
// Note: All exceptions are methods that are known to have the same
behavior in Axiom
// and DOM. In these cases, method collisions are allowed.
suite.addTest(new MethodCollisionTestCase(OMAttribute.class,
Attr.class,
- new MethodSignature[] { new MethodSignature("getNamespaceURI",
new Class[0]),
+ new MethodSignature[] { new MethodSignature("getPrefix", new
Class[0]),
+ new MethodSignature("getNamespaceURI",
new Class[0]),
new MethodSignature("getLocalName",
new Class[0]) }));
suite.addTest(new MethodCollisionTestCase(OMComment.class,
Comment.class));
suite.addTest(new MethodCollisionTestCase(OMDocType.class,
DocumentType.class));
@@ -54,10 +55,12 @@ public class DOMCompatibilityTest extend
suite.addTest(new
MethodCollisionTestCase(OMProcessingInstruction.class,
ProcessingInstruction.class,
new MethodSignature[] { new MethodSignature("getTarget", new
Class[0]) }));
suite.addTest(new MethodCollisionTestCase(OMElement.class,
Element.class,
- new MethodSignature[] { new MethodSignature("getNamespaceURI",
new Class[0]),
+ new MethodSignature[] { new MethodSignature("getPrefix", new
Class[0]),
+ new MethodSignature("getNamespaceURI",
new Class[0]),
new MethodSignature("getLocalName",
new Class[0]) }));
suite.addTest(new MethodCollisionTestCase(OMSourcedElement.class,
Element.class,
- new MethodSignature[] { new MethodSignature("getNamespaceURI",
new Class[0]),
+ new MethodSignature[] { new MethodSignature("getPrefix", new
Class[0]),
+ new MethodSignature("getNamespaceURI",
new Class[0]),
new MethodSignature("getLocalName",
new Class[0]) }));
suite.addTest(new MethodCollisionTestCase(OMText.class, Text.class));
suite.addTest(new MethodCollisionTestCase(OMText.class,
CDATASection.class));
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/soap/DOMCompatibilityTest.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/soap/DOMCompatibilityTest.java?rev=1221676&r1=1221675&r2=1221676&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/soap/DOMCompatibilityTest.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/soap/DOMCompatibilityTest.java
Wed Dec 21 11:07:33 2011
@@ -37,6 +37,7 @@ public class DOMCompatibilityTest extend
// These methods are known to have the same behavior in Axiom and DOM:
MethodSignature[] elementExceptions = new MethodSignature[] {
+ new MethodSignature("getPrefix", new Class[0]),
new MethodSignature("getNamespaceURI", new Class[0]),
new MethodSignature("getLocalName", new Class[0]) };
@@ -48,6 +49,7 @@ public class DOMCompatibilityTest extend
// The getNodeValue and setNodeValue methods are real collisions that
will be fixed in Axiom 1.3; see AXIOM-363
suite.addTest(new MethodCollisionTestCase(SOAPFaultNode.class,
Element.class, new MethodSignature[] {
+ new MethodSignature("getPrefix", new Class[0]),
new MethodSignature("getNamespaceURI", new Class[0]),
new MethodSignature("getLocalName", new Class[0]),
new MethodSignature("getNodeValue", new Class[0]),
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java?rev=1221676&r1=1221675&r2=1221676&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
Wed Dec 21 11:07:33 2011
@@ -47,6 +47,7 @@ public class DOMTestSuiteBuilder extends
addTest(new
org.apache.axiom.ts.dom.element.TestGetElementsByTagNameWithNamespaces(dbf));
addTest(new
org.apache.axiom.ts.dom.element.TestGetElementsByTagNameWithWildcard(dbf));
addTest(new
org.apache.axiom.ts.dom.element.TestGetNamespaceURIWithNoNamespace(dbf));
+ addTest(new
org.apache.axiom.ts.dom.element.TestGetPrefixWithDefaultNamespace(dbf));
addTest(new org.apache.axiom.ts.dom.element.TestGetTextContent(dbf));
addTest(new org.apache.axiom.ts.dom.element.TestInsertBefore(dbf));
addTest(new
org.apache.axiom.ts.dom.element.TestInsertBeforeWithDocumentFragment(dbf));
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetPrefixWithDefaultNamespace.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetPrefixWithDefaultNamespace.java?rev=1221676&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetPrefixWithDefaultNamespace.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetPrefixWithDefaultNamespace.java
Wed Dec 21 11:07:33 2011
@@ -0,0 +1,37 @@
+/*
+ * 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.dom.element;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class TestGetPrefixWithDefaultNamespace extends DOMTestCase {
+ public TestGetPrefixWithDefaultNamespace(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ Document doc = dbf.newDocumentBuilder().newDocument();
+ Element element = doc.createElementNS("urn:test", "test");
+ assertNull(element.getPrefix());
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetPrefixWithDefaultNamespace.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1221676&r1=1221675&r2=1221676&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
Wed Dec 21 11:07:33 2011
@@ -1226,7 +1226,13 @@ public class ElementImpl extends ParentN
* @see org.w3c.dom.Node#getPrefix()
*/
public String getPrefix() {
- return (this.namespace == null) ? null : this.namespace.getPrefix();
+ OMNamespace ns = getNamespace();
+ if (ns == null) {
+ return null;
+ } else {
+ String prefix = ns.getPrefix();
+ return prefix.length() == 0 ? null : prefix;
+ }
}
/** @see NodeImpl#setOwnerDocument
(org.apache.axiom.om.impl.dom.DocumentImpl) */
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java?rev=1221676&r1=1221675&r2=1221676&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
Wed Dec 21 11:07:33 2011
@@ -175,6 +175,16 @@ public class OMAttributeImpl implements
return namespace;
}
+ public String getPrefix() {
+ OMNamespace ns = getNamespace();
+ if (ns == null) {
+ return null;
+ } else {
+ String prefix = ns.getPrefix();
+ return prefix.length() == 0 ? null : prefix;
+ }
+ }
+
public String getNamespaceURI() {
OMNamespace ns = getNamespace();
if (ns == null) {
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=1221676&r1=1221675&r2=1221676&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
Wed Dec 21 11:07:33 2011
@@ -981,6 +981,16 @@ public class OMElementImpl extends OMNod
return ns;
}
+ public String getPrefix() {
+ OMNamespace ns = getNamespace();
+ if (ns == null) {
+ return null;
+ } else {
+ String prefix = ns.getPrefix();
+ return prefix.length() == 0 ? null : prefix;
+ }
+ }
+
public String getNamespaceURI() {
OMNamespace ns = getNamespace();
if (ns == 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=1221676&r1=1221675&r2=1221676&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
Wed Dec 21 11:07:33 2011
@@ -534,6 +534,10 @@ public class OMSourcedElementImpl extend
return definedNamespace;
}
+ public String getPrefix() {
+ return super.getPrefix();
+ }
+
public String getNamespaceURI() {
return super.getNamespaceURI();
}
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=1221676&r1=1221675&r2=1221676&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
Wed Dec 21 11:07:33 2011
@@ -56,6 +56,8 @@ public class OMTestSuiteBuilder extends
addTest(new
org.apache.axiom.ts.om.attribute.TestEqualsHashCode(metaFactory));
addTest(new
org.apache.axiom.ts.om.attribute.TestGetNamespaceURIWithNamespace(metaFactory));
addTest(new
org.apache.axiom.ts.om.attribute.TestGetNamespaceURIWithoutNamespace(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.attribute.TestGetPrefixWithNamespace(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.attribute.TestGetPrefixWithoutNamespace(metaFactory));
addTest(new
org.apache.axiom.ts.om.attribute.TestGetQNameWithNamespace(metaFactory));
addTest(new
org.apache.axiom.ts.om.attribute.TestGetQNameWithoutNamespace(metaFactory));
for (int i=0; i<conformanceFiles.length; i++) {
@@ -170,6 +172,9 @@ public class OMTestSuiteBuilder extends
addTest(new
org.apache.axiom.ts.om.element.TestGetNamespacesInScopeWithMaskedNamespace(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestGetNamespaceURIWithNamespace(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestGetNamespaceURIWithoutNamespace(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.element.TestGetPrefixWithDefaultNamespace(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.element.TestGetPrefixWithNamespace(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.element.TestGetPrefixWithoutNamespace(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestGetQNameWithNamespace(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestGetQNameWithoutNamespace(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestGetText(metaFactory));
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestGetPrefixWithNamespace.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestGetPrefixWithNamespace.java?rev=1221676&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestGetPrefixWithNamespace.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestGetPrefixWithNamespace.java
Wed Dec 21 11:07:33 2011
@@ -0,0 +1,41 @@
+/*
+ * 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.attribute;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamedInformationItem;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests that {@link OMNamedInformationItem#getPrefix()} returns the prefix
when invoked on an
+ * {@link OMAttribute} that has a namespace.
+ */
+public class TestGetPrefixWithNamespace extends AxiomTestCase {
+ public TestGetPrefixWithNamespace(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory factory = metaFactory.getOMFactory();
+ OMAttribute attr = factory.createOMAttribute("name",
factory.createOMNamespace("urn:ns", "p"), "value");
+ assertEquals("p", attr.getPrefix());
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestGetPrefixWithNamespace.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestGetPrefixWithoutNamespace.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestGetPrefixWithoutNamespace.java?rev=1221676&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestGetPrefixWithoutNamespace.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestGetPrefixWithoutNamespace.java
Wed Dec 21 11:07:33 2011
@@ -0,0 +1,41 @@
+/*
+ * 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.attribute;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamedInformationItem;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests that {@link OMNamedInformationItem#getPrefix()} returns
<code>null</code> when invoked on
+ * an {@link OMAttribute} that has no namespace.
+ */
+public class TestGetPrefixWithoutNamespace extends AxiomTestCase {
+ public TestGetPrefixWithoutNamespace(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory factory = metaFactory.getOMFactory();
+ OMAttribute attr = factory.createOMAttribute("name", null, "value");
+ assertNull(attr.getPrefix());
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestGetPrefixWithoutNamespace.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithDefaultNamespace.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithDefaultNamespace.java?rev=1221676&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithDefaultNamespace.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithDefaultNamespace.java
Wed Dec 21 11:07:33 2011
@@ -0,0 +1,41 @@
+/*
+ * 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.OMNamedInformationItem;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests that {@link OMNamedInformationItem#getPrefix()} returns
<code>null</code> when invoked on
+ * an {@link OMElement} that has a namespace without a prefix.
+ */
+public class TestGetPrefixWithDefaultNamespace extends AxiomTestCase {
+ public TestGetPrefixWithDefaultNamespace(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory factory = metaFactory.getOMFactory();
+ OMElement element = factory.createOMElement("test",
factory.createOMNamespace("urn:ns", ""));
+ assertNull(element.getPrefix());
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithDefaultNamespace.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithNamespace.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithNamespace.java?rev=1221676&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithNamespace.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithNamespace.java
Wed Dec 21 11:07:33 2011
@@ -0,0 +1,43 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamedInformationItem;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests that {@link OMNamedInformationItem#getPrefix()} returns the prefix
when invoked on an
+ * {@link OMElement} that has a namespace with a prefix.
+ */
+public class TestGetPrefixWithNamespace extends AxiomTestCase {
+ public TestGetPrefixWithNamespace(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory factory = metaFactory.getOMFactory();
+ OMElement element = factory.createOMElement(new QName("urn:ns",
"test", "p"));
+ assertEquals("p", element.getPrefix());
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithNamespace.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithoutNamespace.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithoutNamespace.java?rev=1221676&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithoutNamespace.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithoutNamespace.java
Wed Dec 21 11:07:33 2011
@@ -0,0 +1,43 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamedInformationItem;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests that {@link OMNamedInformationItem#getPrefix()} returns
<code>null</code> when invoked on
+ * an {@link OMElement} that has no namespace.
+ */
+public class TestGetPrefixWithoutNamespace extends AxiomTestCase {
+ public TestGetPrefixWithoutNamespace(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory factory = metaFactory.getOMFactory();
+ OMElement element = factory.createOMElement(new QName("test"));
+ assertNull(element.getPrefix());
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetPrefixWithoutNamespace.java
------------------------------------------------------------------------------
svn:eol-style = native