You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ch...@apache.org on 2004/12/07 10:09:17 UTC

svn commit: r110097 - in webservices/axis/trunk/java/dev/scratch/prototype2/src: java/org/apache/axis/impl/llom/factory test-resources test/org/apache/axis/om test/org/apache/axis/om/impl/builder

Author: chinthaka
Date: Tue Dec  7 01:09:15 2004
New Revision: 110097

URL: http://svn.apache.org/viewcvs?view=rev&rev=110097
Log:
Test cases for OM to be built without SOAP specifics
Added:
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/factory/OMXMLBuilderFactory.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/non_soap.xml
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/builder/
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/builder/StAXOMBuilderTest.java
Modified:
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/IteratorTester.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMTestCase.java

Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/factory/OMXMLBuilderFactory.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/factory/OMXMLBuilderFactory.java?view=auto&rev=110097
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/factory/OMXMLBuilderFactory.java	Tue Dec  7 01:09:15 2004
@@ -0,0 +1,44 @@
+package org.apache.axis.impl.llom.factory;
+
+import org.apache.axis.om.OMXMLParserWrapper;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.impl.llom.builder.StAXSOAPModelBuilder;
+import org.apache.axis.impl.llom.builder.StAXOMBuilder;
+
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * 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: Dec 7, 2004
+ * Time: 11:40:32 AM
+ */
+public class OMXMLBuilderFactory {
+    public static final String PARSER_XPP = "XPP";
+    public static final String PARSER_STAX = "StAX";
+
+    public static final String MODEL_SOAP_SPECIFIC = "SOAP_SPECIFIC";
+    public static final String MODEL_OM = "OM_ONLY";
+
+    public static StAXSOAPModelBuilder createStAXSOAPModelBuilder(OMFactory ombuilderFactory, XMLStreamReader parser){
+        return new StAXSOAPModelBuilder(ombuilderFactory, parser);
+    }
+
+    public static StAXOMBuilder createStAXOMBuilder(OMFactory ombuilderFactory, XMLStreamReader parser){
+        return new StAXOMBuilder(ombuilderFactory, parser);
+    }
+
+}

Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/non_soap.xml
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/non_soap.xml?view=auto&rev=110097
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/non_soap.xml	Tue Dec  7 01:09:15 2004
@@ -0,0 +1,34 @@
+<ns1:Root xmlns:ns1="http://www.apache.org" xmlns:ns2="http://www.opensource.lk" >
+    <ns2:developers xmlns:ns3="http://www.whatever.com">
+        <ns3:developer>
+            <name>Davanum Srinivas</name>
+            <id>dims</id>
+            <email>dims@apache.org</email>
+            <organization>Computer Associates</organization>
+        </ns3:developer>
+        <ns3:developer>
+            <name>Glen Daniels</name>
+            <id>glen</id>
+            <email>glen@thoughtcraft.com</email>
+            <organization>Sonic Software</organization>
+        </ns3:developer>
+        <ns3:developer>
+            <name>Sanjiva Weerawarana</name>
+            <id>sanjiva</id>
+            <email>sanjiva@opensource.lk</email>
+            <organization>IBM/LSF</organization>
+        </ns3:developer>
+        <ns3:developer>
+            <name>Eran Chinthaka</name>
+            <id>chinthaka</id>
+            <email>chinthaka@apache.org</email>
+            <organization>LSF/Eurocenter DDC</organization>
+        </ns3:developer>
+        <ns3:developer>
+            <name>Jaliya Ekanayake</name>
+            <id>jaliya</id>
+            <email>jaliya@opensource.lk</email>
+            <organization>Virtusa/LSF</organization>
+        </ns3:developer>
+    </ns2:developers>
+</ns1:Root>
\ No newline at end of file

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/IteratorTester.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/IteratorTester.java?view=diff&rev=110097&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/IteratorTester.java&r1=110096&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/IteratorTester.java&r2=110097
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/IteratorTester.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/IteratorTester.java	Tue Dec  7 01:09:15 2004
@@ -39,8 +39,7 @@
     }
 
     protected void setUp() throws Exception {
-		envelope = new StAXSOAPModelBuilder(XMLInputFactory.newInstance().
-                createXMLStreamReader(
+		envelope = new StAXSOAPModelBuilder(XMLInputFactory.newInstance().createXMLStreamReader(
                         new FileReader(getTestResourceFile("soap/sample1.xml")))).getOMEnvelope();
     }
 

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMTestCase.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMTestCase.java?view=diff&rev=110097&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMTestCase.java&r1=110096&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMTestCase.java&r2=110097
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMTestCase.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMTestCase.java	Tue Dec  7 01:09:15 2004
@@ -1,12 +1,12 @@
 package org.apache.axis.om;
 
-import java.io.FileReader;
-
 import org.apache.axis.AbstractTestCase;
 import org.apache.axis.impl.llom.wrapper.OMXPPWrapper;
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserFactory;
 
+import java.io.FileReader;
+
 /**
  * Copyright 2001-2004 The Apache Software Foundation.
  * <p/>
@@ -26,11 +26,11 @@
  * Date: Nov 2, 2004
  * Time: 2:15:28 PM
  */
-public class OMTestCase extends AbstractTestCase  {
+public class OMTestCase extends AbstractTestCase {
 
     protected static final String IN_FILE_NAME = "soap/soapmessage.xml";
     protected OMXPPWrapper omXmlPullParserWrapper;
-protected OMFactory ombuilderFactory;
+    protected OMFactory ombuilderFactory;
 
     protected SOAPEnvelope soapEnvelope;
 

Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/builder/StAXOMBuilderTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/builder/StAXOMBuilderTest.java?view=auto&rev=110097
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/builder/StAXOMBuilderTest.java	Tue Dec  7 01:09:15 2004
@@ -0,0 +1,77 @@
+package org.apache.axis.om.impl.builder;
+
+/**
+ * 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: Dec 7, 2004
+ * Time: 2:29:07 PM
+ */
+
+import org.apache.axis.AbstractTestCase;
+import org.apache.axis.impl.llom.factory.OMXMLBuilderFactory;
+import org.apache.axis.impl.llom.builder.StAXOMBuilder;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.OMText;
+
+import javax.xml.stream.XMLInputFactory;
+import java.io.FileReader;
+import java.util.Iterator;
+
+public class StAXOMBuilderTest extends AbstractTestCase {
+    StAXOMBuilder stAXOMBuilder;
+    FileReader testFile;
+    private OMElement rootElement;
+
+    /**
+     * Constructor.
+     */
+    public StAXOMBuilderTest(String testName) {
+        super(testName);
+    }
+
+    protected void setUp() throws Exception {
+        testFile = new FileReader(getTestResourceFile("non_soap.xml"));
+        stAXOMBuilder = OMXMLBuilderFactory.createStAXOMBuilder(OMFactory.newInstance(), XMLInputFactory.newInstance().createXMLStreamReader(testFile));
+    }
+
+    public void testGetRootElement() throws Exception {
+        rootElement = stAXOMBuilder.getRootElement();
+
+        System.out.println("Checking nullity of Root Element");
+        assertTrue("Root element can not be null", rootElement != null);
+
+        System.out.println("Checking for correct root element name");
+        assertTrue(" Name of the root element is wrong", rootElement.getLocalName().equalsIgnoreCase("Root"));
+
+        System.out.println("Checking number of children");
+        // get the first OMElement child
+        OMNode omnode = rootElement.getFirstChild();
+        while(omnode instanceof OMText){
+            omnode = omnode.getNextSibling();
+        }
+
+        Iterator children = ((OMElement)omnode).getChildren();
+        int childrenCount = 0;
+        while (children.hasNext()) {
+            OMNode node = (OMNode) children.next();
+            if(node instanceof OMElement)
+                childrenCount++;
+        }
+        assertTrue(childrenCount == 5);
+    }
+}
\ No newline at end of file