[prev in list] [next in list] [prev in thread] [next in thread] 

List:       axis-cvs
Subject:    svn commit: r106981 - in webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis
From:       chinthaka () apache ! org
Date:       2004-11-30 3:50:49
Message-ID: 20041130035049.76394.qmail () minotaur ! apache ! org
[Download RAW message or body]

Author: chinthaka
Date: Mon Nov 29 19:50:48 2004
New Revision: 106981

URL: http://svn.apache.org/viewcvs?view=rev&rev=106981
Log:
Integrated StAX parser to OM. 
Fixed isCompleted bug
Added tests
Added:
   webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/AllOMTests.java
  webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/IteratorTester.java
  webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMnavigatorTest.java
  webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/Tester.java
  webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/builder/
  webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/builder/ObjectToOMBuilderTest.java
  webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/builder/dummy/
  webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/builder/dummy/DummyOutObject.java
  webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/impl/
  webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/impl/streamwrapper/
  webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java
  webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java
 Modified:
   webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTest.java
  webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTestCase.java
  webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTestUtils.java


Added: webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/AllOMTests.java
                
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/AllOMTests.java?view=auto&rev=106981
 ==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/AllOMTests.java	Mon \
Nov 29 19:50:48 2004 @@ -0,0 +1,42 @@
+/**
+* Copyright 2001-2004 The Apache Software Foundation.
+* <p/>
+* 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
+* <p/>
+* http://www.apache.org/licenses/LICENSE-2.0
+* <p/>
+* 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.
+* <p/>
+* Author: Eran Chinthaka - Lanka Software Foundation
+* Date: Nov 29, 2004
+* Time: 2:35:38 PM
+*/
+package org.apache.axis.om;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+public class AllOMTests {
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(AllOMTests.suite());
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite("Test for org.apache.axis.om");
+        //$JUnit-BEGIN$
+        suite.addTestSuite(OMTest.class);
+        suite.addTestSuite(IteratorTester.class);
+        suite.addTestSuite(OMnavigatorTest.class);
+        suite.addTestSuite(Tester.class);
+        //$JUnit-END$
+        return suite;
+    }
+}

Added: webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/IteratorTester.java
                
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/IteratorTester.java?view=auto&rev=106981
 ==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/IteratorTester.java	Mon \
