Author: veithen
Date: Sat Jul 16 11:44:44 2011
New Revision: 1147402
URL: http://svn.apache.org/viewvc?rev=1147402&view=rev
Log:
AXIOM-311: Refactored some test cases related to namespace declarations.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestChildReDeclaringGrandParentsDefaultNSWithPrefix.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestChildReDeclaringParentsDefaultNSWithPrefix.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareDefaultNamespace1.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareDefaultNamespace2.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestMultipleDefaultNS.java
(with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestCase.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/test/java/org/apache/axiom/om/OMElementTestBase.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java?rev=1147402&r1=1147401&r2=1147402&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java
Sat Jul 16 11:44:44 2011
@@ -19,12 +19,10 @@
package org.apache.axiom.om;
-import java.io.ByteArrayInputStream;
import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
import org.apache.axiom.om.util.AXIOMUtil;
@@ -97,139 +95,4 @@ public abstract class OMElementTestBase
assertEquals("urn:a", ns.getNamespaceURI());
root.close(false);
}
-
- private int getNumberOfOccurrences(String xml, String pattern) {
- int index = -1;
- int count = 0;
- while ((index = xml.indexOf(pattern, index + 1)) != -1) {
- count++;
- }
-
- return count;
- }
-
- public void testDeclareDefaultNamespace1() throws XMLStreamException {
-
- /**
- * <RootElement xmlns="http://one.org">
- * <ns2:ChildElementOne xmlns:ns2="http://ws.apache.org/axis2"
xmlns="http://two.org">
- * <ChildElementTwo xmlns="http://one.org" />
- * </ns2:ChildElementOne>
- * </RootElement>
- */
-
- OMFactory omFac = omMetaFactory.getOMFactory();
-
- OMElement documentElement = omFac.createOMElement("RootElement", null);
- documentElement.declareDefaultNamespace("http://one.org");
-
- OMNamespace ns = omFac.createOMNamespace("http://ws.apache.org/axis2",
"ns2");
- OMElement childOne = omFac.createOMElement("ChildElementOne", ns,
documentElement);
- childOne.declareDefaultNamespace("http://two.org");
-
- OMElement childTwo = omFac.createOMElement("ChildElementTwo", null,
childOne);
- childTwo.declareDefaultNamespace("http://one.org");
-
-
- assertEquals(2,
getNumberOfOccurrences(documentElement.toStringWithConsume(),
- "xmlns=\"http://one.org\""));
- }
-
- public void testDeclareDefaultNamespace2() throws XMLStreamException {
-
- /**
- * <RootElement xmlns:ns1="http://one.org" xmlns:ns2="http://one.org">
- * <ns2:ChildElementOne xmlns="http://one.org">
- * <ns2:ChildElementTwo />
- * </ns2:ChildElementOne>
- * </RootElement>
- */
-
- OMFactory omFac = omMetaFactory.getOMFactory();
-
- OMElement documentElement = omFac.createOMElement("RootElement", null);
- OMNamespace ns1 = documentElement.declareNamespace("http://one.org",
"ns1");
- OMNamespace ns2 = documentElement.declareNamespace("http://one.org",
"ns2");
-
- OMElement childOne = omFac.createOMElement("ChildElementOne", ns2,
documentElement);
- childOne.declareDefaultNamespace("http://one.org");
-
- OMElement childTwo = omFac.createOMElement("ChildElementTwo", ns1,
childOne);
-
- assertEquals(1,
getNumberOfOccurrences(documentElement.toStringWithConsume(),
- "xmlns:ns2=\"http://one.org\""));
- }
-
- public void testMultipleDefaultNS() {
- OMFactory omFactory = omMetaFactory.getOMFactory();
- OMNamespace defaultNS1 =
omFactory.createOMNamespace("http://defaultNS1.org", null);
- OMNamespace defaultNS2 =
omFactory.createOMNamespace("http://defaultNS2.org", null);
-
- OMElement omElementOne = omFactory.createOMElement("DocumentElement",
null);
- omElementOne.declareDefaultNamespace("http://defaultNS1.org");
- OMElement omElementOneChild = omFactory.createOMElement("ChildOne",
null, omElementOne);
-
-
- OMElement omElementTwo = omFactory.createOMElement("Foo", defaultNS2,
omElementOne);
- omElementTwo.declareDefaultNamespace("http://defaultNS2.org");
- OMElement omElementTwoChild = omFactory.createOMElement("ChildOne",
null, omElementTwo);
-
- OMElement omElementThree = omFactory.createOMElement("Bar",
defaultNS1, omElementTwo);
- omElementThree.declareDefaultNamespace("http://defaultNS1.org");
-
- OMNamespace omElementOneChildNS = omElementOneChild.getNamespace();
- OMNamespace omElementTwoChildNS = omElementTwoChild.getNamespace();
- // TODO: LLOM's and DOOM's behaviors are slightly different here; need
to check if both are allowed
- assertTrue(omElementOneChildNS == null ||
"".equals(omElementOneChildNS.getNamespaceURI()));
- assertTrue(omElementTwoChildNS == null ||
"".equals(omElementTwoChildNS.getNamespaceURI()));
- }
-
- public void testChildReDeclaringParentsDefaultNSWithPrefix() throws
Exception {
- OMFactory fac = omMetaFactory.getOMFactory();
- OMElement elem = fac.createOMElement("RequestSecurityToken", null);
-
elem.declareDefaultNamespace("http://schemas.xmlsoap.org/ws/2005/02/trust");
- fac.createOMElement(new QName("TokenType"), elem).setText("test");
- fac.createOMElement(new QName("RequestType"), elem).setText("test1");
-
- fac.createOMElement(
- new QName("http://schemas.xmlsoap.org/ws/2005/02/trust",
"Entropy", "wst"),
- elem);
- String xml = elem.toString();
-
- OMXMLParserWrapper builder =
OMXMLBuilderFactory.createOMBuilder(omMetaFactory.getOMFactory(),
- new ByteArrayInputStream(xml.getBytes()));
-
- builder.getDocumentElement().build();
-
- // The StAX implementation may or may not have a trailing blank in the
tag
- String assertText1 =
- "<wst:Entropy
xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\" />";
- String assertText2 =
- "<wst:Entropy
xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\"/>";
- String assertText3 =
- "<wst:Entropy
xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\"></wst:Entropy>";
-
- assertTrue((xml.indexOf(assertText1) != -1) ||
- (xml.indexOf(assertText2) != -1) ||
- (xml.indexOf(assertText3) != -1));
- }
-
- public void testChildReDeclaringGrandParentsDefaultNSWithPrefix() {
- OMFactory fac = omMetaFactory.getOMFactory();
- OMElement elem = fac.createOMElement("RequestSecurityToken", null);
-
elem.declareDefaultNamespace("http://schemas.xmlsoap.org/ws/2005/02/trust");
- fac.createOMElement(new QName("TokenType"), elem).setText("test");
- fac.createOMElement(new QName("RequestType"), elem).setText("test1");
-
- OMElement entElem = fac.createOMElement(
- new QName("http://schemas.xmlsoap.org/ws/2005/02/trust",
"Entropy", "wst"),
- elem);
- OMElement binSecElem = fac.createOMElement(
- new QName("http://schemas.xmlsoap.org/ws/2005/02/trust",
"Binarysecret", "wst"),
- entElem);
- binSecElem.setText("secret value");
- String xml = elem.toString();
- assertTrue("Binarysecret element should have \'wst\' ns prefix",
- xml.indexOf("<wst:Binarysecret") != -1);
- }
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestCase.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestCase.java?rev=1147402&r1=1147401&r2=1147402&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestCase.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestCase.java
Sat Jul 16 11:44:44 2011
@@ -66,4 +66,14 @@ public abstract class AxiomTestCase exte
return childCount;
}
+
+ protected static int getNumberOfOccurrences(String xml, String pattern) {
+ int index = -1;
+ int count = 0;
+ while ((index = xml.indexOf(pattern, index + 1)) != -1) {
+ count++;
+ }
+
+ return count;
+ }
}
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=1147402&r1=1147401&r2=1147402&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
Sat Jul 16 11:44:44 2011
@@ -78,6 +78,10 @@ public class OMTestSuiteBuilder extends
addTest(new
org.apache.axiom.ts.om.element.TestAddAttributeWithoutNamespace(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestAddChild(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestAddChildWithParent(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.element.TestChildReDeclaringGrandParentsDefaultNSWithPrefix(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.element.TestChildReDeclaringParentsDefaultNSWithPrefix(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.element.TestDeclareDefaultNamespace1(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.element.TestDeclareDefaultNamespace2(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestDeclareNamespace1(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestGetAllAttributes1(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestGetAllAttributes2(metaFactory));
@@ -116,6 +120,7 @@ public class OMTestSuiteBuilder extends
addTest(new
org.apache.axiom.ts.om.element.TestGetXMLStreamReaderOnNonRootElement(metaFactory,
false));
addTest(new
org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithOMSourcedElementDescendant(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestIsCompleteAfterAddingIncompleteChild(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.element.TestMultipleDefaultNS(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestResolveQNameWithDefaultNamespace(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestResolveQNameWithNonDefaultNamespace(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestResolveQNameWithoutNamespace(metaFactory));
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestChildReDeclaringGrandParentsDefaultNSWithPrefix.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestChildReDeclaringGrandParentsDefaultNSWithPrefix.java?rev=1147402&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestChildReDeclaringGrandParentsDefaultNSWithPrefix.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestChildReDeclaringGrandParentsDefaultNSWithPrefix.java
Sat Jul 16 11:44:44 2011
@@ -0,0 +1,51 @@
+/*
+ * 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.ts.AxiomTestCase;
+
+public class TestChildReDeclaringGrandParentsDefaultNSWithPrefix extends
AxiomTestCase {
+ public TestChildReDeclaringGrandParentsDefaultNSWithPrefix(OMMetaFactory
metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory fac = metaFactory.getOMFactory();
+ OMElement elem = fac.createOMElement("RequestSecurityToken", null);
+
elem.declareDefaultNamespace("http://schemas.xmlsoap.org/ws/2005/02/trust");
+ fac.createOMElement(new QName("TokenType"), elem).setText("test");
+ fac.createOMElement(new QName("RequestType"), elem).setText("test1");
+
+ OMElement entElem = fac.createOMElement(
+ new QName("http://schemas.xmlsoap.org/ws/2005/02/trust",
"Entropy", "wst"),
+ elem);
+ OMElement binSecElem = fac.createOMElement(
+ new QName("http://schemas.xmlsoap.org/ws/2005/02/trust",
"Binarysecret", "wst"),
+ entElem);
+ binSecElem.setText("secret value");
+ String xml = elem.toString();
+ assertTrue("Binarysecret element should have \'wst\' ns prefix",
+ xml.indexOf("<wst:Binarysecret") != -1);
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestChildReDeclaringGrandParentsDefaultNSWithPrefix.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestChildReDeclaringParentsDefaultNSWithPrefix.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestChildReDeclaringParentsDefaultNSWithPrefix.java?rev=1147402&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestChildReDeclaringParentsDefaultNSWithPrefix.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestChildReDeclaringParentsDefaultNSWithPrefix.java
Sat Jul 16 11:44:44 2011
@@ -0,0 +1,66 @@
+/*
+ * 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 java.io.ByteArrayInputStream;
+
+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.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestChildReDeclaringParentsDefaultNSWithPrefix extends
AxiomTestCase {
+ public TestChildReDeclaringParentsDefaultNSWithPrefix(OMMetaFactory
metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory fac = metaFactory.getOMFactory();
+ OMElement elem = fac.createOMElement("RequestSecurityToken", null);
+
elem.declareDefaultNamespace("http://schemas.xmlsoap.org/ws/2005/02/trust");
+ fac.createOMElement(new QName("TokenType"), elem).setText("test");
+ fac.createOMElement(new QName("RequestType"), elem).setText("test1");
+
+ fac.createOMElement(
+ new QName("http://schemas.xmlsoap.org/ws/2005/02/trust",
"Entropy", "wst"),
+ elem);
+ String xml = elem.toString();
+
+ OMXMLParserWrapper builder =
OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(),
+ new ByteArrayInputStream(xml.getBytes()));
+
+ builder.getDocumentElement().build();
+
+ // The StAX implementation may or may not have a trailing blank in the
tag
+ String assertText1 =
+ "<wst:Entropy
xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\" />";
+ String assertText2 =
+ "<wst:Entropy
xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\"/>";
+ String assertText3 =
+ "<wst:Entropy
xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\"></wst:Entropy>";
+
+ assertTrue((xml.indexOf(assertText1) != -1) ||
+ (xml.indexOf(assertText2) != -1) ||
+ (xml.indexOf(assertText3) != -1));
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestChildReDeclaringParentsDefaultNSWithPrefix.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareDefaultNamespace1.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareDefaultNamespace1.java?rev=1147402&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareDefaultNamespace1.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareDefaultNamespace1.java
Sat Jul 16 11:44:44 2011
@@ -0,0 +1,57 @@
+/*
+ * 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;
+
+public class TestDeclareDefaultNamespace1 extends AxiomTestCase {
+ public TestDeclareDefaultNamespace1(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ /**
+ * <RootElement xmlns="http://one.org">
+ * <ns2:ChildElementOne xmlns:ns2="http://ws.apache.org/axis2"
xmlns="http://two.org">
+ * <ChildElementTwo xmlns="http://one.org" />
+ * </ns2:ChildElementOne>
+ * </RootElement>
+ */
+
+ OMFactory omFac = metaFactory.getOMFactory();
+
+ OMElement documentElement = omFac.createOMElement("RootElement", null);
+ documentElement.declareDefaultNamespace("http://one.org");
+
+ OMNamespace ns = omFac.createOMNamespace("http://ws.apache.org/axis2",
"ns2");
+ OMElement childOne = omFac.createOMElement("ChildElementOne", ns,
documentElement);
+ childOne.declareDefaultNamespace("http://two.org");
+
+ OMElement childTwo = omFac.createOMElement("ChildElementTwo", null,
childOne);
+ childTwo.declareDefaultNamespace("http://one.org");
+
+
+ assertEquals(2,
getNumberOfOccurrences(documentElement.toStringWithConsume(),
+ "xmlns=\"http://one.org\""));
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareDefaultNamespace1.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareDefaultNamespace2.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareDefaultNamespace2.java?rev=1147402&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareDefaultNamespace2.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareDefaultNamespace2.java
Sat Jul 16 11:44:44 2011
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+public class TestDeclareDefaultNamespace2 extends AxiomTestCase {
+ public TestDeclareDefaultNamespace2(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ /**
+ * <RootElement xmlns:ns1="http://one.org" xmlns:ns2="http://one.org">
+ * <ns2:ChildElementOne xmlns="http://one.org">
+ * <ns2:ChildElementTwo />
+ * </ns2:ChildElementOne>
+ * </RootElement>
+ */
+
+ OMFactory omFac = metaFactory.getOMFactory();
+
+ OMElement documentElement = omFac.createOMElement("RootElement", null);
+ OMNamespace ns1 = documentElement.declareNamespace("http://one.org",
"ns1");
+ OMNamespace ns2 = documentElement.declareNamespace("http://one.org",
"ns2");
+
+ OMElement childOne = omFac.createOMElement("ChildElementOne", ns2,
documentElement);
+ childOne.declareDefaultNamespace("http://one.org");
+
+ OMElement childTwo = omFac.createOMElement("ChildElementTwo", ns1,
childOne);
+
+ assertEquals(1,
getNumberOfOccurrences(documentElement.toStringWithConsume(),
+ "xmlns:ns2=\"http://one.org\""));
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDeclareDefaultNamespace2.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestMultipleDefaultNS.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestMultipleDefaultNS.java?rev=1147402&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestMultipleDefaultNS.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestMultipleDefaultNS.java
Sat Jul 16 11:44:44 2011
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+public class TestMultipleDefaultNS extends AxiomTestCase {
+ public TestMultipleDefaultNS(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory omFactory = metaFactory.getOMFactory();
+ OMNamespace defaultNS1 =
omFactory.createOMNamespace("http://defaultNS1.org", null);
+ OMNamespace defaultNS2 =
omFactory.createOMNamespace("http://defaultNS2.org", null);
+
+ OMElement omElementOne = omFactory.createOMElement("DocumentElement",
null);
+ omElementOne.declareDefaultNamespace("http://defaultNS1.org");
+ OMElement omElementOneChild = omFactory.createOMElement("ChildOne",
null, omElementOne);
+
+
+ OMElement omElementTwo = omFactory.createOMElement("Foo", defaultNS2,
omElementOne);
+ omElementTwo.declareDefaultNamespace("http://defaultNS2.org");
+ OMElement omElementTwoChild = omFactory.createOMElement("ChildOne",
null, omElementTwo);
+
+ OMElement omElementThree = omFactory.createOMElement("Bar",
defaultNS1, omElementTwo);
+ omElementThree.declareDefaultNamespace("http://defaultNS1.org");
+
+ OMNamespace omElementOneChildNS = omElementOneChild.getNamespace();
+ OMNamespace omElementTwoChildNS = omElementTwoChild.getNamespace();
+ // TODO: LLOM's and DOOM's behaviors are slightly different here; need
to check if both are allowed
+ assertTrue(omElementOneChildNS == null ||
"".equals(omElementOneChildNS.getNamespaceURI()));
+ assertTrue(omElementTwoChildNS == null ||
"".equals(omElementTwoChildNS.getNamespaceURI()));
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestMultipleDefaultNS.java
------------------------------------------------------------------------------
svn:eol-style = native