You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ch...@apache.org on 2006/02/01 11:36:10 UTC

svn commit: r374036 [10/15] - in /webservices/commons/trunk/axiom: src/org/apache/ws/ src/org/apache/ws/commons/ src/org/apache/ws/commons/attachments/ src/org/apache/ws/commons/attachments/utils/ src/org/apache/ws/commons/om/ src/org/apache/ws/commons...

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/BadInputTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/BadInputTest.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/BadInputTest.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/BadInputTest.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,136 @@
+/*
+ * 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.ws.commons.om;
+
+import org.apache.ws.commons.soap.SOAPEnvelope;
+
+public class BadInputTest extends OMTestCase {
+
+    public BadInputTest(String testName) {
+        super(testName);
+    }
+
+
+    //done
+    public void testEnvelopeMissing() throws Exception {
+        try {
+            SOAPEnvelope soapEnvelope =
+                    (SOAPEnvelope) OMTestUtils.getOMBuilder(
+                            getTestResourceFile(TestConstants.BAD_ENVELOPE_MISSING))
+                    .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(
+                            getTestResourceFile(TestConstants.BAD_HEADER_BODY_WRONG_ORDER))
+                    .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(
+                            getTestResourceFile(TestConstants.BAD_TWO_BODY))
+                    .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(
+                            getTestResourceFile(TestConstants.BAD_TWO_HEADERS))
+                    .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(
+                            getTestResourceFile(TestConstants.BAD_WRONG_SOAP_NS))
+                    .getDocumentElement();
+            OMTestUtils.walkThrough(soapEnvelope);
+            fail("this must failed gracefully with OMException or AxisFault");
+        } catch (OMException e) {
+            return;
+        }
+
+    }
+
+
+
+
+}

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/CompareOMWithDOMTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/CompareOMWithDOMTest.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/CompareOMWithDOMTest.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/CompareOMWithDOMTest.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,57 @@
+/*
+ * 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.ws.commons.om;
+
+import org.apache.ws.commons.soap.SOAPEnvelope;
+import org.w3c.dom.Document;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.File;
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public class CompareOMWithDOMTest extends AbstractTestCase {
+    /**
+     * @param testName
+     */
+    public CompareOMWithDOMTest(String testName) {
+        super(testName);
+    }
+
+    public void testAllMessagesInSOAP() throws OMException, Exception {
+        File dir = new File(testResourceDir, "soap");
+        File[] files = dir.listFiles();
+        if (files != null) {
+            for (int i = 0; i < files.length; i++) {
+                if (files[i].isFile() && files[i].getName().endsWith(".xml") && !files[i].getName().startsWith("wrong")) {
+                    SOAPEnvelope soapEnvelope = (SOAPEnvelope) OMTestUtils.getOMBuilder(
+                            files[i])
+                            .getDocumentElement();
+                    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+                    dbf.setNamespaceAware(true);
+                    DocumentBuilder builder = dbf.newDocumentBuilder();
+                    Document doc = builder.parse(files[i].getAbsolutePath());
+                    OMTestUtils.compare(doc.getDocumentElement(),
+                            soapEnvelope);
+                }
+            }
+
+        }
+    }
+}

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/DefaultNamespaceTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/DefaultNamespaceTest.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/DefaultNamespaceTest.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/DefaultNamespaceTest.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,52 @@
+package org.apache.ws.commons.om;
+
+import org.custommonkey.xmlunit.XMLTestCase;
+
+import javax.xml.namespace.QName;
+
+/*
+ * 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.
+ *
+ */
+
+public class DefaultNamespaceTest extends XMLTestCase {
+
+    public void testDefaultNamespace() throws Exception {
+
+        String expectedXML = "<Foo xmlns=\"http://defaultNsUri.org\"><Bar xmlns=\"\"></Bar><Baz></Baz></Foo>";
+
+        OMFactory factory = OMAbstractFactory.getOMFactory();
+        OMElement foo = factory.createOMElement(new QName("http://defaultNsUri.org", "Foo"), null);
+        factory.createOMElement("Bar", null, foo);
+        factory.createOMElement(new QName("http://defaultNsUri.org", "Baz"), foo);
+        assertXMLEqual(expectedXML, foo.toString());
+    }
+
+    public void test() {
+        OMFactory factory = OMAbstractFactory.getOMFactory();
+
+        String nsURI = "http://test.org";
+        String nsPrefix = "testPrefix";
+        OMElement element = factory.createOMElement("DocElement", null);
+
+        OMElement foo = factory.createOMElement(new QName(nsURI, "Foo", nsPrefix), element);
+        factory.createOMElement(new QName(nsURI+1, "Bar", nsPrefix), element);
+
+        factory.createOMElement(new QName(nsURI+2, "Baz", nsPrefix), foo);
+        factory.createOMElement(new QName(nsURI, "Baz", nsPrefix), foo);
+
+    }
+
+}

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/IteratorTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/IteratorTest.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/IteratorTest.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/IteratorTest.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,184 @@
+/*
+ * 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.ws.commons.om;
+
+import org.apache.ws.commons.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.ws.commons.om.impl.llom.factory.OMLinkedListImplFactory;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+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);
+
+    }
+
+
+}

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/MIMEOutputUtilsTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/MIMEOutputUtilsTest.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/MIMEOutputUtilsTest.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/MIMEOutputUtilsTest.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,91 @@
+/*
+ * 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.ws.commons.om;
+
+import junit.framework.TestCase;
+import org.apache.ws.commons.attachments.ByteArrayDataSource;
+import org.apache.ws.commons.om.impl.MIMEOutputUtils;
+import org.apache.ws.commons.soap.SOAP12Constants;
+import org.apache.ws.commons.soap.SOAPFactory;
+
+import javax.activation.DataHandler;
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+public class MIMEOutputUtilsTest extends TestCase {
+    byte[] buffer;
+    byte[] byteArray = new byte[]{13, 56, 65, 32, 12, 12, 7, -3, -2, -1,
+                                  98};
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+        ByteArrayOutputStream outStream;
+        String boundary;
+        
+        OMOutputFormat omOutput = new OMOutputFormat();
+        boundary = omOutput.getMimeBoundary();
+
+        String contentType = org.apache.ws.commons.om.impl.MIMEOutputUtils
+				.getContentTypeForMime(boundary, omOutput.getRootContentId(),
+						omOutput.getCharSetEncoding(),SOAP12Constants.SOAP_12_CONTENT_TYPE);
+        DataHandler dataHandler;
+        dataHandler = new DataHandler(new ByteArrayDataSource(byteArray));
+        OMText textData = factory.createText(dataHandler, true);
+        assertNotNull(textData.getContentID());
+
+        DataHandler dataHandler2 = new DataHandler(
+                "Apache Software Foundation", "text/plain");
+        OMText text = factory.createText(dataHandler2, true);
+        assertNotNull(text.getContentID());
+        outStream = new ByteArrayOutputStream();
+        outStream.write(("Content-Type: " + contentType).getBytes());
+        outStream.write(new byte[]{13,10});
+        outStream.write(new byte[]{13,10});
+
+        MIMEOutputUtils.startWritingMime(outStream, boundary);
+        MimeBodyPart part1 = MIMEOutputUtils.createMimeBodyPart(textData);
+        MIMEOutputUtils.writeBodyPart(outStream, part1, boundary);
+        MimeBodyPart part2 = MIMEOutputUtils.createMimeBodyPart(text);
+        MIMEOutputUtils.writeBodyPart(outStream, part2, boundary);
+        MIMEOutputUtils.finishWritingMime(outStream);
+        buffer = outStream.toByteArray();
+    }
+
+    public void testMIMEWriting() throws IOException, MessagingException {
+        ByteArrayInputStream inStream = new ByteArrayInputStream(buffer);
+        Properties props = new Properties();
+        javax.mail.Session session = javax.mail.Session
+                .getInstance(props, null);
+        MimeMessage mimeMessage = new MimeMessage(session, inStream);
+        DataHandler dh = mimeMessage.getDataHandler();
+        MimeMultipart multiPart = new MimeMultipart(dh.getDataSource());
+        MimeBodyPart mimeBodyPart0 = (MimeBodyPart) multiPart.getBodyPart(0);
+        Object object0 = mimeBodyPart0.getContent();
+        assertNotNull(object0);
+        MimeBodyPart mimeBodyPart1 = (MimeBodyPart) multiPart.getBodyPart(1);
+        Object object1 = mimeBodyPart1.getContent();
+        assertNotNull(object1);
+        assertEquals(multiPart.getCount(),2);
+    }
+}
\ No newline at end of file

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/MessagesTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/MessagesTest.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/MessagesTest.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/MessagesTest.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,62 @@
+/*
+ * 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.ws.commons.om;
+
+import org.apache.ws.commons.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(TestConstants.WHITESPACE_MESSAGE))
+                .getDocumentElement();
+        OMTestUtils.walkThrough(soapEnvelope);
+    }
+
+    public void testMinimalMessage() throws OMException, Exception {
+        soapEnvelope =
+                (SOAPEnvelope) OMTestUtils.getOMBuilder(
+                        getTestResourceFile(TestConstants.MINIMAL_MESSAGE))
+                .getDocumentElement();
+        OMTestUtils.walkThrough(soapEnvelope);
+    }
+
+    public void testReallyBigMessage() throws OMException, Exception {
+        soapEnvelope =
+                (SOAPEnvelope) OMTestUtils.getOMBuilder(
+                        getTestResourceFile(TestConstants.REALLY_BIG_MESSAGE))
+                .getDocumentElement();
+        OMTestUtils.walkThrough(soapEnvelope);
+    }
+
+    public void testEmptyBodiedMessage() throws OMException, Exception {
+        soapEnvelope =
+                (SOAPEnvelope) OMTestUtils.getOMBuilder(
+                        getTestResourceFile(TestConstants.EMPTY_BODY_MESSAGE))
+                .getDocumentElement();
+        OMTestUtils.walkThrough(soapEnvelope);
+    }
+
+
+}

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMBlankElementTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMBlankElementTest.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMBlankElementTest.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMBlankElementTest.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,56 @@
+/*
+ * 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.ws.commons.om;
+
+import junit.framework.TestCase;
+
+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();
+			assertNull("There's a serialized output for a blank XML element that cannot exist", value);
+		} catch (Exception e) {
+			//An exception is thrown trying to serializeAndConsume 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.serialize(writer);
+		writer.flush();
+		return writer.toString();
+	}
+}

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMBodyTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMBodyTest.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMBodyTest.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMBodyTest.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,62 @@
+/*
+ * 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.ws.commons.om;
+
+import org.apache.ws.commons.soap.SOAPBody;
+import org.apache.ws.commons.soap.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.serializeAndConsume(soapBody, System.out);
+    }
+
+}

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMDocumentTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMDocumentTest.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMDocumentTest.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMDocumentTest.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,95 @@
+/*
+ * 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.ws.commons.om;
+
+import junit.framework.TestCase;
+import org.apache.ws.commons.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;
+
+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();
+        omDocument.serializeAndConsume(outStream);
+        outXML = new String(outStream.toByteArray());
+
+        // 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;
+//    }
+
+}

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMElementCloneTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMElementCloneTest.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMElementCloneTest.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMElementCloneTest.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,89 @@
+package org.apache.ws.commons.om;
+
+import org.apache.ws.commons.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.ws.commons.soap.SOAPBody;
+import org.apache.ws.commons.soap.SOAPEnvelope;
+import org.custommonkey.xmlunit.XMLTestCase;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+
+/*
+ * 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.
+ *
+ */
+
+public class OMElementCloneTest extends XMLTestCase {
+
+    File dir = new File(TestConstants.TEST_RESOURCES, TestConstants.SOAP_DIR);
+
+    public void testElementCloningWithoutUsingOMElementMethod() throws Exception {
+        SOAPEnvelope soapEnvelope =
+                (SOAPEnvelope) OMTestUtils.getOMBuilder(
+                        new File(dir, TestConstants.SOAPMESSAGE))
+                        .getDocumentElement();
+        SOAPBody body = soapEnvelope.getBody();
+
+        OMElement firstClonedBodyElement = new StAXOMBuilder(body.getXMLStreamReader()).getDocumentElement();
+        OMElement secondClonedBodyElement = new StAXOMBuilder(body.getXMLStreamReader()).getDocumentElement();
+
+        // first check whether both have the same information
+        assertXMLEqual(newDocument(body.toString()), newDocument(firstClonedBodyElement.toString()));
+        assertXMLEqual(newDocument(body.toString()), newDocument(secondClonedBodyElement.toString()));
+        assertXMLEqual(newDocument(firstClonedBodyElement.toString()), newDocument(secondClonedBodyElement.toString()));
+
+        // lets check some links. They must not be equal
+        assertNotSame(body.getParent(), firstClonedBodyElement.getParent());
+        assertNotSame(body.getParent(), secondClonedBodyElement.getParent());
+        assertNotSame(firstClonedBodyElement.getParent(), secondClonedBodyElement.getParent());
+
+    }
+
+    public void testElementCloningUsingOMElementMethod() throws Exception {
+        SOAPEnvelope soapEnvelope =
+                (SOAPEnvelope) OMTestUtils.getOMBuilder(
+                        new File(dir, TestConstants.SOAPMESSAGE))
+                        .getDocumentElement();
+        SOAPBody body = soapEnvelope.getBody();
+
+        OMElement firstClonedBodyElement = body.cloneOMElement();
+        OMElement secondClonedBodyElement = body.cloneOMElement();
+
+        // first check whether both have the same information
+        assertXMLEqual(newDocument(body.toString()), newDocument(firstClonedBodyElement.toString()));
+        assertXMLEqual(newDocument(body.toString()), newDocument(secondClonedBodyElement.toString()));
+        assertXMLEqual(newDocument(firstClonedBodyElement.toString()), newDocument(secondClonedBodyElement.toString()));
+
+        // lets check some links. They must not be equal
+        assertNotSame(body.getParent(), firstClonedBodyElement.getParent());
+        assertNotSame(body.getParent(), secondClonedBodyElement.getParent());
+        assertNotSame(firstClonedBodyElement.getParent(), secondClonedBodyElement.getParent());
+
+    }
+
+    public Document newDocument(String xml)
+            throws ParserConfigurationException, SAXException, IOException {
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware(true);
+        DocumentBuilder db = dbf.newDocumentBuilder();
+        return db.parse(new ByteArrayInputStream(xml.getBytes()));
+    }
+}

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMElementQNameTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMElementQNameTest.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMElementQNameTest.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMElementQNameTest.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,88 @@
+/** (C) Copyright 2005 Hewlett-Packard Development Company, LP
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+ For more information: www.smartfrog.org
+
+ */
+package org.apache.ws.commons.om;
+
+import org.apache.ws.commons.om.util.ElementHelper;
+
+import javax.xml.namespace.QName;
+
+/**
+ * created 03-Nov-2005 11:46:32
+ */
+
+public class OMElementQNameTest extends OMTestCase {
+
+    OMElement element;
+
+    private static final String WSA= "http://schemas.xmlsoap.org/ws/2004/03/addressing";
+    private static final String SOAPENV = "http://schemas.xmlsoap.org/soap/envelope/";
+
+    public OMElementQNameTest(String testName) {
+        super(testName);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        element = OMTestUtils.getOMBuilder(
+                        getTestResourceFile(TestConstants.SOAP_SOAPMESSAGE1))
+                        .getDocumentElement();
+    }
+
+    public void testSimpleQName() throws Exception {
+        QName result = element.resolveQName("wsa:To");
+        assertEquals(WSA,result.getNamespaceURI());
+        assertEquals("wsa", result.getPrefix());
+        assertEquals("To", result.getLocalPart());
+    }
+
+    public void testDefaultQName() throws Exception {
+        QName result = element.resolveQName("localonly");
+        assertEquals(SOAPENV, result.getNamespaceURI());
+        assertEquals("soapenv", result.getPrefix());
+        assertEquals("localonly", result.getLocalPart());
+    }
+
+    public void testDefaultQNameCanBeLocal() throws Exception {
+        ElementHelper helper=new ElementHelper(element);
+        QName result = helper.resolveQName("localonly",false);
+        assertEquals("", result.getNamespaceURI());
+        assertEquals("localonly", result.getLocalPart());
+    }
+
+    public void testNoLocal() throws Exception {
+        assertResolvesToNull("wsa:");
+    }
+
+    public void testNoMatch() throws Exception {
+        assertResolvesToNull("wsa2005:To");
+    }
+
+    public void testNothing() throws Exception {
+        assertResolvesToNull(":");
+    }
+
+
+
+    private void assertResolvesToNull(String qname) {
+        QName result = element.resolveQName(qname);
+        assertNull("Expected "+qname+" to resolve to null",result);
+    }
+
+}

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMNavigatorTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMNavigatorTest.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMNavigatorTest.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMNavigatorTest.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,103 @@
+/*
+ * 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.ws.commons.om;
+
+import org.apache.ws.commons.om.impl.llom.OMNavigator;
+import org.apache.ws.commons.soap.SOAPEnvelope;
+import org.apache.ws.commons.soap.impl.llom.builder.StAXSOAPModelBuilder;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+
+public class OMNavigatorTest extends AbstractTestCase {
+    private SOAPEnvelope envelope = null;
+    private OMXMLParserWrapper builder;
+    private File tempFile;
+    private XMLStreamWriter output;
+
+    public OMNavigatorTest(String testName) {
+        super(testName);
+    }
+
+    protected void setUp() throws Exception {
+        XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().
+                createXMLStreamReader(
+                        new FileReader(
+                                getTestResourceFile(TestConstants.SOAP_SOAPMESSAGE1)));
+        builder = new StAXSOAPModelBuilder(xmlStreamReader, null);
+        envelope = (SOAPEnvelope) builder.getDocumentElement();
+        tempFile = File.createTempFile("temp", "xml");
+        output =
+                XMLOutputFactory.newInstance().createXMLStreamWriter(
+                        new FileOutputStream(tempFile));
+    }
+
+    public void testnavigatorFullyBuilt() throws Exception {
+        assertNotNull(envelope);
+        //dump the out put to a  temporary file
+        envelope.serialize(output);
+
+        //now the OM is fully created -> test the navigation
+        OMNavigator navigator = new OMNavigator(envelope);
+        OMNode node = null;
+        while (navigator.isNavigable()) {
+            node = navigator.next();
+            assertNotNull(node);
+        }
+    }
+
+    public void testnavigatorHalfBuilt() {
+        assertNotNull(envelope);
+        //now the OM is not fully created. Try to navigate it
+        OMNavigator navigator = new OMNavigator(envelope);
+        OMNode node = null;
+        while (navigator.isNavigable()) {
+            node = navigator.next();
+            assertNotNull(node);
+        }
+    }
+
+    public void testnavigatorHalfBuiltStep() {
+        assertNotNull(envelope);
+
+        //now the OM is not fully created
+        OMNavigator navigator = new OMNavigator(envelope);
+        OMNode node = null;
+        while (!navigator.isCompleted()) {
+            if (navigator.isNavigable()) {
+                node = navigator.next();
+            } else {
+                builder.next();
+                navigator.step();
+                node = navigator.next();
+            }
+            assertNotNull(node);
+
+        }
+
+    }
+
+    protected void tearDown() throws Exception {
+        tempFile.delete();
+    }
+
+}

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMTest.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMTest.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMTest.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,142 @@
+/*
+ * 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.ws.commons.om;
+
+import org.apache.ws.commons.soap.SOAPEnvelope;
+import org.apache.ws.commons.soap.impl.llom.builder.StAXSOAPModelBuilder;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.Iterator;
+
+/**
+ * This test case tests the basic expectations of the engine from the OM.
+ */
+public class OMTest extends AbstractTestCase {
+    private SOAPEnvelope envelope;
+
+    /**
+     * Constructor.
+     */
+    public OMTest(String testName) {
+        super(testName);
+    }
+
+    protected void setUp() throws Exception {
+        File file = getTestResourceFile(TestConstants.SAMPLE1);
+        XMLStreamReader parser = XMLInputFactory.newInstance()
+                .createXMLStreamReader(new FileReader(file));
+        OMXMLParserWrapper builder = new StAXSOAPModelBuilder(parser, null);
+        envelope = (SOAPEnvelope) builder.getDocumentElement();
+    }
+
+    /**
+     * Sometime the hasNext() in the childeren iterator is true yet the next() is null
+     */
+    public void testNullInChilderen() {
+        isNullChildrenThere(envelope);
+    }
+
+    /**
+     * the envelope is completly namesapce qulified so all the OMElements got to have namespace values not null
+     */
+    public void test4MissingNamespaces() {
+        isNameSpacesMissing(envelope);
+    }
+
+    public void isNullChildrenThere(OMElement omeleent) {
+        Iterator it = omeleent.getChildren();
+        while (it.hasNext()) {
+            OMNode node = (OMNode) it.next();
+            assertNotNull(node);
+            if (node.getType() == OMNode.ELEMENT_NODE) {
+                isNullChildrenThere((OMElement) node);
+            }
+        }
+    }
+
+    public void isNameSpacesMissing(OMElement omeleent) {
+        OMNamespace omns = omeleent.getNamespace();
+        assertNotNull(omns);
+        assertNotNull(omns.getName());
+        Iterator it = omeleent.getChildren();
+        while (it.hasNext()) {
+            OMNode node = (OMNode) it.next();
+            if (node != null && node.getType() == OMNode.ELEMENT_NODE) {
+                isNameSpacesMissing((OMElement) node);
+            }
+        }
+    }
+
+    public void testRootNotCompleteInPartialBuild() throws Exception {
+        assertFalse("Root should not be complete", envelope.isComplete());
+    }
+
+    /**
+     * Assumption - The fed XML has at least two children under the root element
+     *
+     * @throws Exception
+     */
+    public void testFirstChildDetach() throws Exception {
+        OMElement root = envelope;
+        assertFalse("Root should not be complete", root.isComplete());
+        OMNode oldFirstChild = root.getFirstOMChild();
+        assertNotNull(oldFirstChild);
+        oldFirstChild.detach();
+        OMNode newFirstChild = root.getFirstOMChild();
+        assertNotNull(newFirstChild);
+        assertNotSame(oldFirstChild, newFirstChild);
+    }
+
+    //todo this is wrong correct this
+    public void testAdditionOfaCompletelyNewElement() throws Exception {
+
+        //        OMElement root= envelope;
+        //
+        //        OMNamespace soapenv= root.findNamespace("http://schemas.xmlsoap.org/soap/envelope/", "soapenv");
+        //        OMNamespace wsa= root.findNamespace("http://schemas.xmlsoap.org/ws/2004/03/addressing", "wsa");
+        //        if (wsa==null)
+        //            wsa= root.declareNamespace("http://schemas.xmlsoap.org/ws/2004/03/addressing", "wsa");
+        //
+        //        //Assumption - A RelatesTo Element does not exist in the input document
+        //        OMElement relatesTo= fac.createOMElement ("RelatesTo", wsa);
+        //        relatesTo.addAttribute(fac.createOMAttribute("RelationshipType", null, "wsa:Reply", relatesTo));
+        //        relatesTo.addAttribute(fac.createOMAttribute("mustUnderstand", soapenv, "0", relatesTo));
+        //        relatesTo.addChild(fac.createText(relatesTo, "uuid:3821F4F0-D020-11D8-A10A-E4EE6425FCB0"));
+        //        relatesTo.setComplete(true);
+        //
+        //        root.addChild(relatesTo);
+        //
+        //        QName name = new QName(wsa.getName(),"RelatesTo",wsa.getPrefix());
+        //
+        //        Iterator children = root.getChildrenWithName(name);
+        //        //this should contain only one child!
+        //        if (children.hasNext()){
+        //            OMElement newlyAddedElement = (OMElement)children.next();
+        //
+        //            assertNotNull(newlyAddedElement);
+        //
+        //            assertEquals(newlyAddedElement.getLocalName(),"RelatesTo");
+        //            //todo put the other assert statements here
+        //        }else{
+        //            assertFalse("New child not added",true);
+        //        }
+
+    }
+}

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMTestCase.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMTestCase.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMTestCase.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,73 @@
+/*
+ * 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.ws.commons.om;
+
+import org.apache.ws.commons.soap.SOAPEnvelope;
+import org.apache.ws.commons.soap.SOAPFactory;
+import org.apache.ws.commons.soap.impl.llom.builder.StAXSOAPModelBuilder;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import java.io.FileReader;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public abstract class OMTestCase extends AbstractTestCase {
+    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 = TestConstants.SOAP_SOAPMESSAGE;
+        }
+        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);
+    }
+
+
+}

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMTestUtils.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMTestUtils.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMTestUtils.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/OMTestUtils.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,121 @@
+/*
+ * 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.ws.commons.om;
+
+import junit.framework.TestCase;
+import org.apache.ws.commons.om.impl.llom.factory.OMXMLBuilderFactory;
+import org.apache.ws.commons.soap.SOAPEnvelope;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+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.getAllAttributes();
+        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.getAllAttributes();
+            OMAttribute omattribute;
+            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.getAttributeValue());
+                } 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();
+    }
+
+}

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/SpacesTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/SpacesTest.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/SpacesTest.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/SpacesTest.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,98 @@
+/*
+ * 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.ws.commons.om;
+
+import org.apache.ws.commons.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.ws.commons.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.XMLStreamException;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+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();
+
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            ((OMDocument) rootElement.getParent()).serialize(baos);
+
+            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);
+    }
+
+
+}

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/StaxParserTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/StaxParserTest.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/StaxParserTest.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/StaxParserTest.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,221 @@
+/*
+ * 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.ws.commons.om;
+
+import org.apache.ws.commons.om.impl.llom.factory.OMXMLBuilderFactory;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import java.io.ByteArrayInputStream;
+import java.util.Iterator;
+
+public class StaxParserTest extends AbstractTestCase {
+
+    XMLStreamReader parser1;
+    XMLStreamReader parser2;
+    XMLStreamReader parser3;
+    XMLStreamReader parser4;
+    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
+        //Parser 1 is a plain parser from the stax implementation
+        parser1 =
+                XMLInputFactory.newInstance().createXMLStreamReader(
+                        new ByteArrayInputStream(xmlDocument.getBytes()));
+
+        //parser 2 is one of our parsers taken with cache. i.e. when the parser
+        //proceeds the object model will be built
+        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(
+                OMAbstractFactory.getSOAP11Factory(),
+                XMLInputFactory.newInstance().createXMLStreamReader(
+                        new ByteArrayInputStream(xmlDocument.getBytes())));
+        parser2 = builder.getDocumentElement().getXMLStreamReader();
+
+        //same as parser2 but this time the parser is not a caching parser. Once the
+        //parser proceeds, it's gone forever.
+        OMXMLParserWrapper builder2 = OMXMLBuilderFactory.createStAXOMBuilder(
+                OMAbstractFactory.getSOAP11Factory(),
+                XMLInputFactory.newInstance().createXMLStreamReader(
+                        new ByteArrayInputStream(xmlDocument.getBytes())));
+        parser3 =
+                builder2.getDocumentElement().getXMLStreamReaderWithoutCaching();
+
+        //parser4 is another instance of our parser accessing the same stream as parser3.
+        // Note - The implementation returns a *new* instance but with reference to
+        //the same underlying stream!
+        parser4 = builder2.getDocumentElement().getXMLStreamReaderWithoutCaching();
+
+    }
+
+    public void testParserEventsWithCache() throws Exception {
+
+        //check the initial event
+        assertEquals(parser1.getEventType(), parser2.getEventType());
+
+        //check the other events
+        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 testParserBehaviornonCaching() throws Exception{
+
+        OMXMLParserWrapper builder2 = OMXMLBuilderFactory.createStAXOMBuilder(
+                OMAbstractFactory.getOMFactory(),
+                XMLInputFactory.newInstance().createXMLStreamReader(
+                        new ByteArrayInputStream(xmlDocument.getBytes())));
+
+        OMElement documentElement = builder2.getDocumentElement();
+        XMLStreamReader originalParser =
+                documentElement.getXMLStreamReaderWithoutCaching();
+
+        //consume the parser. this should force the xml stream to be exhausted without
+        //building the tree
+        while(originalParser.hasNext()){
+            originalParser.next();
+        }
+
+        //try to find the children of the document element. This should produce an
+        //error since the underlying stream is fully consumed without building the object tree
+        Iterator childElements = documentElement.getChildElements();
+        try {
+            while (childElements.hasNext()) {
+                childElements.next();
+                fail("The stream should've been consumed by now!");
+            }
+        } catch (Exception e) {
+            //if we are here without failing, then we are successful
+        }
+    }
+
+
+    public void testParserBehaviorCaching() throws Exception{
+
+        OMXMLParserWrapper builder2 = OMXMLBuilderFactory.createStAXOMBuilder(
+                OMAbstractFactory.getSOAP11Factory(),
+                XMLInputFactory.newInstance().createXMLStreamReader(
+                        new ByteArrayInputStream(xmlDocument.getBytes())));
+
+        OMElement documentElement = builder2.getDocumentElement();
+        XMLStreamReader originalParser =
+                documentElement.getXMLStreamReader();
+
+        //consume the parser. this should force the xml stream to be exhausted but the
+        //tree to be fully built
+        while(originalParser.hasNext()){
+            originalParser.next();
+        }
+
+        //try to find the children of the document element. This should *NOT* produce an
+        //error even when the underlying stream is fully consumed , the object tree is already complete
+        Iterator childElements = documentElement.getChildElements();
+        int count = 0;
+        try {
+            while (childElements.hasNext()) {
+                childElements.next();
+                count++;
+            }
+        } catch (Exception e) {
+            fail("The object tree needs to be built and traversing the children is to be a success!");
+        }
+
+        assertEquals("Number of elements need to be 2",count,2);
+    }
+
+
+    public void testParserBehaviorNonCaching2() throws Exception{
+
+        OMXMLParserWrapper builder2 = OMXMLBuilderFactory.createStAXOMBuilder(
+                OMAbstractFactory.getSOAP11Factory(),
+                XMLInputFactory.newInstance().createXMLStreamReader(
+                        new ByteArrayInputStream(xmlDocument.getBytes())));
+
+        OMElement documentElement = builder2.getDocumentElement();
+
+        XMLStreamReader originalParser =
+                documentElement.getXMLStreamReaderWithoutCaching();
+
+        //consume the parser. this should force the xml stream to be exhausted without
+        //building the tree
+        while(originalParser.hasNext()){
+            originalParser.next();
+        }
+
+        //try to find the children of the document element. This should produce an
+        //error since the underlying stream is fully consumed without building the object tree
+        Iterator childElements = documentElement.getChildElements();
+        try {
+            XMLStreamWriter writer =
+                    XMLOutputFactory.newInstance().
+                            createXMLStreamWriter(System.out);
+            documentElement.serializeAndConsume(writer);
+            fail("Stream should be consumed by now");
+        }catch(XMLStreamException e){
+           //wea re cool
+        } catch (Exception e) {
+           fail("This should throw an XMLStreamException");
+        }
+    }
+
+}
+

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/TestConstants.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/TestConstants.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/TestConstants.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/TestConstants.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,44 @@
+/*
+ * Copyright 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.ws.commons.om;
+
+/**
+ * All the various files
+ * created 03-Nov-2005 12:02:12
+ */
+
+public class TestConstants {
+    public static final String TEST_RESOURCES = "test-resources";
+    public static final String SOAP_DIR = "soap";
+    public static final String SOAPMESSAGE = "soapmessage.xml";
+    public static final String SOAP_SOAPMESSAGE = "soap/soapmessage.xml";
+    public static final String SOAP_SOAPMESSAGE1 = "soap/soapmessage1.xml";
+    public static final String SAMPLE1 = "soap/sample1.xml";
+    public static final String WHITESPACE_MESSAGE = "soap/whitespacedMessage.xml";
+    public static final String MINIMAL_MESSAGE = "soap/minimalMessage.xml";
+    public static final String REALLY_BIG_MESSAGE = "soap/reallyReallyBigMessage.xml";
+    public static final String EMPTY_BODY_MESSAGE = "soap/emtyBodymessage.xml";
+    public static final String BAD_WRONG_SOAP_NS = "badsoap/wrongSoapNs.xml";
+    public static final String BAD_TWO_HEADERS = "badsoap/twoheaders.xml";
+    public static final String BAD_TWO_BODY = "badsoap/twoBodymessage.xml";
+    public static final String BAD_ENVELOPE_MISSING = "badsoap/envelopeMissing.xml";
+    public static final String BAD_HEADER_BODY_WRONG_ORDER = "badsoap/haederBodyWrongOrder.xml";
+
+    private TestConstants() {
+    }
+
+
+}

