Author: ajith
Date: Thu Sep  1 20:42:42 2005
New Revision: 266249

URL: http://svn.apache.org/viewcvs?rev=266249&view=rev
Log:
1. OMElementImpl.java had the wrong implementation. Fixed it by  adding a new 
iterator and updated the test case.
2. IteratorTester.java had the wrong name.(which made it not run from it's 
inception!!!). Renamed and modified some of the tests to test the functionality 
that was not tested previously
3. Modified the WSDl2java (mistakenly checked in a commented version!)
4. Modified the InOutMEPClient.java to handle the errors

Added:
    
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/traverse/OMchildElementIterator.java
    
webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/IteratorTest.java
      - copied, changed from r265666, 
webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/IteratorTester.java
Removed:
    
webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/IteratorTester.java
Modified:
    
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/clientapi/InOutMEPClient.java
    
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl
    
webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/codegen/WSDL2JavaTest.java
    
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMElementImpl.java

Modified: 
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/clientapi/InOutMEPClient.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/clientapi/InOutMEPClient.java?rev=266249&r1=266248&r2=266249&view=diff
==============================================================================
--- 
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/clientapi/InOutMEPClient.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/clientapi/InOutMEPClient.java
 Thu Sep  1 20:42:42 2005
@@ -184,12 +184,15 @@
                 if (isExceptionToBeThrownOnSOAPFault) {
                     //does the SOAPFault has a detail element for Excpetion
                     if (ex != null) {
-//                        AxisEngine engine  = new AxisEngine(sysContext);
-//                        engine.receiveFault(response);
                         throw new AxisFault(ex);
                     } else {
-                        //if detail element not present let us throw the 
exception with Reason
-                        throw new AxisFault(soapFault.getReason().getText());
+                        //if detail element not present create a new Exception 
from the detail
+                        String message = "";
+                        message = message + "Code =" + 
soapFault.getCode()==null?"":
+                                
soapFault.getCode().getValue()==null?"":soapFault.getCode().getValue().getText();
+                        message = message + "Role = 
"+soapFault.getRole()==null?"":soapFault.getRole().getRoleValue();
+                        message = message + "Reason =" + soapFault.getReason();
+                        throw new AxisFault(message);
                     }
                 }
             }

Modified: 
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl?rev=266249&r1=266248&r2=266249&view=diff
==============================================================================
--- 
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl
 (original)
+++ 
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl
 Thu Sep  1 20:42:42 2005
@@ -17,10 +17,10 @@
             <xsl:if test="@type!=''">* @param <xsl:value-of 
select="@name"></xsl:value-of><xsl:text>

          </xsl:text></xsl:if></xsl:for-each>

          */

