You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2005/09/15 21:07:03 UTC
svn commit: r289289 [129/134] - in /webservices/axis2/trunk/java: ./ etc/
modules/addressing/ modules/addressing/src/META-INF/
modules/addressing/src/org/apache/axis2/handlers/addressing/
modules/addressing/test-resources/ modules/addressing/test/org/a...
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/BadInputTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/BadInputTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/BadInputTest.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/BadInputTest.java Thu Sep 15 11:52:11 2005
@@ -1,138 +1,138 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed 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.axis2.om;
-
-import org.apache.axis2.soap.SOAPEnvelope;
-
-import java.io.File;
-
-public class BadInputTest extends OMTestCase {
- File dir = new File(testResourceDir, "badsoap");
-
- public BadInputTest(String testName) {
- super(testName);
- }
-
-
- //done
- public void testEnvelopeMissing() throws Exception {
- try {
- SOAPEnvelope soapEnvelope =
- (SOAPEnvelope) OMTestUtils.getOMBuilder(
- new File(dir, "envelopeMissing.xml"))
- .getDocumentElement();
- OMTestUtils.walkThrough(soapEnvelope);
- fail("this must failed gracefully with OMException or AxisFault");
- } catch (OMException e) {
- return;
- }
-
- }
-
- //done
- public void testHeaderBodyWrongOrder() throws Exception {
- try {
- SOAPEnvelope soapEnvelope =
- (SOAPEnvelope) OMTestUtils.getOMBuilder(
- new File(dir, "haederBodyWrongOrder.xml"))
- .getDocumentElement();
- OMTestUtils.walkThrough(soapEnvelope);
- fail("this must failed gracefully with OMException or AxisFault");
- } catch (OMException e) {
- return;
- }
- }
-
- //done
- // public void testNotnamespaceQualified() throws Exception {
- // try {
- // SOAPEnvelope soapEnvelope =
- // (SOAPEnvelope) OMTestUtils.getOMBuilder(new File(dir, "notnamespaceQualified.xml")).getDocumentElement();
- // OMTestUtils.walkThrough(soapEnvelope);
- // fail("this must failed gracefully with OMException or AxisFault");
- // } catch (OMException e) {
- // return;
- // } catch (AxisFault e) {
- // return;
- // }
- //
- // }
- //done
- // public void testBodyNotQualified() throws Exception {
- // try {
- // SOAPEnvelope soapEnvelope =
- // (SOAPEnvelope) OMTestUtils.getOMBuilder(new File(dir, "bodyNotQualified.xml")).getDocumentElement();
- // OMTestUtils.walkThrough(soapEnvelope);
- // fail("this must failed gracefully with OMException or AxisFault");
- // } catch (OMException e) {
- // //we are OK!
- // return;
- // } catch (AxisFault e) {
- // //we are OK here too!
- // return;
- // }
- //
- // }
-
- //done
- public void testTwoBodymessage() throws Exception {
- try {
- SOAPEnvelope soapEnvelope =
- (SOAPEnvelope) OMTestUtils.getOMBuilder(
- new File(dir, "twoBodymessage.xml"))
- .getDocumentElement();
- OMTestUtils.walkThrough(soapEnvelope);
- fail("this must failed gracefully with OMException or AxisFault");
- } catch (OMException e) {
- return;
- }
-
- }
-
- //done
- public void testTwoheaders() throws Exception {
- try {
- SOAPEnvelope soapEnvelope =
- (SOAPEnvelope) OMTestUtils.getOMBuilder(
- new File(dir, "twoheaders.xml"))
- .getDocumentElement();
- OMTestUtils.walkThrough(soapEnvelope);
- fail("this must failed gracefully with OMException or AxisFault");
- } catch (OMException e) {
- return;
- }
-
- }
-
- //done
- public void testWrongSoapNs() throws Exception {
- try {
- SOAPEnvelope soapEnvelope =
- (SOAPEnvelope) OMTestUtils.getOMBuilder(
- new File(dir, "wrongSoapNs.xml"))
- .getDocumentElement();
- OMTestUtils.walkThrough(soapEnvelope);
- fail("this must failed gracefully with OMException or AxisFault");
- } catch (OMException e) {
- return;
- }
-
- }
-
-
-
-
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.om;
+
+import org.apache.axis2.soap.SOAPEnvelope;
+
+import java.io.File;
+
+public class BadInputTest extends OMTestCase {
+ File dir = new File(testResourceDir, "badsoap");
+
+ public BadInputTest(String testName) {
+ super(testName);
+ }
+
+
+ //done
+ public void testEnvelopeMissing() throws Exception {
+ try {
+ SOAPEnvelope soapEnvelope =
+ (SOAPEnvelope) OMTestUtils.getOMBuilder(
+ new File(dir, "envelopeMissing.xml"))
+ .getDocumentElement();
+ OMTestUtils.walkThrough(soapEnvelope);
+ fail("this must failed gracefully with OMException or AxisFault");
+ } catch (OMException e) {
+ return;
+ }
+
+ }
+
+ //done
+ public void testHeaderBodyWrongOrder() throws Exception {
+ try {
+ SOAPEnvelope soapEnvelope =
+ (SOAPEnvelope) OMTestUtils.getOMBuilder(
+ new File(dir, "haederBodyWrongOrder.xml"))
+ .getDocumentElement();
+ OMTestUtils.walkThrough(soapEnvelope);
+ fail("this must failed gracefully with OMException or AxisFault");
+ } catch (OMException e) {
+ return;
+ }
+ }
+
+ //done
+ // public void testNotnamespaceQualified() throws Exception {
+ // try {
+ // SOAPEnvelope soapEnvelope =
+ // (SOAPEnvelope) OMTestUtils.getOMBuilder(new File(dir, "notnamespaceQualified.xml")).getDocumentElement();
+ // OMTestUtils.walkThrough(soapEnvelope);
+ // fail("this must failed gracefully with OMException or AxisFault");
+ // } catch (OMException e) {
+ // return;
+ // } catch (AxisFault e) {
+ // return;
+ // }
+ //
+ // }
+ //done
+ // public void testBodyNotQualified() throws Exception {
+ // try {
+ // SOAPEnvelope soapEnvelope =
+ // (SOAPEnvelope) OMTestUtils.getOMBuilder(new File(dir, "bodyNotQualified.xml")).getDocumentElement();
+ // OMTestUtils.walkThrough(soapEnvelope);
+ // fail("this must failed gracefully with OMException or AxisFault");
+ // } catch (OMException e) {
+ // //we are OK!
+ // return;
+ // } catch (AxisFault e) {
+ // //we are OK here too!
+ // return;
+ // }
+ //
+ // }
+
+ //done
+ public void testTwoBodymessage() throws Exception {
+ try {
+ SOAPEnvelope soapEnvelope =
+ (SOAPEnvelope) OMTestUtils.getOMBuilder(
+ new File(dir, "twoBodymessage.xml"))
+ .getDocumentElement();
+ OMTestUtils.walkThrough(soapEnvelope);
+ fail("this must failed gracefully with OMException or AxisFault");
+ } catch (OMException e) {
+ return;
+ }
+
+ }
+
+ //done
+ public void testTwoheaders() throws Exception {
+ try {
+ SOAPEnvelope soapEnvelope =
+ (SOAPEnvelope) OMTestUtils.getOMBuilder(
+ new File(dir, "twoheaders.xml"))
+ .getDocumentElement();
+ OMTestUtils.walkThrough(soapEnvelope);
+ fail("this must failed gracefully with OMException or AxisFault");
+ } catch (OMException e) {
+ return;
+ }
+
+ }
+
+ //done
+ public void testWrongSoapNs() throws Exception {
+ try {
+ SOAPEnvelope soapEnvelope =
+ (SOAPEnvelope) OMTestUtils.getOMBuilder(
+ new File(dir, "wrongSoapNs.xml"))
+ .getDocumentElement();
+ OMTestUtils.walkThrough(soapEnvelope);
+ fail("this must failed gracefully with OMException or AxisFault");
+ } catch (OMException e) {
+ return;
+ }
+
+ }
+
+
+
+
+}
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/BadInputTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/CompareOMWithDOMTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/IteratorTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/IteratorTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/IteratorTest.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/IteratorTest.java Thu Sep 15 11:52:11 2005
@@ -1,185 +1,185 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed 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.axis2.om;
-
-import org.apache.axis2.soap.SOAPEnvelope;
-import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
-import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
-import org.apache.axis2.om.impl.llom.factory.OMLinkedListImplFactory;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.namespace.QName;
-import java.io.FileReader;
-import java.util.Iterator;
-
-public class IteratorTest extends AbstractTestCase {
- private OMElement envelope = null;
-
- public IteratorTest(String testName) {
- super(testName);
- }
-
- protected void setUp() throws Exception {
- //lets use a plain OM factory
- envelope =
- new StAXOMBuilder(new OMLinkedListImplFactory(),
- XMLInputFactory.newInstance().createXMLStreamReader(
- new FileReader(
- getTestResourceFile(
- "soap/soapmessage1.xml")))).getDocumentElement();
- }
-
- protected void tearDown() throws Exception {
- envelope = null;
- }
-
- /**
- * Test the plain iterator which includes all the
- * children (including the texts)
- */
- public void testIterator() {
- OMElement elt = envelope;
- 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);
- }
-
- /**
- * Test the element iterator
- */
- public void testElementIterator() {
- OMElement elt = envelope;
- 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);
- }
-
- /**
- * Test the element iterator
- */
- public void testElementQNameIterator() {
- OMElement elt = envelope;
- QName qname = new QName("http://schemas.xmlsoap.org/soap/envelope/","body");
- 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);
- }
-
- /**
- * test the remove exception behavior
- */
- public void testIteratorRemove1() {
- OMElement elt = envelope;
- 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
- }
-
- }
-
- /**
- * test the remove exception behavior, consecutive remove calls
- */
- public void testIteratorRemove2() {
- OMElement elt = envelope;
- 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 :)
- }
-
- }
-
- /**
- * Remove all!
- */
- public void testIteratorRemove3() {
- OMElement elt = envelope;
- 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!");
- }
-
-
- }
-
- /**
- * test whether the children count reduces.
- */
- public void testIteratorRemove4() {
- OMElement elt = envelope;
- 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);
-
- }
-
-
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.om;
+
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.axis2.om.impl.llom.factory.OMLinkedListImplFactory;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.namespace.QName;
+import java.io.FileReader;
+import java.util.Iterator;
+
+public class IteratorTest extends AbstractTestCase {
+ private OMElement envelope = null;
+
+ public IteratorTest(String testName) {
+ super(testName);
+ }
+
+ protected void setUp() throws Exception {
+ //lets use a plain OM factory
+ envelope =
+ new StAXOMBuilder(new OMLinkedListImplFactory(),
+ XMLInputFactory.newInstance().createXMLStreamReader(
+ new FileReader(
+ getTestResourceFile(
+ "soap/soapmessage1.xml")))).getDocumentElement();
+ }
+
+ protected void tearDown() throws Exception {
+ envelope = null;
+ }
+
+ /**
+ * Test the plain iterator which includes all the
+ * children (including the texts)
+ */
+ public void testIterator() {
+ OMElement elt = envelope;
+ 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);
+ }
+
+ /**
+ * Test the element iterator
+ */
+ public void testElementIterator() {
+ OMElement elt = envelope;
+ 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);
+ }
+
+ /**
+ * Test the element iterator
+ */
+ public void testElementQNameIterator() {
+ OMElement elt = envelope;
+ QName qname = new QName("http://schemas.xmlsoap.org/soap/envelope/","body");
+ 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);
+ }
+
+ /**
+ * test the remove exception behavior
+ */
+ public void testIteratorRemove1() {
+ OMElement elt = envelope;
+ 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
+ }
+
+ }
+
+ /**
+ * test the remove exception behavior, consecutive remove calls
+ */
+ public void testIteratorRemove2() {
+ OMElement elt = envelope;
+ 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 :)
+ }
+
+ }
+
+ /**
+ * Remove all!
+ */
+ public void testIteratorRemove3() {
+ OMElement elt = envelope;
+ 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!");
+ }
+
+
+ }
+
+ /**
+ * test whether the children count reduces.
+ */
+ public void testIteratorRemove4() {
+ OMElement elt = envelope;
+ 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);
+
+ }
+
+
+}
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/IteratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/MIMEOutputUtilsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/MessagesTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/MessagesTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/MessagesTest.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/MessagesTest.java Thu Sep 15 11:52:11 2005
@@ -1,61 +1,61 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed 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.axis2.om;
-
-import org.apache.axis2.soap.SOAPEnvelope;
-
-public class MessagesTest extends OMTestCase {
- SOAPEnvelope soapEnvelope;
-
- public MessagesTest(String testName) {
- super(testName);
- }
-
- public void testMessageWithLotOfWhiteSpaces() throws OMException,
- Exception {
- soapEnvelope =
- (SOAPEnvelope) OMTestUtils.getOMBuilder(
- getTestResourceFile("soap/whitespacedMessage.xml"))
- .getDocumentElement();
- OMTestUtils.walkThrough(soapEnvelope);
- }
-
- public void testMinimalMessage() throws OMException, Exception {
- soapEnvelope =
- (SOAPEnvelope) OMTestUtils.getOMBuilder(
- getTestResourceFile("soap/minimalMessage.xml"))
- .getDocumentElement();
- OMTestUtils.walkThrough(soapEnvelope);
- }
-
- public void testReallyBigMessage() throws OMException, Exception {
- soapEnvelope =
- (SOAPEnvelope) OMTestUtils.getOMBuilder(
- getTestResourceFile("soap/reallyReallyBigMessage.xml"))
- .getDocumentElement();
- OMTestUtils.walkThrough(soapEnvelope);
- }
-
- public void testEmptyBodiedMessage() throws OMException, Exception {
- soapEnvelope =
- (SOAPEnvelope) OMTestUtils.getOMBuilder(
- getTestResourceFile("soap/emtyBodymessage.xml"))
- .getDocumentElement();
- OMTestUtils.walkThrough(soapEnvelope);
- }
-
-
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.om;
+
+import org.apache.axis2.soap.SOAPEnvelope;
+
+public class MessagesTest extends OMTestCase {
+ SOAPEnvelope soapEnvelope;
+
+ public MessagesTest(String testName) {
+ super(testName);
+ }
+
+ public void testMessageWithLotOfWhiteSpaces() throws OMException,
+ Exception {
+ soapEnvelope =
+ (SOAPEnvelope) OMTestUtils.getOMBuilder(
+ getTestResourceFile("soap/whitespacedMessage.xml"))
+ .getDocumentElement();
+ OMTestUtils.walkThrough(soapEnvelope);
+ }
+
+ public void testMinimalMessage() throws OMException, Exception {
+ soapEnvelope =
+ (SOAPEnvelope) OMTestUtils.getOMBuilder(
+ getTestResourceFile("soap/minimalMessage.xml"))
+ .getDocumentElement();
+ OMTestUtils.walkThrough(soapEnvelope);
+ }
+
+ public void testReallyBigMessage() throws OMException, Exception {
+ soapEnvelope =
+ (SOAPEnvelope) OMTestUtils.getOMBuilder(
+ getTestResourceFile("soap/reallyReallyBigMessage.xml"))
+ .getDocumentElement();
+ OMTestUtils.walkThrough(soapEnvelope);
+ }
+
+ public void testEmptyBodiedMessage() throws OMException, Exception {
+ soapEnvelope =
+ (SOAPEnvelope) OMTestUtils.getOMBuilder(
+ getTestResourceFile("soap/emtyBodymessage.xml"))
+ .getDocumentElement();
+ OMTestUtils.walkThrough(soapEnvelope);
+ }
+
+
+}
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/MessagesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMBlankElementTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMBlankElementTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMBlankElementTest.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMBlankElementTest.java Thu Sep 15 11:52:11 2005
@@ -1,62 +1,62 @@
-package org.apache.axis2.om;
-
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed 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.
- *
- * author : Eran Chinthaka (chinthaka@apache.org)
- */
-
-import junit.framework.TestCase;
-import org.apache.axis2.om.impl.OMOutputImpl;
-
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import java.io.StringWriter;
-
-
-public class OMBlankElementTest extends TestCase {
-
-
- public OMBlankElementTest(String name) {
- super(name);
- }
-
- public void testBlankOMElem() {
- try {
- //We should not get anything as the return value here: the output of the serialization
- String value = buildBlankOMElem();
-// System.out.println(value);
- assertNull("There's a serialized output for a blank XML element that cannot exist", value);
- } catch (Exception e) {
- //An exception is thrown trying to serialize a blank element
- assertTrue(true);
- }
- }
-
-
-
- String buildBlankOMElem() throws XMLStreamException {
- OMFactory factory = OMAbstractFactory.getOMFactory();
- OMNamespace namespace1 = factory.createOMNamespace("","");
- OMElement elem1 = factory.createOMElement("",namespace1);
-
- StringWriter writer = new StringWriter();
- elem1.build();
- elem1.serializeWithCache(new OMOutputImpl(XMLOutputFactory
- .newInstance().createXMLStreamWriter(writer)));
- writer.flush();
- return writer.toString();
- }
-}
+package org.apache.axis2.om;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+import junit.framework.TestCase;
+import org.apache.axis2.om.impl.OMOutputImpl;
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import java.io.StringWriter;
+
+
+public class OMBlankElementTest extends TestCase {
+
+
+ public OMBlankElementTest(String name) {
+ super(name);
+ }
+
+ public void testBlankOMElem() {
+ try {
+ //We should not get anything as the return value here: the output of the serialization
+ String value = buildBlankOMElem();
+// System.out.println(value);
+ assertNull("There's a serialized output for a blank XML element that cannot exist", value);
+ } catch (Exception e) {
+ //An exception is thrown trying to serialize a blank element
+ assertTrue(true);
+ }
+ }
+
+
+
+ String buildBlankOMElem() throws XMLStreamException {
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace1 = factory.createOMNamespace("","");
+ OMElement elem1 = factory.createOMElement("",namespace1);
+
+ StringWriter writer = new StringWriter();
+ elem1.build();
+ elem1.serializeWithCache(new OMOutputImpl(XMLOutputFactory
+ .newInstance().createXMLStreamWriter(writer)));
+ writer.flush();
+ return writer.toString();
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMBlankElementTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMBodyTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMBodyTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMBodyTest.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMBodyTest.java Thu Sep 15 11:52:11 2005
@@ -1,61 +1,61 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed 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.axis2.om;
-
-import org.apache.axis2.soap.SOAPBody;
-import org.apache.axis2.soap.impl.llom.SOAPProcessingException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class OMBodyTest extends OMTestCase implements OMConstants {
- SOAPBody soapBody;
- private Log log = LogFactory.getLog(getClass());
-
- public OMBodyTest(String testName) {
- super(testName);
- }
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- soapBody = soapEnvelope.getBody();
- }
-
- /*
- * Class under test for SOAPFault addFault()
- */
- public void testAddFault() {
- log.info("Adding SOAP fault to body ....");
- try {
- soapBody.addChild(
- soapFactory.createSOAPFault(soapBody,
- new Exception("Testing soap fault")));
- } catch (SOAPProcessingException e) {
- log.info(e.getMessage());
- fail(e.getMessage());
- }
- log.info("\t checking for SOAP Fault ...");
- assertTrue("SOAP body has no SOAP fault", soapBody.hasFault());
- log.info("\t checking for not-nullity ...");
- assertTrue("SOAP body has no SOAP fault", soapBody.getFault() != null);
-
- //SimpleOMSerializer simpleOMSerializer = new SimpleOMSerializer();
- //simpleOMSerializer.serializeWithCache(soapBody, System.out);
- }
-
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.om;
+
+import org.apache.axis2.soap.SOAPBody;
+import org.apache.axis2.soap.impl.llom.SOAPProcessingException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class OMBodyTest extends OMTestCase implements OMConstants {
+ SOAPBody soapBody;
+ private Log log = LogFactory.getLog(getClass());
+
+ public OMBodyTest(String testName) {
+ super(testName);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ soapBody = soapEnvelope.getBody();
+ }
+
+ /*
+ * Class under test for SOAPFault addFault()
+ */
+ public void testAddFault() {
+ log.info("Adding SOAP fault to body ....");
+ try {
+ soapBody.addChild(
+ soapFactory.createSOAPFault(soapBody,
+ new Exception("Testing soap fault")));
+ } catch (SOAPProcessingException e) {
+ log.info(e.getMessage());
+ fail(e.getMessage());
+ }
+ log.info("\t checking for SOAP Fault ...");
+ assertTrue("SOAP body has no SOAP fault", soapBody.hasFault());
+ log.info("\t checking for not-nullity ...");
+ assertTrue("SOAP body has no SOAP fault", soapBody.getFault() != null);
+
+ //SimpleOMSerializer simpleOMSerializer = new SimpleOMSerializer();
+ //simpleOMSerializer.serializeWithCache(soapBody, System.out);
+ }
+
+}
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMBodyTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMDocumentTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMDocumentTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMDocumentTest.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMDocumentTest.java Thu Sep 15 11:52:11 2005
@@ -1,101 +1,101 @@
-package org.apache.axis2.om;
-
-import junit.framework.TestCase;
-import org.apache.axis2.om.impl.OMOutputImpl;
-import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayOutputStream;
-import java.io.StringReader;
-import java.util.Iterator;
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed 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.
- *
- * @author : Eran Chinthaka (chinthaka@apache.org)
- */
-
-public class OMDocumentTest extends TestCase {
- private String sampleXML = "<?xml version='1.0' encoding='utf-8'?>" +
- "<!--This is some comments at the start of the document-->" +
- "<?PITarget PIData?>" +
- "<Axis2>" +
- " <ProjectName>The Apache Web Sevices Project</ProjectName>" +
- "</Axis2>";
-
- public void testOMDocument() throws XMLStreamException {
- // read the string in to the builder
- OMDocument omDocument = getSampleOMDocument(sampleXML);
-
- // serialise it to a string
- String outXML = "";
- ByteArrayOutputStream outStream = new ByteArrayOutputStream();
- OMOutputImpl output = new OMOutputImpl(outStream, false);
- omDocument.serialize(output);
- output.flush();
- outXML = new String(outStream.toByteArray());
- System.out.println("outXML = " + outXML);
-
- // again load that to another builder
- OMDocument secondDocument = getSampleOMDocument(outXML);
-
- // check for the comment and the PI
- boolean commentFound = false;
- boolean piFound = false;
- Iterator children = secondDocument.getChildren();
- while (children.hasNext()) {
- OMNode omNode = (OMNode) children.next();
- if (omNode instanceof OMComment) {
- commentFound = true;
- } else if (omNode instanceof OMProcessingInstruction) {
- piFound = true;
- } else if (omNode instanceof OMElement && !commentFound && !piFound) {
- fail("OMElement should come after Comment and PI");
-
- }
- }
- assertTrue(commentFound && piFound);
-
-
- }
-
- private OMDocument getSampleOMDocument(String xml) {
- try {
- XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml));
- StAXOMBuilder builder = new StAXOMBuilder(xmlStreamReader);
- return builder.getDocument();
- } catch (XMLStreamException e) {
- throw new UnsupportedOperationException();
- }
- }
-
-// private OMDocument getSampleOMDocument() {
-// OMFactory omFactory = OMAbstractFactory.getOMFactory();
-// OMDocument omDocument = omFactory.createOMDocument();
-// omFactory.createOMComment(omDocument, "This is some comments at the start of the document");
-// omDocument.setCharsetEncoding("utf-8");
-// omFactory.createOMProcessingInstruction(omDocument, "PITarget", "PIData");
-//
-// OMElement documentElement = omFactory.createOMElement("Axis2", null, omDocument);
-// omDocument.setDocumentElement(documentElement);
-// omFactory.createOMElement("ProjectName", null, documentElement);
-// documentElement.getFirstElement().setText("The Apache Web Sevices Project");
-//
-// return omDocument;
-// }
-
-}
+package org.apache.axis2.om;
+
+import junit.framework.TestCase;
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+import java.util.Iterator;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * @author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public class OMDocumentTest extends TestCase {
+ private String sampleXML = "<?xml version='1.0' encoding='utf-8'?>" +
+ "<!--This is some comments at the start of the document-->" +
+ "<?PITarget PIData?>" +
+ "<Axis2>" +
+ " <ProjectName>The Apache Web Sevices Project</ProjectName>" +
+ "</Axis2>";
+
+ public void testOMDocument() throws XMLStreamException {
+ // read the string in to the builder
+ OMDocument omDocument = getSampleOMDocument(sampleXML);
+
+ // serialise it to a string
+ String outXML = "";
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ OMOutputImpl output = new OMOutputImpl(outStream, false);
+ omDocument.serialize(output);
+ output.flush();
+ outXML = new String(outStream.toByteArray());
+ System.out.println("outXML = " + outXML);
+
+ // again load that to another builder
+ OMDocument secondDocument = getSampleOMDocument(outXML);
+
+ // check for the comment and the PI
+ boolean commentFound = false;
+ boolean piFound = false;
+ Iterator children = secondDocument.getChildren();
+ while (children.hasNext()) {
+ OMNode omNode = (OMNode) children.next();
+ if (omNode instanceof OMComment) {
+ commentFound = true;
+ } else if (omNode instanceof OMProcessingInstruction) {
+ piFound = true;
+ } else if (omNode instanceof OMElement && !commentFound && !piFound) {
+ fail("OMElement should come after Comment and PI");
+
+ }
+ }
+ assertTrue(commentFound && piFound);
+
+
+ }
+
+ private OMDocument getSampleOMDocument(String xml) {
+ try {
+ XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml));
+ StAXOMBuilder builder = new StAXOMBuilder(xmlStreamReader);
+ return builder.getDocument();
+ } catch (XMLStreamException e) {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+// private OMDocument getSampleOMDocument() {
+// OMFactory omFactory = OMAbstractFactory.getOMFactory();
+// OMDocument omDocument = omFactory.createOMDocument();
+// omFactory.createOMComment(omDocument, "This is some comments at the start of the document");
+// omDocument.setCharsetEncoding("utf-8");
+// omFactory.createOMProcessingInstruction(omDocument, "PITarget", "PIData");
+//
+// OMElement documentElement = omFactory.createOMElement("Axis2", null, omDocument);
+// omDocument.setDocumentElement(documentElement);
+// omFactory.createOMElement("ProjectName", null, documentElement);
+// documentElement.getFirstElement().setText("The Apache Web Sevices Project");
+//
+// return omDocument;
+// }
+
+}
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMDocumentTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMNavigatorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMTestCase.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMTestCase.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMTestCase.java Thu Sep 15 11:52:11 2005
@@ -1,69 +1,69 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed 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.axis2.om;
-
-import org.apache.axis2.soap.SOAPEnvelope;
-import org.apache.axis2.soap.SOAPFactory;
-import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
-
-import javax.xml.stream.*;
-import java.io.FileReader;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public abstract class OMTestCase extends AbstractTestCase {
- protected static final String IN_FILE_NAME = "soap/soapmessage.xml";
- protected StAXSOAPModelBuilder builder;
- protected OMFactory ombuilderFactory;
- protected SOAPFactory soapFactory;
-
- protected SOAPEnvelope soapEnvelope;
-
- public OMTestCase(String testName) {
- super(testName);
- ombuilderFactory = OMAbstractFactory.getOMFactory();
- soapFactory = OMAbstractFactory.getSOAP11Factory();
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- soapEnvelope = (SOAPEnvelope) getOMBuilder("").getDocumentElement();
- }
-
- protected StAXSOAPModelBuilder getOMBuilder(String fileName) throws Exception {
- if ("".equals(fileName) || fileName == null) {
- fileName = IN_FILE_NAME;
- }
- XMLStreamReader parser = XMLInputFactory.newInstance()
- .createXMLStreamReader(
- new FileReader(getTestResourceFile(fileName)));
- builder = new StAXSOAPModelBuilder(parser, null);
- return builder;
- }
-
- protected StAXSOAPModelBuilder getOMBuilder(InputStream in) throws Exception {
- XMLStreamReader parser = XMLInputFactory.newInstance()
- .createXMLStreamReader(in);
- builder = new StAXSOAPModelBuilder(parser, null);
- return builder;
- }
-
- protected XMLStreamWriter getStAXStreamWriter(OutputStream out) throws XMLStreamException {
- return XMLOutputFactory.newInstance().createXMLStreamWriter(out);
- }
-
-
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.om;
+
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.SOAPFactory;
+import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
+
+import javax.xml.stream.*;
+import java.io.FileReader;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public abstract class OMTestCase extends AbstractTestCase {
+ protected static final String IN_FILE_NAME = "soap/soapmessage.xml";
+ protected StAXSOAPModelBuilder builder;
+ protected OMFactory ombuilderFactory;
+ protected SOAPFactory soapFactory;
+
+ protected SOAPEnvelope soapEnvelope;
+
+ public OMTestCase(String testName) {
+ super(testName);
+ ombuilderFactory = OMAbstractFactory.getOMFactory();
+ soapFactory = OMAbstractFactory.getSOAP11Factory();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ soapEnvelope = (SOAPEnvelope) getOMBuilder("").getDocumentElement();
+ }
+
+ protected StAXSOAPModelBuilder getOMBuilder(String fileName) throws Exception {
+ if ("".equals(fileName) || fileName == null) {
+ fileName = IN_FILE_NAME;
+ }
+ XMLStreamReader parser = XMLInputFactory.newInstance()
+ .createXMLStreamReader(
+ new FileReader(getTestResourceFile(fileName)));
+ builder = new StAXSOAPModelBuilder(parser, null);
+ return builder;
+ }
+
+ protected StAXSOAPModelBuilder getOMBuilder(InputStream in) throws Exception {
+ XMLStreamReader parser = XMLInputFactory.newInstance()
+ .createXMLStreamReader(in);
+ builder = new StAXSOAPModelBuilder(parser, null);
+ return builder;
+ }
+
+ protected XMLStreamWriter getStAXStreamWriter(OutputStream out) throws XMLStreamException {
+ return XMLOutputFactory.newInstance().createXMLStreamWriter(out);
+ }
+
+
+}
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMTestUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMTestUtils.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMTestUtils.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMTestUtils.java Thu Sep 15 11:52:11 2005
@@ -1,118 +1,118 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed 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.axis2.om;
-
-import junit.framework.TestCase;
-import org.apache.axis2.om.impl.llom.factory.OMXMLBuilderFactory;
-import org.apache.axis2.soap.SOAPEnvelope;
-import org.w3c.dom.*;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-import java.io.File;
-import java.io.FileReader;
-import java.util.Iterator;
-
-public class OMTestUtils {
- public static OMXMLParserWrapper getOMBuilder(File file) throws Exception {
- XMLStreamReader parser = XMLInputFactory.newInstance()
- .createXMLStreamReader(new FileReader(file));
- return OMXMLBuilderFactory.createStAXSOAPModelBuilder(
- OMAbstractFactory.getSOAP11Factory(), parser);
- }
-
- public static void walkThrough(OMElement omEle) {
- Iterator attibIt = omEle.getAttributes();
- if (attibIt != null) {
- while (attibIt.hasNext()) {
- TestCase.assertNotNull("once the has next is not null, the " +
- "element should not be null",
- attibIt.next());
- }
- }
- Iterator it = omEle.getChildren();
- if (it != null) {
- while (it.hasNext()) {
- OMNode ele = (OMNode) it.next();
- TestCase.assertNotNull("once the has next is not null, the " +
- "element should not be null", ele);
- if (ele instanceof OMElement) {
- walkThrough((OMElement) ele);
- }
- }
- }
- }
-
- public static void compare(Element ele, OMElement omele) throws Exception {
- if (ele == null && omele == null) {
- return;
- } else if (ele != null && omele != null) {
- TestCase.assertEquals("Element name not correct",
- ele.getLocalName(),
- omele.getLocalName());
- if (omele.getNamespace() != null) {
- TestCase.assertEquals("Namespace URI not correct",
- ele.getNamespaceURI(),
- omele.getNamespace().getName());
-
- }
-
- //go through the attributes
- NamedNodeMap map = ele.getAttributes();
- Iterator attIterator = omele.getAttributes();
- OMAttribute omattribute;
- Attr domAttribute;
- String DOMAttrName;
- while (attIterator != null && attIterator.hasNext() && map == null) {
- omattribute = (OMAttribute) attIterator.next();
- Node node = map.getNamedItemNS(
- omattribute.getNamespace().getName(),
- omattribute.getLocalName());
- if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- Attr attr = (Attr) node;
- TestCase.assertEquals(attr.getValue(),
- omattribute.getValue());
- } else {
- throw new OMException("return type is not a Attribute");
- }
-
- }
- Iterator it = omele.getChildren();
- NodeList list = ele.getChildNodes();
- for (int i = 0; i < list.getLength(); i++) {
- Node node = list.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- TestCase.assertTrue(it.hasNext());
- OMNode tempOmNode = (OMNode) it.next();
- while (tempOmNode.getType() != OMNode.ELEMENT_NODE) {
- TestCase.assertTrue(it.hasNext());
- tempOmNode = (OMNode) it.next();
- }
- compare((Element) node, (OMElement) tempOmNode);
- }
- }
-
-
- } else {
- throw new Exception("One is null");
- }
- }
-
- public static SOAPEnvelope createOM(File file) throws Exception {
- return (SOAPEnvelope) getOMBuilder(file).getDocumentElement();
- }
-
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.om;
+
+import junit.framework.TestCase;
+import org.apache.axis2.om.impl.llom.factory.OMXMLBuilderFactory;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.w3c.dom.*;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.Iterator;
+
+public class OMTestUtils {
+ public static OMXMLParserWrapper getOMBuilder(File file) throws Exception {
+ XMLStreamReader parser = XMLInputFactory.newInstance()
+ .createXMLStreamReader(new FileReader(file));
+ return OMXMLBuilderFactory.createStAXSOAPModelBuilder(
+ OMAbstractFactory.getSOAP11Factory(), parser);
+ }
+
+ public static void walkThrough(OMElement omEle) {
+ Iterator attibIt = omEle.getAttributes();
+ if (attibIt != null) {
+ while (attibIt.hasNext()) {
+ TestCase.assertNotNull("once the has next is not null, the " +
+ "element should not be null",
+ attibIt.next());
+ }
+ }
+ Iterator it = omEle.getChildren();
+ if (it != null) {
+ while (it.hasNext()) {
+ OMNode ele = (OMNode) it.next();
+ TestCase.assertNotNull("once the has next is not null, the " +
+ "element should not be null", ele);
+ if (ele instanceof OMElement) {
+ walkThrough((OMElement) ele);
+ }
+ }
+ }
+ }
+
+ public static void compare(Element ele, OMElement omele) throws Exception {
+ if (ele == null && omele == null) {
+ return;
+ } else if (ele != null && omele != null) {
+ TestCase.assertEquals("Element name not correct",
+ ele.getLocalName(),
+ omele.getLocalName());
+ if (omele.getNamespace() != null) {
+ TestCase.assertEquals("Namespace URI not correct",
+ ele.getNamespaceURI(),
+ omele.getNamespace().getName());
+
+ }
+
+ //go through the attributes
+ NamedNodeMap map = ele.getAttributes();
+ Iterator attIterator = omele.getAttributes();
+ OMAttribute omattribute;
+ Attr domAttribute;
+ String DOMAttrName;
+ while (attIterator != null && attIterator.hasNext() && map == null) {
+ omattribute = (OMAttribute) attIterator.next();
+ Node node = map.getNamedItemNS(
+ omattribute.getNamespace().getName(),
+ omattribute.getLocalName());
+ if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
+ Attr attr = (Attr) node;
+ TestCase.assertEquals(attr.getValue(),
+ omattribute.getValue());
+ } else {
+ throw new OMException("return type is not a Attribute");
+ }
+
+ }
+ Iterator it = omele.getChildren();
+ NodeList list = ele.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++) {
+ Node node = list.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ TestCase.assertTrue(it.hasNext());
+ OMNode tempOmNode = (OMNode) it.next();
+ while (tempOmNode.getType() != OMNode.ELEMENT_NODE) {
+ TestCase.assertTrue(it.hasNext());
+ tempOmNode = (OMNode) it.next();
+ }
+ compare((Element) node, (OMElement) tempOmNode);
+ }
+ }
+
+
+ } else {
+ throw new Exception("One is null");
+ }
+ }
+
+ public static SOAPEnvelope createOM(File file) throws Exception {
+ return (SOAPEnvelope) getOMBuilder(file).getDocumentElement();
+ }
+
+}
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/OMTestUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/SpacesTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/SpacesTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/SpacesTest.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/SpacesTest.java Thu Sep 15 11:52:11 2005
@@ -1,107 +1,107 @@
-package org.apache.axis2.om;
-
-import org.apache.axis2.om.impl.OMOutputImpl;
-import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
-import org.apache.axis2.om.impl.llom.factory.OMXMLBuilderFactory;
-import org.custommonkey.xmlunit.Diff;
-import org.custommonkey.xmlunit.XMLTestCase;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import java.io.*;
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed 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.
- *
- * @author : Eran Chinthaka (chinthaka@apache.org)
- */
-
-public class SpacesTest extends XMLTestCase {
- private String filePath = "test-resources/xml/spaces.xml";
-
-
- private OMElement rootElement;
-
- protected void setUp() throws Exception {
- }
-
- public void testCData() throws Exception {
- checkOMConformance(new FileInputStream(filePath));
- }
-
- private void checkOMConformance(InputStream iStream) throws Exception {
- try {
- XMLInputFactory factory = XMLInputFactory.newInstance();
-
- StAXOMBuilder staxOMBuilder = OMXMLBuilderFactory.
- createStAXOMBuilder(OMAbstractFactory.getOMFactory(),
- factory.createXMLStreamReader(
- iStream));
- staxOMBuilder.setDoDebug(true);
- rootElement = staxOMBuilder.getDocumentElement();
-
- XMLStreamWriter writer;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- writer = XMLOutputFactory.newInstance().
- createXMLStreamWriter(baos);
-
- ((OMDocument) rootElement.getParent()).serializeWithCache(new OMOutputImpl(writer));
-
- writer.flush();
- writer.close();
-
- System.out.println("XML = " + new String(baos.toByteArray()));
-
- InputSource resultXML = new InputSource(new InputStreamReader(
- new ByteArrayInputStream(baos.toByteArray())));
-
- Document dom1 = newDocument(new InputSource(new FileInputStream(filePath)));
- Document dom2 = newDocument(resultXML);
-
- Diff diff = compareXML(dom1, dom2);
- assertXMLEqual(diff, true);
- } catch (XMLStreamException e) {
- fail(e.getMessage());
- throw new Exception(e);
- } catch (ParserConfigurationException e) {
- fail(e.getMessage());
- throw new Exception(e);
- } catch (SAXException e) {
- fail(e.getMessage());
- throw new Exception(e);
- } catch (IOException e) {
- fail(e.getMessage());
- throw new Exception(e);
- }
- }
-
- public Document newDocument(InputSource in)
- throws ParserConfigurationException, SAXException, IOException {
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- dbf.setNamespaceAware(true);
- DocumentBuilder db = dbf.newDocumentBuilder();
- return db.parse(in);
- }
-
-
-}
+package org.apache.axis2.om;
+
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.axis2.om.impl.llom.factory.OMXMLBuilderFactory;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.XMLTestCase;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.io.*;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * @author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public class SpacesTest extends XMLTestCase {
+ private String filePath = "test-resources/xml/spaces.xml";
+
+
+ private OMElement rootElement;
+
+ protected void setUp() throws Exception {
+ }
+
+ public void testCData() throws Exception {
+ checkOMConformance(new FileInputStream(filePath));
+ }
+
+ private void checkOMConformance(InputStream iStream) throws Exception {
+ try {
+ XMLInputFactory factory = XMLInputFactory.newInstance();
+
+ StAXOMBuilder staxOMBuilder = OMXMLBuilderFactory.
+ createStAXOMBuilder(OMAbstractFactory.getOMFactory(),
+ factory.createXMLStreamReader(
+ iStream));
+ staxOMBuilder.setDoDebug(true);
+ rootElement = staxOMBuilder.getDocumentElement();
+
+ XMLStreamWriter writer;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ writer = XMLOutputFactory.newInstance().
+ createXMLStreamWriter(baos);
+
+ ((OMDocument) rootElement.getParent()).serializeWithCache(new OMOutputImpl(writer));
+
+ writer.flush();
+ writer.close();
+
+ System.out.println("XML = " + new String(baos.toByteArray()));
+
+ InputSource resultXML = new InputSource(new InputStreamReader(
+ new ByteArrayInputStream(baos.toByteArray())));
+
+ Document dom1 = newDocument(new InputSource(new FileInputStream(filePath)));
+ Document dom2 = newDocument(resultXML);
+
+ Diff diff = compareXML(dom1, dom2);
+ assertXMLEqual(diff, true);
+ } catch (XMLStreamException e) {
+ fail(e.getMessage());
+ throw new Exception(e);
+ } catch (ParserConfigurationException e) {
+ fail(e.getMessage());
+ throw new Exception(e);
+ } catch (SAXException e) {
+ fail(e.getMessage());
+ throw new Exception(e);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ throw new Exception(e);
+ }
+ }
+
+ public Document newDocument(InputSource in)
+ throws ParserConfigurationException, SAXException, IOException {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ return db.parse(in);
+ }
+
+
+}
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/SpacesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/StaxParserTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/StaxParserTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/StaxParserTest.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/StaxParserTest.java Thu Sep 15 11:52:11 2005
@@ -1,117 +1,117 @@
-package org.apache.axis2.om;
-
-import org.apache.axis2.om.impl.llom.factory.OMXMLBuilderFactory;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
-
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed 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.
-*
-* Aim of this test is to check the compatibilty of the stax parser implementation
-*/
-
-public class StaxParserTest extends AbstractTestCase {
-
- XMLStreamReader parser1;
- XMLStreamReader parser2;
- XMLStreamReader parser3;
- String xmlDocument = "<purchase-order xmlns=\"http://openuri.org/easypo\">" +
- "<customer>" +
- " <name>Gladys Kravitz</name>" +
- " <address>Anytown, PA</address>" +
- " </customer>" +
- " <date>2005-03-06T14:06:12.697+06:00</date>" +
- "</purchase-order>";
-
- public StaxParserTest(String testName) {
- super(testName);
- }
-
- protected void setUp() throws Exception {
- //make the parsers
- parser1 =
- XMLInputFactory.newInstance().createXMLStreamReader(
- new ByteArrayInputStream(xmlDocument.getBytes()));
-
- OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(
- OMAbstractFactory.getSOAP11Factory(),
- XMLInputFactory.newInstance().createXMLStreamReader(
- new ByteArrayInputStream(xmlDocument.getBytes())));
- parser2 = builder.getDocumentElement().getXMLStreamReader();
-
- OMXMLParserWrapper builder2 = OMXMLBuilderFactory.createStAXOMBuilder(
- OMAbstractFactory.getSOAP11Factory(),
- XMLInputFactory.newInstance().createXMLStreamReader(
- new ByteArrayInputStream(xmlDocument.getBytes())));
- parser3 =
- builder2.getDocumentElement().getXMLStreamReaderWithoutCaching();
-
- }
-
- public void testParserEventsWithCache() throws Exception {
-
- assertEquals(parser1.getEventType(), parser2.getEventType());
-
- while (parser1.hasNext()) {
-
- int parser1Event = parser1.next();
- int parser2Event = parser2.next();
- assertEquals(parser1Event, parser2Event);
-
- }
-
-
- }
-
- public void testParserEventsWithoutCache() throws Exception {
-
- assertEquals(parser1.getEventType(), parser3.getEventType());
-
- while (parser1.hasNext()) {
- int parser1Event = parser1.next();
- int parser2Event = parser3.next();
- assertEquals(parser1Event, parser2Event);
- }
-
-
- }
-
- public void testParserEvents2WithCache() throws Exception {
- while (parser1.hasNext()) {
- int parser1Event = parser1.getEventType();
- int parser2Event = parser2.getEventType();
- parser1.next();
- parser2.next();
- assertEquals(parser1Event, parser2Event);
- }
-
-
- }
-}
-
-// public void testParserEvents2() throws Exception{
-//
-// System.out.println("parser2 initial = " + parser2.getEventType());
-// while(parser2.hasNext()){
-// System.out.println(" event "+ parser2.next() + parser2.getLocalName());
-// }
-
-
-//}
-
-
-
+package org.apache.axis2.om;
+
+import org.apache.axis2.om.impl.llom.factory.OMXMLBuilderFactory;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayInputStream;
+
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed 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.
+*
+* Aim of this test is to check the compatibilty of the stax parser implementation
+*/
+
+public class StaxParserTest extends AbstractTestCase {
+
+ XMLStreamReader parser1;
+ XMLStreamReader parser2;
+ XMLStreamReader parser3;
+ String xmlDocument = "<purchase-order xmlns=\"http://openuri.org/easypo\">" +
+ "<customer>" +
+ " <name>Gladys Kravitz</name>" +
+ " <address>Anytown, PA</address>" +
+ " </customer>" +
+ " <date>2005-03-06T14:06:12.697+06:00</date>" +
+ "</purchase-order>";
+
+ public StaxParserTest(String testName) {
+ super(testName);
+ }
+
+ protected void setUp() throws Exception {
+ //make the parsers
+ parser1 =
+ XMLInputFactory.newInstance().createXMLStreamReader(
+ new ByteArrayInputStream(xmlDocument.getBytes()));
+
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(
+ OMAbstractFactory.getSOAP11Factory(),
+ XMLInputFactory.newInstance().createXMLStreamReader(
+ new ByteArrayInputStream(xmlDocument.getBytes())));
+ parser2 = builder.getDocumentElement().getXMLStreamReader();
+
+ OMXMLParserWrapper builder2 = OMXMLBuilderFactory.createStAXOMBuilder(
+ OMAbstractFactory.getSOAP11Factory(),
+ XMLInputFactory.newInstance().createXMLStreamReader(
+ new ByteArrayInputStream(xmlDocument.getBytes())));
+ parser3 =
+ builder2.getDocumentElement().getXMLStreamReaderWithoutCaching();
+
+ }
+
+ public void testParserEventsWithCache() throws Exception {
+
+ assertEquals(parser1.getEventType(), parser2.getEventType());
+
+ while (parser1.hasNext()) {
+
+ int parser1Event = parser1.next();
+ int parser2Event = parser2.next();
+ assertEquals(parser1Event, parser2Event);
+
+ }
+
+
+ }
+
+ public void testParserEventsWithoutCache() throws Exception {
+
+ assertEquals(parser1.getEventType(), parser3.getEventType());
+
+ while (parser1.hasNext()) {
+ int parser1Event = parser1.next();
+ int parser2Event = parser3.next();
+ assertEquals(parser1Event, parser2Event);
+ }
+
+
+ }
+
+ public void testParserEvents2WithCache() throws Exception {
+ while (parser1.hasNext()) {
+ int parser1Event = parser1.getEventType();
+ int parser2Event = parser2.getEventType();
+ parser1.next();
+ parser2.next();
+ assertEquals(parser1Event, parser2Event);
+ }
+
+
+ }
+}
+
+// public void testParserEvents2() throws Exception{
+//
+// System.out.println("parser2 initial = " + parser2.getEventType());
+// while(parser2.hasNext()){
+// System.out.println(" event "+ parser2.next() + parser2.getLocalName());
+// }
+
+
+//}
+
+
+
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/StaxParserTest.java
------------------------------------------------------------------------------
svn:eol-style = native