Nov 29 19:50:48 2004 @@ -0,0 +1,72 @@
+package org.apache.axis.om;
+
+import junit.framework.TestCase;
+import org.apache.axis.om.impl.streamwrapper.OMStAXBuilder;
+import org.apache.axis.om.soap.SOAPMessage;
+
+import javax.xml.stream.XMLInputFactory;
+import java.io.FileReader;
+import java.util.Iterator;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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 Axis team
+ * Date: Oct 11, 2004
+ * Time: 12:34:15 PM
+ * 
+ */
+public class IteratorTester extends TestCase{
+    private static final String IN_FILE_NAME = "resources/soapmessage.xml";
+    private static final String IN_FILE_NAME2 = \
"src/test-resources/soap/sample1.xml"; +    SOAPMessage document = null;
+
+    protected void setUp() throws Exception {
+//        XmlPullParser parser= XmlPullParserFactory.newInstance().newPullParser();
+//		parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
+//		parser.setInput();
+//        ;
+		document = new OMStAXBuilder(XMLInputFactory.newInstance().
+                createXMLStreamReader(new \
FileReader(IN_FILE_NAME2))).getSOAPMessage(); +    }
+
+    public void testIterator(){
+        OMElement elt = document.getEnvelope();
+        Iterator iter = elt.getChildren();
+
+        while (iter.hasNext()) {
+            OMNode o = (OMNode) iter.next();
+            System.out.println("o = " + o);
+            if (o!=null)
+            System.out.println("value o " + o.getValue());
+        }
+
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}

Modified: webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTest.java
                
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype1/ \
src/test/org/apache/axis/om/OMTest.java?view=diff&rev=106981&p1=webservices/axis/trunk \
/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTest.java&r1=106980&p2=webs \
ervices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTest.java&r2=106981
 ==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTest.java	(original)
                
+++ webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTest.java	Mon \
Nov 29 19:50:48 2004 @@ -15,21 +15,20 @@
  */
 package org.apache.axis.om;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.util.Iterator;
-
-
-import org.apache.axis.om.impl.OMXMLPullParserWrapper;
+import junit.framework.TestCase;
 import org.apache.axis.om.impl.SOAPMessageImpl;
+import org.apache.axis.om.impl.streamwrapper.OMXPPWrapper;
 import org.apache.axis.om.soap.SOAPMessage;
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserFactory;
 
-import junit.framework.TestCase;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.Iterator;
 
 /**
+ * This test case tests the basic expectations of the engine from the OM.
  * @author Srinath Perera (hemapani@opensource.lk)
  */
 public class OMTest extends TestCase{
@@ -43,7 +42,7 @@
         XmlPullParser  parser = pf.newPullParser();
         parser.setInput(new InputStreamReader(in));
         
-        OMXMLParserWrapper parserWrapper = new OMXMLPullParserWrapper(parser); 
+        OMXMLParserWrapper parserWrapper = new OMXPPWrapper(parser);
         omdoc = parserWrapper.getSOAPMessage();
     }
 
@@ -52,9 +51,9 @@
      * Sometime the hasNext() in the childeren iterator is true yet the next() is \
                null
      */
 
-//    public void testNullInChilderen(){
-//        isNullChildrenAreThere(omdoc.getDocumentElement());
-//    }
+    public void testNullInChilderen(){
+        isNullChildrenAreThere(omdoc.getEnvelope());
+    }
     
     /**
      * the document is completly namesapce qulified so all the OMElements got to \
have namespace values not null @@ -87,9 +86,5 @@
                 isNameSpacesMissing((OMElement)node);
             }
         }
-    }
-    protected void tearDown() throws Exception {
-        // TODO Auto-generated method stub
-        super.tearDown();
     }
 }

Modified: webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTestCase.java
                
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype1/ \
src/test/org/apache/axis/om/OMTestCase.java?view=diff&rev=106981&p1=webservices/axis/t \
runk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTestCase.java&r1=106980 \
&p2=webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTestCase.java&r2=106981
 ==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTestCase.java	(original)
                
+++ webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTestCase.java	Mon \
Nov 29 19:50:48 2004 @@ -1,7 +1,7 @@
 package org.apache.axis.om;
 
 import junit.framework.TestCase;
-import org.apache.axis.om.impl.OMXMLPullParserWrapper;
+import org.apache.axis.om.impl.streamwrapper.OMXPPWrapper;
 import org.apache.axis.om.soap.SOAPEnvelope;
 import org.apache.axis.om.soap.SOAPMessage;
 import org.xmlpull.v1.XmlPullParser;
@@ -30,13 +30,26 @@
  */
 public class OMTestCase extends TestCase  {
 
-    protected static final String IN_FILE_NAME = \
                "src/test-resources/soapmessage.xml";
-    protected OMXMLPullParserWrapper omXmlPullParserWrapper;
+    protected static final String IN_FILE_NAME = \
"src/test-resources/soap/soapmessage.xml"; +    protected OMXPPWrapper \
omXmlPullParserWrapper;  
     protected SOAPMessage soapMessage;
     protected SOAPEnvelope soapEnvelope;
+
+
     protected void setUp() throws Exception {
-        soapMessage = OMTestUtils.getOMBuilder(IN_FILE_NAME).getSOAPMessage();
+        super.setUp();
+        soapMessage = getOMBuilder().getSOAPMessage();
         soapEnvelope = soapMessage.getEnvelope();
     }
+
+    protected OMXPPWrapper getOMBuilder() throws Exception {
+        XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
+        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
+        parser.setInput(new FileReader(IN_FILE_NAME));
+        omXmlPullParserWrapper = new OMXPPWrapper(parser);
+        return omXmlPullParserWrapper;
+    }
+
+
 }

Modified: webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTestUtils.java
                
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype1/ \
src/test/org/apache/axis/om/OMTestUtils.java?view=diff&rev=106981&p1=webservices/axis/ \
trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTestUtils.java&r1=1069 \
80&p2=webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTestUtils.java&r2=106981
 ==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTestUtils.java	(original)
                
+++ webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMTestUtils.java	Mon \
Nov 29 19:50:48 2004 @@ -19,9 +19,10 @@
 import java.io.FileReader;
 import java.util.Iterator;
 
+
 import junit.framework.TestCase;
 
-import org.apache.axis.om.impl.OMXMLPullParserWrapper;
+import org.apache.axis.om.impl.streamwrapper.OMXPPWrapper;
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserFactory;
 
@@ -29,11 +30,11 @@
  * @author Srinath Perera(hemapani@opensource.lk)
  */
 public class OMTestUtils {
-    public static OMXMLPullParserWrapper getOMBuilder(String file) throws Exception \
{ +    public static OMXPPWrapper getOMBuilder(String file) throws Exception {
         XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
         parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
         parser.setInput(new FileReader(file));
-        OMXMLPullParserWrapper omXmlPullParserWrapper = new \
OMXMLPullParserWrapper(parser); +        OMXPPWrapper omXmlPullParserWrapper = new \
OMXPPWrapper(parser);  return omXmlPullParserWrapper;
     }
     

Added: webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMnavigatorTest.java
                
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMnavigatorTest.java?view=auto&rev=106981
 ==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/OMnavigatorTest.java	Mon \
Nov 29 19:50:48 2004 @@ -0,0 +1,116 @@
+package org.apache.axis.om;
+
+import junit.framework.TestCase;
+import org.apache.axis.om.impl.OMNavigator;
+import org.apache.axis.om.impl.factory.OMLinkedListImplFactory;
+import org.apache.axis.om.impl.serialize.SimpleOMSerializer;
+import org.apache.axis.om.impl.streamwrapper.OMStAXBuilder;
+import org.apache.axis.om.soap.SOAPMessage;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.io.FileReader;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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 Axis team
+ * Date: Nov 19, 2004
+ * Time: 4:35:04 PM
+ * 
+ */
+public class OMnavigatorTest extends TestCase{
+    private static final String IN_FILE_NAME2 = \
"src/test-resources/soap/soapmessage1.xml"; +    private SOAPMessage document = null;
+    private SimpleOMSerializer serilizer;
+    private OMStAXBuilder builder;
+
+    protected void setUp() throws Exception {
+        XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().
+                createXMLStreamReader(new FileReader(IN_FILE_NAME2));
+        OMFactory factory = new OMLinkedListImplFactory();
+        builder = new OMStAXBuilder(factory,xmlStreamReader);
+        document = builder.getSOAPMessage();
+        serilizer = new SimpleOMSerializer();
+    }
+
+
+    public void testnavigatorFullyBuilt(){
+        System.out.println(" #######  Testing fully built OM tree ########");
+        assertNotNull(document);
+        serilizer.serialize(document.getEnvelope(),System.out);
+
+        //now the OM is fully created
+        OMNavigator navigator = new OMNavigator(document.getEnvelope());
+        OMNode node=null;
+        while(navigator.isNavigable()){
+            node = navigator.next();
+
+            assertNotNull(node);
+
+            System.out.println("node = " + node);
+            System.out.println("node.getValue() = " + node.getValue());
+
+        }
+
+    }
+
+    public void testnavigatorHalfBuilt(){
+        System.out.println(" #######  Testing partially built OM tree ########");
+        assertNotNull(document);
+
+        //now the OM is not fully created
+        OMNavigator navigator = new OMNavigator(document.getEnvelope());
+        OMNode node=null;
+
+        while(navigator.isNavigable()){
+            node = navigator.next();
+
+            assertNotNull(node);
+
+            System.out.println("node = " + node);
+            System.out.println("node.getValue() = " + node.getValue());
+
+        }
+
+    }
+    public void testnavigatorHalfBuiltStep(){
+        System.out.println(" #######  Testing partially built OM tree With \
Stepping########"); +        assertNotNull(document);
+
+        //now the OM is not fully created
+        OMNavigator navigator = new OMNavigator(document.getEnvelope());
+        OMNode node=null;
+
+        while(!navigator.isCompleted()){
+            if (navigator.isNavigable()){
+                node = navigator.next();
+            }else{
+                builder.next();
+                navigator.step();
+                node=navigator.next();
+            }
+
+            assertNotNull(node);
+
+            System.out.println("node = " + node);
+            System.out.println("node.getValue() = " + node.getValue());
+
+        }
+
+    }
+
+
+}

Added: webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/Tester.java
                
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/Tester.java?view=auto&rev=106981
 ==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/Tester.java	Mon \
Nov 29 19:50:48 2004 @@ -0,0 +1,233 @@
+/*
+* Created on Sep 26, 2004
+* Copyright  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.
+*
+*/
+
+package org.apache.axis.om;
+
+import junit.framework.TestCase;
+import org.apache.axis.om.impl.OMAttributeImpl;
+import org.apache.axis.om.impl.OMElementImpl;
+import org.apache.axis.om.impl.OMNavigator;
+import org.apache.axis.om.impl.OMTextImpl;
+import org.apache.axis.om.impl.serialize.SimpleOMSerializer;
+import org.apache.axis.om.impl.streamwrapper.OMStAXBuilder;
+import org.xmlpull.v1.XmlPullParser;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.lang.reflect.Field;
+
+
+/**
+ * @author Dasarath Weeratunge
+ *
+ */
+public class Tester extends TestCase {
+    private static final String IN_FILE_NAME = \
"src/test-resources/soap/soapmessage.xml"; +    private static final String \
OUT_FILE_NAME = "src/test-resources/soap/tester-out.xml"; +
+    private SimpleOMSerializer serializer = null;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        serializer = new SimpleOMSerializer();
+    }
+
+    public void test1() throws Exception {
+        System.out.println("\n+++");
+        OMElement root= getOMBuilder().getSOAPMessage().getEnvelope();
+        System.out.println(root.isComplete());
+        print(root,System.out);
+    }
+
+    public void test2() throws Exception {
+        System.out.println("\n+++");
+        OMElement root= getOMBuilder().getSOAPMessage().getEnvelope();
+
+        System.out.println(root.isComplete());
+        root.getFirstChild().detach();
+
+        System.out.println("---");
+        navigate(root);
+
+        OMElement header= (OMElement)root.getFirstChild();
+        //	we read the header completely but do not cache it
+       // header.detach();
+
+        System.out.println("---");
+        navigate(root);
+
+        System.out.println("---");
+        print(root,System.out);
+    }
+
+    public void test3() throws Exception {
+        System.out.println("\n+++");
+        OMElement root= getOMBuilder().getSOAPMessage().getEnvelope();
+
+        OMNamespace soapenv= \
root.resolveNamespace("http://schemas.xmlsoap.org/soap/envelope/", "soapenv"); +      \
OMNamespace wsa= root.resolveNamespace("http://schemas.xmlsoap.org/ws/2004/03/addressing", \
"wsa"); +
+        OMElement relatesTo= new OMElementImpl("RelatesTo", wsa);
+        relatesTo.insertAttribute(new OMAttributeImpl("RelationshipType", null, \
"wsa:Reply", relatesTo)); +        relatesTo.insertAttribute(new \
OMAttributeImpl("mustUnderstand", soapenv, "0", relatesTo)); +        \
relatesTo.addChild(new OMTextImpl(relatesTo, \
"uuid:3821F4F0-D020-11D8-A10A-E4EE6425FCB0")); +        relatesTo.setComplete(true);
+
+        System.out.println(root.isComplete());
+        root.addChild(relatesTo);
+
+        OMNavigator navigator= new OMNavigator(root);
+        OMNode node= navigator.next();
+        do {
+            if (node instanceof OMElement) {
+                OMElement el= (OMElement)node;
+                System.out.println("OMElement= " + el.getLocalName());
+            }
+            else
+                System.out.println("OMText= " + node.getValue());
+            node= navigator.next();
+        }
+        while (node != null);
+
+        print(root,System.out);
+    }
+
+    public void test4() throws Exception {
+        System.out.println("\n+++");
+        OMElementImpl root= new OMElementImpl("Envelope", null);
+        OMNamespace soapenv= \
root.createNamespace("http://schemas.xmlsoap.org/soap/envelope/", "soapenv"); +       \
root.setNamespace(soapenv); +        OMElement header= new OMElementImpl("Header", \
soapenv); +        header.setComplete(true);
+        root.addChild(header);
+        OMNamespace xsd= root.createNamespace("http://www.w3.org/2001/XMLSchema", \
"xsd"); +        OMNamespace xsi= \
root.createNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi"); +        \
OMNamespace wsa= root.createNamespace("http://schemas.xmlsoap.org/ws/2004/03/addressing", \
"wsa"); +
+        OMElement messageID= new OMElementImpl("MessageID", wsa);
+        messageID.addChild(new \
OMTextImpl("uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5")); +        \
messageID.insertAttribute(new OMAttributeImpl("mustUnderstand", soapenv, "0")); +
+        OMElement from= new OMElementImpl("From", wsa);
+        OMElement address= new OMElementImpl("Address", null);
+        address.createNamespace("http://schemas.xmlsoap.org/ws/2004/03/addressing", \
null); +        address.setNamespace(
+                address.resolveNamespace("http://schemas.xmlsoap.org/ws/2004/03/addressing", \
null)); +        address.addChild(new \
OMTextImpl("http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous")); +     \
from.addChild(address); +        //	FIXME:	cannot reuse the attribute object created \
earlier. linked list-- +        from.insertAttribute(new \
OMAttributeImpl("mustUnderstand", soapenv, "0")); +
+        OMElement to= new OMElementImpl("To", wsa);
+        to.addChild(new OMTextImpl("http://localhost:8081/axis/services/BankPort"));
+        to.insertAttribute(new OMAttributeImpl("mustUnderstand", soapenv, "0"));
+
+        OMElement relatesTo= new OMElementImpl("RelatesTo", wsa);
+        relatesTo.insertAttribute(new OMAttributeImpl("RelationshipType", null, \
"wsa:Reply")); +        relatesTo.insertAttribute(new \
OMAttributeImpl("mustUnderstand", soapenv, "0")); +        relatesTo.addChild(new \
OMTextImpl("uuid:3821F4F0-D020-11D8-A10A-E4EE6425FCB0")); +
+        header.addChild(from);
+        from.insertSiblingAfter(relatesTo);
+        from.insertSiblingBefore(to);
+        to.insertSiblingBefore(messageID);
+
+        root.print(new PrintStream(new FileOutputStream(OUT_FILE_NAME)));
+    }
+
+//	public void test5() throws Exception {
+//			System.out.println("\n+++");
+//			OMXMLParserWrapper omBuilder= getOMBuilder();
+//			OMElement root= omBuilder.getSOAPMessage().getEnvelope();
+//
+//        System.out.println("root.isComplete() = " + root.isComplete());
+//			root.getFirstChild().detach();
+//			OMElement header= (OMElement)root.getFirstChild();
+//			while (!header.isComplete())
+//				omBuilder.next();
+//			navigate(root);
+//			System.out.println("---");
+//			omBuilder.reset(header);
+//			int event;
+//			do {
+//				event= omBuilder.next();
+//				System.out.print(getFieldName(event)+"= ");
+//				if (event == XmlPullParser.TEXT)
+//					System.out.println(omBuilder.getText());
+//				else {
+//					System.out.println("{"+omBuilder.getNamespace()+"}"+omBuilder.getName());
+//				}
+//			}while (event != XmlPullParser.END_DOCUMENT);
+//			System.out.println("---");
+//			root.print(System.out);
+//		}
+
+    private void navigate(OMElement node) throws Exception {
+
+        OMNavigator navigator= new OMNavigator(node);
+        OMNode tempNode= null;
+        OMXMLParserWrapper builder;
+
+        while (navigator.isNavigable()){
+            tempNode= navigator.next();
+
+            if (tempNode instanceof OMElement) {
+				OMElement el= (OMElement)tempNode;
+				System.out.print("OMElement= " + el.getLocalName());
+			}
+			else
+				System.out.print("OMText= " + tempNode.getValue());
+
+        }
+
+//        do {
+//			if (tempNode instanceof OMElement) {
+//				OMElement el= (OMElement)tempNode;
+//				System.out.print("OMElement= " + el.getLocalName());
+//			}
+//			else
+//				System.out.print("OMText= " + tempNode.getValue());
+//			System.out.println(" isComplete= " + tempNode.isComplete());
+//			tempNode= navigator.next();
+//		}
+//		while (tempNode != null);
+    }
+
+    private OMXMLParserWrapper getOMBuilder() throws Exception {
+        XMLStreamReader reader = \
XMLInputFactory.newInstance().createXMLStreamReader(new FileReader(IN_FILE_NAME)); +  \
return new OMStAXBuilder(reader); +    }
+
+    private static Field[] flds= XmlPullParser.class.getDeclaredFields();
+
+    public static String getFieldName(int field) throws Exception {
+        for (int i= 1; i < flds.length + 1; i++) {
+            if (flds[i].getInt(null) == field)
+                return flds[i].getName();
+        }
+        return null;
+    }
+
+    private void print(OMNode node,OutputStream stream){
+        this.serializer.serialize(node,stream);
+    }
+}

Added: webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/builder/ObjectToOMBuilderTest.java
                
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype1/ \
src/test/org/apache/axis/om/builder/ObjectToOMBuilderTest.java?view=auto&rev=106981 \
                ==============================================================================
                
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/builder/ObjectToOMBuilderTest.java	Mon \
Nov 29 19:50:48 2004 @@ -0,0 +1,67 @@
+package org.apache.axis.om.builder;
+
+import junit.framework.TestCase;
+import org.xml.sax.XMLReader;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.apache.axis.om.*;
+import org.apache.axis.om.impl.factory.OMLinkedListImplFactory;
+import org.apache.axis.om.builder.dummy.DummyOutObject;
+import org.apache.axis.om.builder.dummy.DummyOutObject;
+
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Iterator;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Nov 19, 2004
+ * Time: 3:54:03 PM
+ */
+public class ObjectToOMBuilderTest extends TestCase{
+
+    OutObject outObject;
+    ObjectToOMBuilder objectToOMBuilder;
+    OMFactory omFactory;
+    private OMElement element;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        outObject = new DummyOutObject();
+        omFactory = new OMLinkedListImplFactory();
+
+        element = omFactory.createOMElement("Body", null);
+        objectToOMBuilder = new ObjectToOMBuilder(element, outObject);
+
+    }
+
+    public void testBuilding(){
+        System.out.println("element = " + element.isComplete());
+
+        objectToOMBuilder.next();
+
+        Iterator children = element.getChildren();
+        while (children.hasNext()) {
+            OMNode omNode = (OMNode) children.next();
+            System.out.println("omNode = " + omNode.getValue());
+        }
+
+        System.out.println("element = " + element.isComplete());
+    }
+
+
+}