-        public  <xsl:if test="$outputtype=''">void</xsl:if><xsl:if 
test="$outputtype!=''"><xsl:value-of select="$outputtype"/></xsl:if><xsl:text> 
</xsl:text><xsl:value-of select="@name"/>(<xsl:for-each select="input/param">

-            <xsl:if test="@type!=''"><xsl:if 
test="position()>1">,</xsl:if><xsl:value-of select="@type"/><xsl:text> 
</xsl:text><xsl:value-of select="@name"/>

-          </xsl:if>

-         </xsl:for-each> ){

+        public  <xsl:if test="$outputtype=''">void</xsl:if><xsl:if 
test="$outputtype!=''"><xsl:value-of select="$outputtype"/></xsl:if><xsl:text> 
</xsl:text><xsl:value-of select="@name"/>

+                  (<xsl:for-each select="input/[EMAIL PROTECTED]'body']">

+            <xsl:if test="@type!=''"><xsl:if 
test="position()>1">,</xsl:if><xsl:value-of select="@type"/><xsl:text> 
</xsl:text><xsl:value-of select="@name"/></xsl:if>

+                   </xsl:for-each> ){

                 //Todo fill this with the necessary business logic

                 <xsl:if test="$outputtype!=''">return null;</xsl:if>

         }


Modified: 
webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/codegen/WSDL2JavaTest.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/codegen/WSDL2JavaTest.java?rev=266249&r1=266248&r2=266249&view=diff
==============================================================================
--- 
webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/codegen/WSDL2JavaTest.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/codegen/WSDL2JavaTest.java
 Thu Sep  1 20:42:42 2005
@@ -47,12 +47,12 @@
      */

     protected void setUp() throws Exception {

         File outputFile = new File(OUTPUT_LOCATION_BASE);

-//        if (outputFile.exists() && outputFile.isDirectory()){

-//            deleteDir(outputFile);

-//            outputFile.mkdir();

-//        }else{

-//            outputFile.mkdir();

-//        }

+        if (outputFile.exists() && outputFile.isDirectory()){

+            deleteDir(outputFile);

+            outputFile.mkdir();

+        }else{

+            outputFile.mkdir();

+        }

     }

 

     /**

@@ -60,10 +60,10 @@
      * @throws Exception

      */

     protected void tearDown() throws Exception {

-//        File outputFile = new File(OUTPUT_LOCATION_BASE);

-//        if (outputFile.exists() && outputFile.isDirectory()){

-//            deleteDir(outputFile);

-//        }

+        File outputFile = new File(OUTPUT_LOCATION_BASE);

+        if (outputFile.exists() && outputFile.isDirectory()){

+            deleteDir(outputFile);

+        }

     }

 

     /**


Modified: 
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMElementImpl.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMElementImpl.java?rev=266249&r1=266248&r2=266249&view=diff
==============================================================================
--- 
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMElementImpl.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMElementImpl.java
 Thu Sep  1 20:42:42 2005
@@ -19,6 +19,7 @@
 import org.apache.axis2.om.impl.OMOutputImpl;
 import org.apache.axis2.om.impl.llom.traverse.OMChildrenIterator;
 import org.apache.axis2.om.impl.llom.traverse.OMChildrenQNameIterator;
+import org.apache.axis2.om.impl.llom.traverse.OMChildElementIterator;
 import org.apache.axis2.om.impl.llom.util.EmptyIterator;
 import org.apache.axis2.soap.impl.llom.SOAPConstants;
 
@@ -258,11 +259,10 @@
 
     /**
      * Returns a filtered list of children - just the elements.
-     *
      * @return an iterator over the child elements
      */
     public Iterator getChildElements() {
-        return new OMChildrenIterator(getFirstChild());
+        return new OMChildElementIterator(getFirstElement());
     }
 
     /**

Added: 
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/traverse/OMchildElementIterator.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/traverse/OMchildElementIterator.java?rev=266249&view=auto
==============================================================================
--- 
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/traverse/OMchildElementIterator.java
 (added)
+++ 
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/traverse/OMchildElementIterator.java
 Thu Sep  1 20:42:42 2005
@@ -0,0 +1,120 @@
+package org.apache.axis2.om.impl.llom.traverse;

+

+import org.apache.axis2.om.OMNode;

+import org.apache.axis2.om.OMException;

+import org.apache.axis2.om.OMElement;

+

+import java.util.Iterator;

+

+/*

+ * 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.

+ */

+

+public class OMChildElementIterator implements Iterator {

+

+    /**

+     * Field currentChild

+     */

+    protected OMNode currentChild;

+

+    /**

+     * Field lastChild

+     */

+    protected OMNode lastChild;

+

+    /**

+     * Field nextCalled

+     */

+    protected boolean nextCalled = false;

+

+    /**

+     * Field removeCalled

+     */

+    protected boolean removeCalled = false;

+

+    /**

+     * Constructor OMChildrenIterator

+     *

+     * @param currentChild

+     */

+    public OMChildElementIterator(OMElement currentChild) {

+        this.currentChild = currentChild;

+    }

+

+    /**

+     * Removes from the underlying collection the last element returned by the

+     * iterator (optional operation).  This method can be called only once per

+     * call to <tt>next</tt>.  The behavior of an iterator is unspecified if

+     * the underlying collection is modified while the iteration is in

+     * progress in any way other than by calling this method.

+     *

+     * @throws UnsupportedOperationException if the <tt>remove</tt>

+     *                                       operation is not supported by 
this Iterator.

+     * @throws IllegalStateException         if the <tt>next</tt> method has 
not

+     *                                       yet been called, or the 
<tt>remove</tt> method has already

+     *                                       been called after the last call 
to the <tt>next</tt>

+     *                                       method.

+     */

+    public void remove() {

+        if (!nextCalled) {

+            throw new IllegalStateException(

+                    "next method has not yet being called");

+        }

+        if (removeCalled) {

+            throw new IllegalStateException("remove has already being called");

+        }

+        removeCalled = true;

+

+        // since this acts on the last child there is no need to mess with the 
current child

+        if (lastChild == null) {

+            throw new OMException("cannot remove a child at this stage!");

+        }

+        lastChild.detach();

+    }

+

+    /**

+     * Returns <tt>true</tt> if the iteration has more elements. (In other

+     * words, returns <tt>true</tt> if <tt>next</tt> would return an element

+     * rather than throwing an exception.)

+     *

+     * @return <tt>true</tt> if the iterator has more elements.

+     */

+    public boolean hasNext() {

+        return (currentChild != null);

+    }

+

+    /**

+     * Returns the next element in the iteration.

+     *

+     * @return the next element in the iteration.

+     * @throws java.util.NoSuchElementException

+     *          iteration has no more elements.

+     */

+    public Object next() {

+        nextCalled = true;

+        removeCalled = false;

+

+        if (hasNext()) {

+            lastChild = currentChild;

+            do{

+                currentChild = currentChild.getNextSibling();

+            }while(currentChild!=null && 
currentChild.getType()!=OMNode.ELEMENT_NODE);

+

+

+            return lastChild;

+        }

+        return null;

+    }

+}


Copied: 
webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/IteratorTest.java
 (from r265666, 
webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/IteratorTester.java)
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/IteratorTest.java?p2=webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/IteratorTest.java&p1=webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/IteratorTester.java&r1=265666&r2=266249&rev=266249&view=diff
==============================================================================
--- 
webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/IteratorTester.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/IteratorTest.java
 Thu Sep  1 20:42:42 2005
@@ -17,38 +17,81 @@
 

 import org.apache.axis2.soap.SOAPEnvelope;

 import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;

+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;

+import org.apache.axis2.om.impl.llom.factory.OMLinkedListImplFactory;

 

 import javax.xml.stream.XMLInputFactory;

+import javax.xml.namespace.QName;

 import java.io.FileReader;

 import java.util.Iterator;

 

-public class IteratorTester extends AbstractTestCase {

-    private SOAPEnvelope envelope = null;

+public class IteratorTest extends AbstractTestCase {

+    private OMElement envelope = null;

 

-    public IteratorTester(String testName) {

+    public IteratorTest(String testName) {

         super(testName);

     }

 

     protected void setUp() throws Exception {

+        //lets use a plain OM factory

         envelope =

-                new StAXSOAPModelBuilder(

+                new StAXOMBuilder(new OMLinkedListImplFactory(),

                         XMLInputFactory.newInstance().createXMLStreamReader(

                                 new FileReader(

                                         getTestResourceFile(

-                                                "soap/soapmessage1.xml"))), 
null).getSOAPEnvelope();

+                                                
"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()) {

-            assertNotNull(iter.next());

+            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);

     }

 

     /**

@@ -101,6 +144,7 @@
         }

         iter = elt.getChildren();

         if (iter.hasNext()) {

+            //we shouldn't reach here!

             fail("No children should remain after removing all!");

         }

 

@@ -120,7 +164,7 @@
             firstChildrenCount++;

         }

 

-        //this should remove the last node

+        //remove the last node

         iter.remove();

 

         //reloop and check the count



Reply via email to