Author: veithen
Date: Sun Jan 2 17:19:28 2011
New Revision: 1054434
URL: http://svn.apache.org/viewvc?rev=1054434&view=rev
Log:
AXIOM-311: Refactored some existing test cases.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildElements.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildren.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove1.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove2.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove3.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove4.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithLocalName.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName.java
(with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
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/AxiomTestSuiteBuilder.java
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java?rev=1054434&r1=1054433&r2=1054434&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
Sun Jan 2 17:19:28 2011
@@ -90,7 +90,7 @@ public abstract class AbstractTestCase
return in;
}
- public OMElement getTestResourceAsElement(OMMetaFactory omMetaFactory,
String relativePath) {
+ public static OMElement getTestResourceAsElement(OMMetaFactory
omMetaFactory, String relativePath) {
return
OMXMLBuilderFactory.createOMBuilder(omMetaFactory.getOMFactory(),
getTestResource(relativePath)).getDocumentElement();
}
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=1054434&r1=1054433&r2=1054434&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
Sun Jan 2 17:19:28 2011
@@ -27,7 +27,6 @@ import javax.xml.stream.XMLStreamConstan
import javax.xml.stream.XMLStreamException;
import org.apache.axiom.om.util.AXIOMUtil;
-import org.apache.axiom.soap.SOAP11Constants;
public abstract class OMElementTestBase extends AbstractTestCase {
protected final OMMetaFactory omMetaFactory;
@@ -36,148 +35,6 @@ public abstract class OMElementTestBase
this.omMetaFactory = omMetaFactory;
}
- /** Test the plain iterator which includes all the children (including the
texts) */
- public void testGetChildren() {
- OMElement elt = getTestResourceAsElement(omMetaFactory,
TestConstants.SOAP_SOAPMESSAGE1);
- Iterator iter = elt.getChildren();
- int counter = 0;
- while (iter.hasNext()) {
- counter ++;
- assertNotNull("Must return not null objects!", iter.next());
- }
- assertEquals("This element should contain only five children including
the text ", 5,
- counter);
- elt.close(false);
- }
-
- /** test the remove exception behavior */
- public void testGetChildrenRemove1() {
- OMElement elt = getTestResourceAsElement(omMetaFactory,
TestConstants.SOAP_SOAPMESSAGE1);
- Iterator iter = elt.getChildren();
-
- //this is supposed to throw an illegal state exception
- try {
- iter.remove();
- fail("remove should throw an exception");
- } catch (IllegalStateException e) {
- //ok. this is what should happen
- }
-
- elt.close(false);
- }
-
- /** test the remove exception behavior, consecutive remove calls */
- public void testGetChildrenRemove2() {
- OMElement elt = getTestResourceAsElement(omMetaFactory,
TestConstants.SOAP_SOAPMESSAGE1);
- Iterator iter = elt.getChildren();
- if (iter.hasNext()) {
- iter.next();
- }
- iter.remove();
-
- //this call must generate an exception
- try {
- iter.remove();
- fail("calling remove twice without a call to next is prohibited");
- } catch (IllegalStateException e) {
- //ok if we come here :)
- }
-
- elt.close(false);
- }
-
- /** Remove all! */
- public void testGetChildrenRemove3() {
- OMElement elt = getTestResourceAsElement(omMetaFactory,
TestConstants.SOAP_SOAPMESSAGE1);
- Iterator iter = elt.getChildren();
- while (iter.hasNext()) {
- iter.next();
- iter.remove();
- }
- iter = elt.getChildren();
- if (iter.hasNext()) {
- //we shouldn't reach here!
- fail("No children should remain after removing all!");
- }
-
- elt.close(false);
- }
-
- /** test whether the children count reduces. */
- public void testGetChildrenRemove4() {
- OMElement elt = getTestResourceAsElement(omMetaFactory,
TestConstants.SOAP_SOAPMESSAGE1);
- Iterator iter = elt.getChildren();
- int firstChildrenCount = 0;
- int secondChildrenCount = 0;
- while (iter.hasNext()) {
- assertNotNull(iter.next());
- firstChildrenCount++;
- }
-
- //remove the last node
- iter.remove();
-
- //reloop and check the count
- //Note- here we should get a fresh iterator since there is no method to
- //reset the iterator
- iter = elt.getChildren(); //reset the iterator
- while (iter.hasNext()) {
- assertNotNull(iter.next());
- secondChildrenCount++;
- }
- assertEquals("children count must reduce from 1",
- firstChildrenCount - 1,
- secondChildrenCount);
-
- elt.close(false);
- }
-
- /** Test the element iterator */
- public void testGetChildElements() {
- OMElement elt = getTestResourceAsElement(omMetaFactory,
TestConstants.SOAP_SOAPMESSAGE1);
- Iterator iter = elt.getChildElements();
- int counter = 0;
- while (iter.hasNext()) {
- counter ++;
- Object o = iter.next();
- assertNotNull("Must return not null objects!", o);
- assertTrue("All these should be elements!",
- ((OMNode) o).getType() == OMNode.ELEMENT_NODE);
- }
- assertEquals("This element should contain only two elements ", 2,
counter);
- elt.close(false);
- }
-
- /** Test the element iterator */
- public void testGetChildrenWithName() {
- OMElement elt = getTestResourceAsElement(omMetaFactory,
TestConstants.SOAP_SOAPMESSAGE1);
- QName qname = new QName(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,
- SOAP11Constants.BODY_LOCAL_NAME);
- Iterator iter = elt.getChildrenWithName(qname);
- int counter = 0;
- while (iter.hasNext()) {
- counter ++;
- Object o = iter.next();
- assertNotNull("Must return not null objects!", o);
- assertTrue("All these should be elements!",
- ((OMNode) o).getType() == OMNode.ELEMENT_NODE);
- }
- assertEquals("This element should contain only one element with the
given QName ", 1,
- counter);
- elt.close(false);
- }
-
- public void testGetChildrenWithLocalName() {
- OMElement elt = getTestResourceAsElement(omMetaFactory,
TestConstants.SOAP_SOAPMESSAGE1);
- Iterator it =
elt.getChildrenWithLocalName(SOAP11Constants.BODY_LOCAL_NAME);
- assertTrue(it.hasNext());
- OMElement child = (OMElement)it.next();
- assertEquals(new QName(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,
- SOAP11Constants.BODY_LOCAL_NAME), child.getQName());
- assertFalse(it.hasNext());
- elt.close(false);
- }
-
public void testSetText() {
OMFactory factory = omMetaFactory.getOMFactory();
String localName = "TestLocalName";
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java?rev=1054434&r1=1054433&r2=1054434&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java
Sun Jan 2 17:19:28 2011
@@ -61,6 +61,14 @@ public class AxiomTestSuiteBuilder {
addTest(new
org.apache.axiom.ts.om.element.TestGetAttributeValueWithXmlPrefix2(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestGetAttributeWithXmlPrefix1(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestGetAttributeWithXmlPrefix2(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.element.TestGetChildElements(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.element.TestGetChildren(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.element.TestGetChildrenRemove1(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.element.TestGetChildrenRemove2(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.element.TestGetChildrenRemove3(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.element.TestGetChildrenRemove4(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.element.TestGetChildrenWithLocalName(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.element.TestGetChildrenWithName(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestGetFirstChildWithName(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestIsCompleteAfterAddingIncompleteChild(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestSerialization(metaFactory, "D", "D",
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildElements.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildElements.java?rev=1054434&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildElements.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildElements.java
Sun Jan 2 17:19:28 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 java.util.Iterator;
+
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.TestConstants;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/** Test the element iterator */
+public class TestGetChildElements extends AxiomTestCase {
+ public TestGetChildElements(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMElement elt = AbstractTestCase.getTestResourceAsElement(metaFactory,
TestConstants.SOAP_SOAPMESSAGE1);
+ Iterator iter = elt.getChildElements();
+ int counter = 0;
+ while (iter.hasNext()) {
+ counter ++;
+ Object o = iter.next();
+ assertNotNull("Must return not null objects!", o);
+ assertTrue("All these should be elements!",
+ ((OMNode) o).getType() == OMNode.ELEMENT_NODE);
+ }
+ assertEquals("This element should contain only two elements ", 2,
counter);
+ elt.close(false);
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildElements.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildren.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildren.java?rev=1054434&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildren.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildren.java
Sun Jan 2 17:19:28 2011
@@ -0,0 +1,47 @@
+/*
+ * 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.util.Iterator;
+
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.TestConstants;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/** Test the plain iterator which includes all the children (including the
texts) */
+public class TestGetChildren extends AxiomTestCase {
+ public TestGetChildren(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMElement elt = AbstractTestCase.getTestResourceAsElement(metaFactory,
TestConstants.SOAP_SOAPMESSAGE1);
+ Iterator iter = elt.getChildren();
+ int counter = 0;
+ while (iter.hasNext()) {
+ counter ++;
+ assertNotNull("Must return not null objects!", iter.next());
+ }
+ assertEquals("This element should contain only five children including
the text ", 5,
+ counter);
+ elt.close(false);
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildren.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove1.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove1.java?rev=1054434&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove1.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove1.java
Sun Jan 2 17:19:28 2011
@@ -0,0 +1,49 @@
+/*
+ * 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.util.Iterator;
+
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.TestConstants;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/** test the remove exception behavior */
+public class TestGetChildrenRemove1 extends AxiomTestCase {
+ public TestGetChildrenRemove1(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMElement elt = AbstractTestCase.getTestResourceAsElement(metaFactory,
TestConstants.SOAP_SOAPMESSAGE1);
+ Iterator iter = elt.getChildren();
+
+ //this is supposed to throw an illegal state exception
+ try {
+ iter.remove();
+ fail("remove should throw an exception");
+ } catch (IllegalStateException e) {
+ //ok. this is what should happen
+ }
+
+ elt.close(false);
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove1.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove2.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove2.java?rev=1054434&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove2.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove2.java
Sun Jan 2 17:19:28 2011
@@ -0,0 +1,53 @@
+/*
+ * 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.util.Iterator;
+
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.TestConstants;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/** test the remove exception behavior, consecutive remove calls */
+public class TestGetChildrenRemove2 extends AxiomTestCase {
+ public TestGetChildrenRemove2(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMElement elt = AbstractTestCase.getTestResourceAsElement(metaFactory,
TestConstants.SOAP_SOAPMESSAGE1);
+ Iterator iter = elt.getChildren();
+ if (iter.hasNext()) {
+ iter.next();
+ }
+ iter.remove();
+
+ //this call must generate an exception
+ try {
+ iter.remove();
+ fail("calling remove twice without a call to next is prohibited");
+ } catch (IllegalStateException e) {
+ //ok if we come here :)
+ }
+
+ elt.close(false);
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove2.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove3.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove3.java?rev=1054434&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove3.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove3.java
Sun Jan 2 17:19:28 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 java.util.Iterator;
+
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.TestConstants;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/** Remove all! */
+public class TestGetChildrenRemove3 extends AxiomTestCase {
+ public TestGetChildrenRemove3(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMElement elt = AbstractTestCase.getTestResourceAsElement(metaFactory,
TestConstants.SOAP_SOAPMESSAGE1);
+ Iterator iter = elt.getChildren();
+ while (iter.hasNext()) {
+ iter.next();
+ iter.remove();
+ }
+ iter = elt.getChildren();
+ if (iter.hasNext()) {
+ //we shouldn't reach here!
+ fail("No children should remain after removing all!");
+ }
+
+ elt.close(false);
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove3.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove4.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove4.java?rev=1054434&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove4.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove4.java
Sun Jan 2 17:19:28 2011
@@ -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.element;
+
+import java.util.Iterator;
+
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.TestConstants;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/** test whether the children count reduces. */
+public class TestGetChildrenRemove4 extends AxiomTestCase {
+ public TestGetChildrenRemove4(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMElement elt = AbstractTestCase.getTestResourceAsElement(metaFactory,
TestConstants.SOAP_SOAPMESSAGE1);
+ Iterator iter = elt.getChildren();
+ int firstChildrenCount = 0;
+ int secondChildrenCount = 0;
+ while (iter.hasNext()) {
+ assertNotNull(iter.next());
+ firstChildrenCount++;
+ }
+
+ //remove the last node
+ iter.remove();
+
+ //reloop and check the count
+ //Note- here we should get a fresh iterator since there is no method to
+ //reset the iterator
+ iter = elt.getChildren(); //reset the iterator
+ while (iter.hasNext()) {
+ assertNotNull(iter.next());
+ secondChildrenCount++;
+ }
+ assertEquals("children count must reduce from 1",
+ firstChildrenCount - 1,
+ secondChildrenCount);
+
+ elt.close(false);
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenRemove4.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithLocalName.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithLocalName.java?rev=1054434&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithLocalName.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithLocalName.java
Sun Jan 2 17:19:28 2011
@@ -0,0 +1,47 @@
+/*
+ * 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.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.TestConstants;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestGetChildrenWithLocalName extends AxiomTestCase {
+ public TestGetChildrenWithLocalName(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMElement elt = AbstractTestCase.getTestResourceAsElement(metaFactory,
TestConstants.SOAP_SOAPMESSAGE1);
+ Iterator it =
elt.getChildrenWithLocalName(SOAP11Constants.BODY_LOCAL_NAME);
+ assertTrue(it.hasNext());
+ OMElement child = (OMElement)it.next();
+ assertEquals(new QName(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,
+ SOAP11Constants.BODY_LOCAL_NAME), child.getQName());
+ assertFalse(it.hasNext());
+ elt.close(false);
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithLocalName.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName.java?rev=1054434&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName.java
Sun Jan 2 17:19:28 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.element;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.TestConstants;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/** Test the element iterator */
+public class TestGetChildrenWithName extends AxiomTestCase {
+ public TestGetChildrenWithName(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMElement elt = AbstractTestCase.getTestResourceAsElement(metaFactory,
TestConstants.SOAP_SOAPMESSAGE1);
+ QName qname = new QName(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,
+ SOAP11Constants.BODY_LOCAL_NAME);
+ Iterator iter = elt.getChildrenWithName(qname);
+ int counter = 0;
+ while (iter.hasNext()) {
+ counter ++;
+ Object o = iter.next();
+ assertNotNull("Must return not null objects!", o);
+ assertTrue("All these should be elements!",
+ ((OMNode) o).getType() == OMNode.ELEMENT_NODE);
+ }
+ assertEquals("This element should contain only one element with the
given QName ", 1,
+ counter);
+ elt.close(false);
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName.java
------------------------------------------------------------------------------
svn:eol-style = native