Author: chinthaka
Date: Mon Sep 11 10:20:23 2006
New Revision: 442267

URL: http://svn.apache.org/viewvc?view=rev&rev=442267
Log:
Fix for http://issues.apache.org/jira/browse/WSCOMMONS-91. 

Some tests were testing whether iterators are returning null, which is 
incorrect. Fixed them as well.

Modified:
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/traverse/OMChildrenIterator.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/BadInputTest.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMTestUtils.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPFaultDetailTest.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPHeaderTest.java

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/traverse/OMChildrenIterator.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/traverse/OMChildrenIterator.java?view=diff&rev=442267&r1=442266&r2=442267
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/traverse/OMChildrenIterator.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/traverse/OMChildrenIterator.java
 Mon Sep 11 10:20:23 2006
@@ -20,6 +20,7 @@
 import org.apache.axiom.om.OMNode;

 

 import java.util.Iterator;

+import java.util.NoSuchElementException;

 

 /**

  * Class OMChildrenIterator

@@ -45,6 +46,8 @@
      */

     protected boolean removeCalled = false;

 

+    protected boolean isExceptionThrownInAdvancingToNextElement = false;

+

     /**

      * Constructor OMChildrenIterator.

      *

@@ -55,7 +58,7 @@
     }

 

     /**

-     * Removes the last element returned by the iterator (optional operation) 

+     * Removes the last element returned by the iterator (optional operation)

      * from the underlying collection.   This method must 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

@@ -90,10 +93,11 @@
      * words, returns <tt>true</tt> if <tt>next</tt> would return an element

      * rather than throwing an exception.)

      *

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

+     * @return Returns <tt>true</tt> if the iterator has more elements. This 
will never throw an exception even there is an

+     * exception thrown underneath.

      */

     public boolean hasNext() {

-        return (currentChild != null);

+        return (currentChild != null && 
!isExceptionThrownInAdvancingToNextElement);

     }

 

     /**

@@ -108,9 +112,14 @@
         removeCalled = false;

         if (hasNext()) {

             lastChild = currentChild;

-            currentChild = currentChild.getNextOMSibling();

+            try {

+                currentChild = currentChild.getNextOMSibling();

+            } catch (OMException e) {

+                isExceptionThrownInAdvancingToNextElement = true;

+            }

             return lastChild;

+        } else {

+            throw new NoSuchElementException();

         }

-        return null;

     }

 }


Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/BadInputTest.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/BadInputTest.java?view=diff&rev=442267&r1=442266&r2=442267
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/BadInputTest.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/BadInputTest.java
 Mon Sep 11 10:20:23 2006
@@ -47,7 +47,7 @@
                     (SOAPEnvelope) OMTestUtils.getOMBuilder(

                             
getTestResourceFile(TestConstants.BAD_HEADER_BODY_WRONG_ORDER))

                     .getDocumentElement();

-            OMTestUtils.walkThrough(soapEnvelope);

+            soapEnvelope.build();

             fail("this must failed gracefully with OMException or AxisFault");

         } catch (OMException e) {

             return;

@@ -92,7 +92,7 @@
                     (SOAPEnvelope) OMTestUtils.getOMBuilder(

                             getTestResourceFile(TestConstants.BAD_TWO_BODY))

                     .getDocumentElement();

-            OMTestUtils.walkThrough(soapEnvelope);

+            soapEnvelope.build();

             fail("this must failed gracefully with OMException or AxisFault");

         } catch (OMException e) {

             return;

@@ -107,7 +107,7 @@
                     (SOAPEnvelope) OMTestUtils.getOMBuilder(

                             getTestResourceFile(TestConstants.BAD_TWO_HEADERS))

                     .getDocumentElement();

-            OMTestUtils.walkThrough(soapEnvelope);

+            soapEnvelope.build();

             fail("this must failed gracefully with OMException or AxisFault");

         } catch (OMException e) {

             return;


Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMTestUtils.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMTestUtils.java?view=diff&rev=442267&r1=442266&r2=442267
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMTestUtils.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMTestUtils.java
 Mon Sep 11 10:20:23 2006
@@ -17,13 +17,9 @@
 package org.apache.axiom.om;

 

 import junit.framework.TestCase;

-import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;

 import org.apache.axiom.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 org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;

+import org.w3c.dom.*;

 

 import javax.xml.stream.XMLInputFactory;

 import javax.xml.stream.XMLStreamReader;

@@ -35,8 +31,7 @@
     public static OMXMLParserWrapper getOMBuilder(File file) throws Exception {

         XMLStreamReader parser = XMLInputFactory.newInstance()

                 .createXMLStreamReader(new FileReader(file));

-        return OMXMLBuilderFactory.createStAXSOAPModelBuilder(

-                OMAbstractFactory.getSOAP11Factory(), parser);

+        return new StAXSOAPModelBuilder(parser, null);

     }

 

     public static void walkThrough(OMElement omEle) {


Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPFaultDetailTest.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPFaultDetailTest.java?view=diff&rev=442267&r1=442266&r2=442267
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPFaultDetailTest.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPFaultDetailTest.java
 Mon Sep 11 10:20:23 2006
@@ -74,14 +74,14 @@
                         "http://www.test.org";));

         assertTrue(

                 "SOAP 1.1 Fault Detail Test : - After calling addDetailEntry 
method twice, getAllDetailEntries method returns an iterator with three 
objects",

-                iterator.next() == null);

+                !iterator.hasNext());

     }

 

     public void testSOAP11GetAllDetailEntries() {

         Iterator iterator = soap11FaultDetail.getAllDetailEntries();

         assertTrue(

                 "SOAP 1.1 Fault Detail Test : - After creating 
SOAP11FaultDetail element, it has DetailEntries",

-                iterator.next() == null);

+                !iterator.hasNext());

         soap11FaultDetail.addDetailEntry(

                 omFactory.createOMElement("DetailEntry", omNamespace));

         iterator = soap11FaultDetail.getAllDetailEntries();

@@ -98,7 +98,7 @@
                         "http://www.test.org";));

         assertTrue(

                 "SOAP 1.1 Fault Detail Test : - After calling addDetailEntry 
method once, getAllDetailEntries method returns an iterator with two objects",

-                iterator.next() == null);

+                !iterator.hasNext());

     }

 

     //SOAP 1.2 Fault Detail Test (Programaticaly Created)

@@ -132,14 +132,14 @@
                         "http://www.test.org";));

         assertTrue(

                 "SOAP 1.2 Fault Detail Test : - After calling addDetailEntry 
method twice, getAllDetailEntries method returns an iterator with three 
objects",

-                iterator.next() == null);

+                !iterator.hasNext());

     }

 

     public void testSOAP12GetAllDetailEntries() {

         Iterator iterator = soap12FaultDetail.getAllDetailEntries();

         assertTrue(

                 "SOAP 1.2 Fault Detail Test : - After creating 
SOAP11FaultDetail element, it has DetailEntries",

-                iterator.next() == null);

+                !iterator.hasNext());

         soap12FaultDetail.addDetailEntry(

                 omFactory.createOMElement("DetailEntry", omNamespace));

         iterator = soap12FaultDetail.getAllDetailEntries();

@@ -156,7 +156,7 @@
                         "http://www.test.org";));

         assertTrue(

                 "SOAP 1.2 Fault Detail Test : - After calling addDetailEntry 
method once, getAllDetailEntries method returns an iterator with two objects",

-                iterator.next() == null);

+                !iterator.hasNext());

     }

 

     //SOAP 1.1 Fault Detail Test (With Parser)

@@ -187,7 +187,7 @@
         iterator.next();

         assertTrue(

                 "SOAP 1.1 Fault Detail Test With Parser : - 
getAllDetailEntries method returns an itrator with more than two detail 
entries",

-                iterator.next() == null);

+                !iterator.hasNext());

     }

 

     //SOAP 1.2 Fault Detail Test (With Parser)

@@ -218,6 +218,6 @@
         iterator.next();

         assertTrue(

                 "SOAP 1.2 Fault Detail Test With Parser : - 
getAllDetailEntries method returns an itrator with more than two detail 
entries",

-                iterator.next() == null);

+                !iterator.hasNext());

     }

 }


Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPHeaderTest.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPHeaderTest.java?view=diff&rev=442267&r1=442266&r2=442267
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPHeaderTest.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPHeaderTest.java
 Mon Sep 11 10:20:23 2006
@@ -59,7 +59,7 @@
 

         assertTrue(

                 "SOAP 1.1 Header Test : - After calling addHeaderBlock method 
twice, getChildren method returns an iterator with more than two object",

-                iterator.next() == null);

+                !iterator.hasNext());

     }

 

     public void testSOAP11ExamineHeaderBlocks() {

@@ -90,7 +90,6 @@
 //    }

 

 

-

     public void testSOAP11ExamineAllHeaderBlocks() {

         soap11Header.addHeaderBlock("echoOk1", namespace);

         soap11Header.addHeaderBlock("echoOk2", namespace);

@@ -142,7 +141,7 @@
         assertTrue(

                 "SOAP 1.1 Header Test : - headerBlock of given namespace uri 
mismatch",

                 ((SOAPHeaderBlock) 
arrayList.get(0)).getNamespace().getNamespaceURI()

-                .equals("http://www.test1.org";));

+                        .equals("http://www.test1.org";));

     }

 

     //SOAP 1.2 Header Test (Programaticaly 
Created)----------------------------------------------------------------------------------

@@ -174,7 +173,7 @@
 

         assertTrue(

                 "SOAP 1.2 Header Test : - After calling addHeaderBlock method 
twice, getChildren method returns an iterator with more than two elements",

-                iterator.next() == null);

+                !iterator.hasNext());

     }

 

     public void testSOAP12ExamineHeaderBlocks() {

@@ -277,7 +276,7 @@
         assertTrue(

                 "SOAP 1.2 Header Test : - headerBlock of given namespace uri, 
mismatch",

                 ((SOAPHeaderBlock) 
arrayList.get(0)).getNamespace().getNamespaceURI()

-                .equals("http://www.test1.org";));

+                        .equals("http://www.test1.org";));

     }

 

     //SOAP 1.1 Header Test (With 
Parser)---------------------------------------------------------------------------------------------

@@ -363,7 +362,7 @@
         assertTrue(

                 "SOAP 1.1 Header Test With Parser : - headerBlock of given 
namespace uri, mismatch",

                 ((SOAPHeaderBlock) 
arrayList.get(0)).getNamespace().getNamespaceURI()

-                .equals("http://example.org/ts-tests";));

+                        .equals("http://example.org/ts-tests";));

     }

 

     //SOAP 1.2 Header Test (With 
Parser)-------------------------------------------------------------------------------------------

@@ -460,6 +459,6 @@
         assertTrue(

                 "SOAP 1.2 Header Test With Parser : - headerBlock of given 
namespace uri, mismatch",

                 ((SOAPHeaderBlock) 
arrayList.get(0)).getNamespace().getNamespaceURI()

-                .equals("http://example.org/ts-tests";));

+                        .equals("http://example.org/ts-tests";));

     }

 }




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to