Added: webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/builder/dummy/DummyOutObject.java
                
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype1/ \
src/test/org/apache/axis/om/builder/dummy/DummyOutObject.java?view=auto&rev=106981 \
                ==============================================================================
                
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/builder/dummy/DummyOutObject.java	Mon \
Nov 29 19:50:48 2004 @@ -0,0 +1,71 @@
+package org.apache.axis.om.builder.dummy;
+
+import org.apache.axis.om.OutObject;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+import java.io.FileReader;
+import java.io.IOException;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Nov 19, 2004
+ * Time: 3:56:08 PM
+ */
+public class DummyOutObject implements OutObject {
+    private XMLReader parser;
+    String fileName = \
"E:\\projects\\PrototypeOne\\src\\test-resources\\soapmessage.xml"; +
+
+    public DummyOutObject() {
+        setup();
+    }
+
+    private void setup() {
+        try {
+            parser = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
+            System.setProperty("org.xml.sax.driver", \
"org.apache.xerces.parsers.SAXParser"); +            \
System.out.println(System.getProperty("org.xml.sax.driver")); +
+        } catch (SAXException e) {
+            e.printStackTrace();  //TODO implement this
+        }
+
+    }
+
+    public void setContentHandler(ContentHandler contentHandler) {
+        parser.setContentHandler(contentHandler);
+
+    }
+
+    public ContentHandler getContentHandler() {
+        return parser.getContentHandler();
+    }
+
+    public void startBuilding() {
+        try {
+            parser.parse(new InputSource(new FileReader(fileName)));
+        } catch (IOException e) {
+            e.printStackTrace();  //TODO implement this
+        } catch (SAXException e) {
+            e.printStackTrace();  //TODO implement this
+        }
+
+    }
+}