Added: webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/factory/OMLinkedListImplFactoryTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/factory/OMLinkedListImplFactoryTest.java?rev=374036&view=auto
==============================================================================
--- webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/factory/OMLinkedListImplFactoryTest.java (added)
+++ webservices/commons/trunk/axiom/test/org/apache/ws/commons/om/factory/OMLinkedListImplFactoryTest.java Wed Feb  1 02:33:37 2006
@@ -0,0 +1,235 @@
+/*
+ * 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.ws.commons.om.factory;
+
+import org.apache.ws.commons.om.AbstractTestCase;
+import org.apache.ws.commons.om.OMAbstractFactory;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMNamespace;
+import org.apache.ws.commons.om.OMTestUtils;
+import org.apache.ws.commons.om.OMText;
+import org.apache.ws.commons.om.OMXMLParserWrapper;
+import org.apache.ws.commons.soap.SOAP11Constants;
+import org.apache.ws.commons.soap.SOAPBody;
+import org.apache.ws.commons.soap.SOAPConstants;
+import org.apache.ws.commons.soap.SOAPEnvelope;
+import org.apache.ws.commons.soap.SOAPFactory;
+import org.apache.ws.commons.soap.SOAPFault;
+import org.apache.ws.commons.soap.SOAPHeader;
+import org.apache.ws.commons.soap.SOAPHeaderBlock;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * User: Eran Chinthaka (eran.chinthaka@gmail.com)
+ * Date: Feb 8, 2005
+ * Time: 11:06:09 AM
+ * All Rights Reserved.
+ */
+public class OMLinkedListImplFactoryTest extends AbstractTestCase {
+
+    private Log log = LogFactory.getLog(getClass());
+
+    public OMLinkedListImplFactoryTest(String testName) {
+        super(testName);
+    }
+
+    SOAPFactory omFactory;
+    OMNamespace namespace;
+    String nsUri = "http://www.apache.org/~chinthaka";
+    String nsPrefix = "myhome";
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        omFactory = OMAbstractFactory.getSOAP11Factory();
+        namespace = omFactory.createOMNamespace(nsUri, nsPrefix);
+    }
+
+    public void testCreateOMElementWithNoBuilder() {
+        OMElement omElement = omFactory.createOMElement("chinthaka",
+                namespace);
+        assertTrue(
+                "Programatically created OMElement should have done = true ",
+                omElement.isComplete());
+
+    }
+
+    public void testCreateOMElement() {
+        try {
+            OMXMLParserWrapper omBuilder = OMTestUtils.getOMBuilder(
+                    getTestResourceFile("soap/whitespacedMessage.xml"));
+            OMElement documentElement = omBuilder.getDocumentElement();
+            OMElement child = omFactory.createOMElement("child",
+                    namespace,
+                    documentElement,
+                    omBuilder);
+            assertTrue(
+                    "OMElement with a builder should start with done = false ",
+                    !child.isComplete());
+            assertTrue("This OMElement must have a builder ",
+                    child.getBuilder() instanceof OMXMLParserWrapper);
+
+        } catch (Exception e) {
+            log.info(e.getMessage());
+        }
+    }
+
+    public void testCreateOMNamespace() {
+        assertTrue("OMNamespace uri not correct",
+                nsUri.equals(namespace.getName()));   // here equalsIgnoreCase should not be used as case does matter
+        assertTrue("OMNamespace prefix not correct",
+                nsPrefix.equals(namespace.getPrefix()));  // here equalsIgnoreCase should not be used as case does matter
+    }
+
+    public void testCreateText() {
+        OMElement omElement = omFactory.createOMElement("chinthaka",
+                namespace);
+        String text = "sampleText";
+        OMText omText = omFactory.createText(omElement, text);
+        assertTrue("Programatically created OMText should have done = true ",
+                omText.isComplete());
+        assertTrue(
+                "Programatically created OMText should have correct text value ",
+                text.equals(omText.getText()));
+
+    }
+
+    public void testCreateSOAPBody() {
+        try {
+            OMXMLParserWrapper omBuilder = OMTestUtils.getOMBuilder(
+                    getTestResourceFile("soap/minimalMessage.xml"));
+            SOAPEnvelope soapEnvelope = (SOAPEnvelope) omBuilder.getDocumentElement();
+            SOAPBody soapBodyOne = omFactory.createSOAPBody(soapEnvelope);
+            assertTrue(
+                    "Programatically created SOAPBody should have done = true ",
+                    soapBodyOne.isComplete());
+            soapBodyOne.detach();
+            SOAPBody soapBodyTwo = omFactory.createSOAPBody(soapEnvelope,
+                    omBuilder);
+            assertTrue(
+                    "SOAPBody with a builder should start with done = false ",
+                    !soapBodyTwo.isComplete());
+            assertTrue("This SOAPBody must have a builder ",
+                    soapBodyTwo.getBuilder() instanceof OMXMLParserWrapper);
+
+
+        } catch (Exception e) {
+            log.info(e.getMessage());
+        }
+    }
+
+    public void testCreateSOAPEnvelope() {
+        try {
+            omFactory.createOMNamespace(
+                    SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,
+                    SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX);
+            SOAPEnvelope soapEnvelopeTwo = omFactory.createSOAPEnvelope();
+            assertTrue(
+                    "Programatically created SOAPEnvelope should have done = true ",
+                    soapEnvelopeTwo.isComplete());
+            SOAPEnvelope soapEnvelope = omFactory.createSOAPEnvelope(
+                    OMTestUtils.getOMBuilder(
+                            getTestResourceFile("soap/minimalMessage.xml")));
+            assertTrue(
+                    "SOAPEnvelope with a builder should start with done = false ",
+                    !soapEnvelope.isComplete());
+            assertTrue("This SOAPEnvelope must have a builder ",
+                    soapEnvelope.getBuilder() instanceof OMXMLParserWrapper);
+
+
+        } catch (Exception e) {
+            log.info(e.getMessage());
+        }
+    }
+
+    public void testCreateSOAPHeader() {
+        try {
+            OMXMLParserWrapper omBuilder = OMTestUtils.getOMBuilder(
+                    getTestResourceFile("soap/minimalMessage.xml"));
+            SOAPEnvelope soapEnvelope = (SOAPEnvelope) omBuilder.getDocumentElement();
+            SOAPHeader soapHeader = omFactory.createSOAPHeader(soapEnvelope);
+            assertTrue(
+                    "Programatically created SOAPHeader should have done = true ",
+                    soapHeader.isComplete());
+            soapHeader.detach();
+            SOAPHeader soapHeaderTwo = omFactory.createSOAPHeader(soapEnvelope,
+                    omBuilder);
+            assertTrue(
+                    "SOAPHeader with a builder should start with done = false ",
+                    !soapHeaderTwo.isComplete());
+            assertTrue("This SOAPHeader must have a builder ",
+                    soapHeaderTwo.getBuilder() instanceof OMXMLParserWrapper);
+
+
+        } catch (Exception e) {
+            log.info(e.getMessage());
+        }
+    }
+
+    public void testCreateSOAPHeaderBlock() {
+        try {
+            OMXMLParserWrapper omBuilder = OMTestUtils.getOMBuilder(
+                    getTestResourceFile("soap/soapmessage.xml"));
+            SOAPEnvelope soapEnvelope = (SOAPEnvelope) omBuilder.getDocumentElement();
+            SOAPHeader soapHeader = soapEnvelope.getHeader();
+            SOAPHeaderBlock soapHeaderBlock = omFactory.createSOAPHeaderBlock(
+                    "soapHeaderBlockOne", namespace, soapHeader);
+            assertTrue(
+                    "Programatically created SOAPHeaderBlock should have done = true ",
+                    soapHeaderBlock.isComplete());
+            SOAPHeaderBlock soapHeaderBlockTwo = omFactory.createSOAPHeaderBlock(
+                    "soapHeaderBlockOne", namespace, soapHeader, omBuilder);
+            assertTrue(
+                    "SOAPHeaderBlock with a builder should start with done = false ",
+                    !soapHeaderBlockTwo.isComplete());
+            assertTrue("This SOAPHeaderBlock must have a builder ",
+                    soapHeaderBlockTwo.getBuilder() instanceof OMXMLParserWrapper);
+
+
+        } catch (Exception e) {
+            log.info(e.getMessage());
+        }
+    }
+
+    public void testCreateSOAPFault() {
+        try {
+            OMXMLParserWrapper omBuilder = OMTestUtils.getOMBuilder(
+                    getTestResourceFile("soap/soapmessage.xml"));
+            SOAPEnvelope soapEnvelope = (SOAPEnvelope) omBuilder.getDocumentElement();
+            SOAPBody soapBody = soapEnvelope.getBody();
+            SOAPFault soapFault = omFactory.createSOAPFault(soapBody,
+                    new Exception(" this is just a test "));
+            assertTrue(
+                    "Programatically created SOAPFault should have done = true ",
+                    soapFault.isComplete());
+            soapFault.detach();
+            SOAPFault soapFaultTwo = omFactory.createSOAPFault(soapBody,
+                    omBuilder);
+            assertTrue(
+                    "SOAPFault with a builder should start with done = false ",
+                    !soapFaultTwo.isComplete());
+            assertTrue("This SOAPFault must have a builder ",
+                    soapFaultTwo.getBuilder() instanceof OMXMLParserWrapper);
+
+
+        } catch (Exception e) {
+            log.info(e.getMessage());
+        }
+    }
+
+
+}