Added: webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java
                
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype1/ \
src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java?view=auto&rev=106981
 ==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java	Mon \
Nov 29 19:50:48 2004 @@ -0,0 +1,117 @@
+package org.apache.axis.om.impl.streamwrapper;
+
+import junit.framework.TestCase;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.impl.factory.OMLinkedListImplFactory;
+import org.apache.axis.om.impl.serialize.SimpleOMSerializer;
+import org.apache.axis.om.soap.SOAPMessage;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamConstants;
+import java.io.FileReader;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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 Axis team
+ * Date: Nov 19, 2004
+ * Time: 5:23:01 PM
+ * 
+ */
+public class OMStaxStreamingWrapperTest extends TestCase {
+
+    private static final String IN_FILE_NAME2 = \
"src/test-resources/soap/soapmessage1.xml"; +    private SOAPMessage document = null;
+    private SimpleOMSerializer serilizer;
+    private OMStAXBuilder omStAXBuilder;
+
+    protected void setUp() throws Exception {
+        XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().
+                createXMLStreamReader(new FileReader(IN_FILE_NAME2));
+        OMFactory factory = new OMLinkedListImplFactory();
+        omStAXBuilder = new OMStAXBuilder(factory, xmlStreamReader);
+        document = omStAXBuilder.getSOAPMessage();
+        serilizer = new SimpleOMSerializer();
+    }
+
+
+    public void testWrapperFullOM() {
+        System.out.println(" # -----------------------Full \
OM------------------------------- #"); +        assertNotNull(document);
+        //this serializing will cause the OM to fully build!
+        serilizer.serialize(document.getEnvelope(), System.out);
+
+        //now the OM is fully created. Create the wrapper and see
+        OMStAXWrapper wrapper = new OMStAXWrapper(omStAXBuilder, \
document.getEnvelope()); +
+        while (wrapper.hasNext()) {
+            int event = wrapper.next();
+            assertTrue(event>0);
+        }
+
+        System.out.println(" # -----------------------Full OM end \
------------------------------- #"); +    }
+
+    public void testWrapperHalfOM() {
+        System.out.println(" # -----------------------Half \
OM------------------------------- #"); +        assertNotNull(document);
+
+        //now the OM is not fully created. Create the wrapper and see
+        OMStAXWrapper wrapper = new OMStAXWrapper(omStAXBuilder, \
document.getEnvelope()); +
+        while (wrapper.hasNext()) {
+            int event = wrapper.next();
+            assertTrue(event>0);
+//            System.out.println("returnEvent = " + getEventString(event));
+        }
+
+        System.out.println(" # -----------------------Half OM \
end------------------------------- #"); +    }
+    public void testWrapperHalfOMWithCacheOff() {
+        System.out.println(" # -----------------------Half OM with cache \
off------------------------------- #"); +        assertNotNull(document);
+
+        //now the OM is not fully created. Create the wrapper and see
+        OMStAXWrapper wrapper = new OMStAXWrapper(omStAXBuilder, \
document.getEnvelope()); +        //set the switching allowed flag
+        wrapper.setAllowSwitching(true);
+        while (wrapper.hasNext()) {
+            int event = wrapper.next();
+            assertTrue(event>0);
+//            System.out.println("returnEvent = " + getEventString(event));
+        }
+        System.out.println(" # -----------------------Half OM with cache off \
end------------------------------- #"); +    }
+
+    private String getEventString(int event){
+        String outStr = "";
+        switch (event){
+            case XMLStreamConstants.START_ELEMENT:
+                outStr = "START_ELEMENT";
+                break;
+            case XMLStreamConstants.END_ELEMENT:
+                outStr = "END_ELEMENT";
+                break;
+            case XMLStreamConstants.CHARACTERS:
+                outStr = "char";
+                break;
+            default:outStr = event+"";
+
+        }
+        return outStr;
+    }
+
+}

Added: webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java
                
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype1/ \
src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java?view=auto&rev=106981
 ==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype1/src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java	Mon \
Nov 29 19:50:48 2004 @@ -0,0 +1,59 @@
+package org.apache.axis.om.impl.streamwrapper;
+
+import junit.framework.TestCase;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.impl.factory.OMLinkedListImplFactory;
+import org.apache.axis.om.impl.serialize.SimpleOMSerializer;
+import org.apache.axis.om.soap.SOAPMessage;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.io.FileReader;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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 Axis team
+ * Date: Nov 18, 2004
+ * Time: 3:54:54 PM
+ * 
+ */
+public class OmStAXBuilderTest extends TestCase{
+
+    private static final String FILE_NAME = \
"src/test-resources/soap/soapmessage1.xml"; +    private OMFactory factory =null;
+    private OMStAXBuilder builder;
+    private SimpleOMSerializer serilizer;
+    protected void setUp() throws Exception {
+
+        factory = new OMLinkedListImplFactory();
+        XMLStreamReader reader = \
XMLInputFactory.newInstance().createXMLStreamReader(new FileReader(FILE_NAME)); +     \
builder = new OMStAXBuilder(factory,reader); +        serilizer = new \
SimpleOMSerializer(); +    }
+
+    public void testStaxBuilder(){
+
+        SOAPMessage message = builder.getSOAPMessage();
+        assertNotNull(message);
+        serilizer.serialize(message.getEnvelope(),System.out);
+
+
+    }
+
+
+
+
+}


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic