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 ve...@apache.org on 2010/03/13 20:24:57 UTC

svn commit: r922656 - in /webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom: om/ om/ds/ om/impl/serializer/ soap/ soap/impl/llom/

Author: veithen
Date: Sat Mar 13 19:24:56 2010
New Revision: 922656

URL: http://svn.apache.org/viewvc?rev=922656&view=rev
Log:
Eliminated some instances of the catch-and-fail JUnit antipattern. No changes to the test logic.

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/AbstractOMSerializationTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/AttrNsTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/DefaultNSHandlingTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/NamespaceTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMBodyTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMWrapperTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/SpacesTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/ds/ParserInputStreamDataSourceTests.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/serializer/OMSerializerTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAP11FaultImplConversionTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAP12FaultTestBase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/impl/llom/OMEnvelopeTest.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/AbstractOMSerializationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/AbstractOMSerializationTest.java?rev=922656&r1=922655&r2=922656&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/AbstractOMSerializationTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/AbstractOMSerializationTest.java Sat Mar 13 19:24:56 2010
@@ -89,41 +89,26 @@ public abstract class AbstractOMSerializ
     }
 
     public Diff getDiffForComparison(InputStream inStream) throws Exception {
+        StAXOMBuilder staxOMBuilder = OMXMLBuilderFactory.
+                createStAXOMBuilder(OMAbstractFactory.getOMFactory(),
+                                    StAXUtils.createXMLStreamReader(inStream));
+        OMElement rootElement = staxOMBuilder.getDocumentElement();
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+        if (ignoreDocument) {
+            rootElement.serialize(baos);
+        } else {
+            ((OMDocument) rootElement.getParent()).serialize(baos);
+        }
 
-        try {
-            StAXOMBuilder staxOMBuilder = OMXMLBuilderFactory.
-                    createStAXOMBuilder(OMAbstractFactory.getOMFactory(),
-                                        StAXUtils.createXMLStreamReader(inStream));
-            OMElement rootElement = staxOMBuilder.getDocumentElement();
+        InputSource resultXML = new InputSource(new InputStreamReader(
+                new ByteArrayInputStream(baos.toByteArray())));
 
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        Document dom2 = newDocument(resultXML);
+        Document dom1 = newDocument(inStream);
 
-            if (ignoreDocument) {
-                rootElement.serialize(baos);
-            } else {
-                ((OMDocument) rootElement.getParent()).serialize(baos);
-            }
-
-            InputSource resultXML = new InputSource(new InputStreamReader(
-                    new ByteArrayInputStream(baos.toByteArray())));
-
-            Document dom2 = newDocument(resultXML);
-            Document dom1 = newDocument(inStream);
-
-            return compareXML(dom1, dom2);
-        } 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);
-        }
+        return compareXML(dom1, dom2);
     }
 
     public Document newDocument(InputSource in)

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/AttrNsTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/AttrNsTest.java?rev=922656&r1=922655&r2=922656&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/AttrNsTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/AttrNsTest.java Sat Mar 13 19:24:56 2010
@@ -99,75 +99,56 @@ public class AttrNsTest extends Abstract
                      attr.getNamespace().getNamespaceURI());
     }
 
-    public void testAttributesWithProgrammaticalCreation() {
-
-        try {
-            String expectedXML =
-                    "<AttributeTester xmlns=\"\" xmlns:myAttr2NS=\"http://test-attributes-2.org\" " +
-                            "xmlns:myAttr1NS=\"http://test-attributes-1.org\" myAttr2NS:attrNumber=\"2\" myAttr1NS:attrNumber=\"1\" />";
-
-            OMFactory omFactory = OMAbstractFactory.getOMFactory();
-
-            OMNamespace attrNS1 =
-                    omFactory.createOMNamespace("http://test-attributes-1.org", "myAttr1NS");
-            OMNamespace attrNS2 =
-                    omFactory.createOMNamespace("http://test-attributes-2.org", "myAttr2NS");
-            OMElement omElement = omFactory.createOMElement("AttributeTester", null);
-            omElement.addAttribute(omFactory.createOMAttribute("attrNumber", attrNS1, "1"));
-            omElement.addAttribute(omFactory.createOMAttribute("attrNumber", attrNS2, "2"));
-
-            int nsCount = 0;
-            for (Iterator iterator = omElement.getAllDeclaredNamespaces(); iterator.hasNext();) {
-                iterator.next();
-                nsCount++;
-            }
-            assertTrue(nsCount == 2);
-
-            Document document1 = newDocument(expectedXML);
-            Document document2 = newDocument(omElement.toString());
-
-            Diff diff = compareXML(document1, document2);
-            assertXMLEqual(diff, true);
-        } catch (ParserConfigurationException e) {
-            fail(e.getMessage());
-        } catch (SAXException e) {
-            fail(e.getMessage());
-        } catch (IOException e) {
-            fail(e.getMessage());
+    public void testAttributesWithProgrammaticalCreation() throws Exception {
+        String expectedXML =
+                "<AttributeTester xmlns=\"\" xmlns:myAttr2NS=\"http://test-attributes-2.org\" " +
+                        "xmlns:myAttr1NS=\"http://test-attributes-1.org\" myAttr2NS:attrNumber=\"2\" myAttr1NS:attrNumber=\"1\" />";
+
+        OMFactory omFactory = OMAbstractFactory.getOMFactory();
+
+        OMNamespace attrNS1 =
+                omFactory.createOMNamespace("http://test-attributes-1.org", "myAttr1NS");
+        OMNamespace attrNS2 =
+                omFactory.createOMNamespace("http://test-attributes-2.org", "myAttr2NS");
+        OMElement omElement = omFactory.createOMElement("AttributeTester", null);
+        omElement.addAttribute(omFactory.createOMAttribute("attrNumber", attrNS1, "1"));
+        omElement.addAttribute(omFactory.createOMAttribute("attrNumber", attrNS2, "2"));
+
+        int nsCount = 0;
+        for (Iterator iterator = omElement.getAllDeclaredNamespaces(); iterator.hasNext();) {
+            iterator.next();
+            nsCount++;
         }
+        assertTrue(nsCount == 2);
+
+        Document document1 = newDocument(expectedXML);
+        Document document2 = newDocument(omElement.toString());
+
+        Diff diff = compareXML(document1, document2);
+        assertXMLEqual(diff, true);
     }
 
 
-    public void testAttributesWithNamespaceSerialization() {
-        try {
-            String xmlString =
-                    "<root xmlns='http://custom.com'><node cust:id='123' xmlns:cust='http://custom.com' /></root>";
-            XMLStreamReader xmlStreamReader = StAXUtils.createXMLStreamReader(
-                    new StringReader(xmlString));
-
-            // copied code from the generated stub class toOM method
-            org.apache.axiom.om.impl.builder.StAXOMBuilder builder =
-                    new org.apache.axiom.om.impl.builder.StAXOMBuilder(xmlStreamReader);
-            org.apache.axiom.om.OMElement documentElement = builder
-                    .getDocumentElement();
-
-            ((org.apache.axiom.om.impl.OMNodeEx) documentElement).setParent(null);
-            // end copied code
-
-            // now print the object after it has been processed
-            System.out.println("after - '" + documentElement.toString() + "'");
-            Document document1 = newDocument(xmlString);
-            Document document2 = newDocument(documentElement.toString());
-            Diff diff = compareXML(document1, document2);
-            assertXMLEqual(diff, true);
-        } catch (ParserConfigurationException e) {
-            fail(e.getMessage());
-        } catch (SAXException e) {
-            fail(e.getMessage());
-        } catch (IOException e) {
-            fail(e.getMessage());
-        } catch (javax.xml.stream.XMLStreamException e) {
-            fail(e.getMessage());
-        }
+    public void testAttributesWithNamespaceSerialization() throws Exception {
+        String xmlString =
+                "<root xmlns='http://custom.com'><node cust:id='123' xmlns:cust='http://custom.com' /></root>";
+        XMLStreamReader xmlStreamReader = StAXUtils.createXMLStreamReader(
+                new StringReader(xmlString));
+
+        // copied code from the generated stub class toOM method
+        org.apache.axiom.om.impl.builder.StAXOMBuilder builder =
+                new org.apache.axiom.om.impl.builder.StAXOMBuilder(xmlStreamReader);
+        org.apache.axiom.om.OMElement documentElement = builder
+                .getDocumentElement();
+
+        ((org.apache.axiom.om.impl.OMNodeEx) documentElement).setParent(null);
+        // end copied code
+
+        // now print the object after it has been processed
+        System.out.println("after - '" + documentElement.toString() + "'");
+        Document document1 = newDocument(xmlString);
+        Document document2 = newDocument(documentElement.toString());
+        Diff diff = compareXML(document1, document2);
+        assertXMLEqual(diff, true);
     }
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/DefaultNSHandlingTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/DefaultNSHandlingTest.java?rev=922656&r1=922655&r2=922656&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/DefaultNSHandlingTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/DefaultNSHandlingTest.java Sat Mar 13 19:24:56 2010
@@ -90,62 +90,54 @@ public class DefaultNSHandlingTest exten
         assertTrue("".equals(omElementTwoChild.getNamespace().getNamespaceURI()));
     }
 
-    public void testChildReDeclaringParentsDefaultNSWithPrefix() {
-        try {
-            OMFactory fac = OMAbstractFactory.getOMFactory();
-            OMElement elem = fac.createOMElement("RequestSecurityToken", null);
-            elem.declareDefaultNamespace("http://schemas.xmlsoap.org/ws/2005/02/trust");
-            fac.createOMElement(new QName("TokenType"), elem).setText("test");
-            fac.createOMElement(new QName("RequestType"), elem).setText("test1");
-
-            fac.createOMElement(
-                    new QName("http://schemas.xmlsoap.org/ws/2005/02/trust", "Entropy", "wst"),
-                    elem);
-            String xml = elem.toString();
-
-            XMLStreamReader reader = StAXUtils.createXMLStreamReader(
-                    new ByteArrayInputStream(xml.getBytes()));
-
-            StAXOMBuilder builder = new StAXOMBuilder(reader);
-            builder.getDocumentElement().build();
-
-            // The StAX implementation may or may not have a trailing blank in the tag
-            String assertText1 =
-                    "<wst:Entropy xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\" />";
-            String assertText2 =
-                    "<wst:Entropy xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\"/>";
-            String assertText3 =
-                    "<wst:Entropy xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\"></wst:Entropy>";
-
-            assertTrue((xml.indexOf(assertText1) != -1) ||
-                    (xml.indexOf(assertText2) != -1) ||
-                    (xml.indexOf(assertText3) != -1));
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
+    public void testChildReDeclaringParentsDefaultNSWithPrefix() throws Exception {
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMElement elem = fac.createOMElement("RequestSecurityToken", null);
+        elem.declareDefaultNamespace("http://schemas.xmlsoap.org/ws/2005/02/trust");
+        fac.createOMElement(new QName("TokenType"), elem).setText("test");
+        fac.createOMElement(new QName("RequestType"), elem).setText("test1");
+
+        fac.createOMElement(
+                new QName("http://schemas.xmlsoap.org/ws/2005/02/trust", "Entropy", "wst"),
+                elem);
+        String xml = elem.toString();
+
+        XMLStreamReader reader = StAXUtils.createXMLStreamReader(
+                new ByteArrayInputStream(xml.getBytes()));
+
+        StAXOMBuilder builder = new StAXOMBuilder(reader);
+        builder.getDocumentElement().build();
+
+        // The StAX implementation may or may not have a trailing blank in the tag
+        String assertText1 =
+                "<wst:Entropy xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\" />";
+        String assertText2 =
+                "<wst:Entropy xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\"/>";
+        String assertText3 =
+                "<wst:Entropy xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\"></wst:Entropy>";
+
+        assertTrue((xml.indexOf(assertText1) != -1) ||
+                (xml.indexOf(assertText2) != -1) ||
+                (xml.indexOf(assertText3) != -1));
     }
 
     public void testChildReDeclaringGrandParentsDefaultNSWithPrefix() {
-        try {
-            OMFactory fac = OMAbstractFactory.getOMFactory();
-            OMElement elem = fac.createOMElement("RequestSecurityToken", null);
-            elem.declareDefaultNamespace("http://schemas.xmlsoap.org/ws/2005/02/trust");
-            fac.createOMElement(new QName("TokenType"), elem).setText("test");
-            fac.createOMElement(new QName("RequestType"), elem).setText("test1");
-
-            OMElement entElem = fac.createOMElement(
-                    new QName("http://schemas.xmlsoap.org/ws/2005/02/trust", "Entropy", "wst"),
-                    elem);
-            OMElement binSecElem = fac.createOMElement(
-                    new QName("http://schemas.xmlsoap.org/ws/2005/02/trust", "Binarysecret", "wst"),
-                    entElem);
-            binSecElem.setText("secret value");
-            String xml = elem.toString();
-            assertTrue("Binarysecret element should have \'wst\' ns prefix",
-                       xml.indexOf("<wst:Binarysecret") != -1);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMElement elem = fac.createOMElement("RequestSecurityToken", null);
+        elem.declareDefaultNamespace("http://schemas.xmlsoap.org/ws/2005/02/trust");
+        fac.createOMElement(new QName("TokenType"), elem).setText("test");
+        fac.createOMElement(new QName("RequestType"), elem).setText("test1");
+
+        OMElement entElem = fac.createOMElement(
+                new QName("http://schemas.xmlsoap.org/ws/2005/02/trust", "Entropy", "wst"),
+                elem);
+        OMElement binSecElem = fac.createOMElement(
+                new QName("http://schemas.xmlsoap.org/ws/2005/02/trust", "Binarysecret", "wst"),
+                entElem);
+        binSecElem.setText("secret value");
+        String xml = elem.toString();
+        assertTrue("Binarysecret element should have \'wst\' ns prefix",
+                   xml.indexOf("<wst:Binarysecret") != -1);
     }
 
 //    public void testForIssueWSCOMMONS119() {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/NamespaceTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/NamespaceTest.java?rev=922656&r1=922655&r2=922656&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/NamespaceTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/NamespaceTest.java Sat Mar 13 19:24:56 2010
@@ -240,7 +240,7 @@ public class NamespaceTest extends XMLTe
     /**
      * This is re-producing and testing the bug mentioned in http://issues.apache.org/jira/browse/WSCOMMONS-74
      */
-    public void testNamespaceProblem7() {
+    public void testNamespaceProblem7() throws Exception {
 
         String expectedString = "<person xmlns=\"http://ws.apache.org/axis2/apacheconasia/06\">" +
                 "<name>John</name>" +
@@ -269,17 +269,13 @@ public class NamespaceTest extends XMLTe
         String result = personElem.toString();
 
 
-        try {
-            assertXMLEqual(expectedString, result);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
+        assertXMLEqual(expectedString, result);
     }
 
     /**
      * This is re-producing and testing the bug mentioned in http://issues.apache.org/jira/browse/WSCOMMONS-74
      */
-    public void testNamespaceProblem8() {
+    public void testNamespaceProblem8() throws Exception {
 
         String expectedXML =
                 "<person xmlns=\"http://ws.apache.org/axis2/apacheconasia/06\"><name xmlns=\"\">John</name><age>34</age><weight>50</weight></person>";
@@ -301,12 +297,7 @@ public class NamespaceTest extends XMLTe
         personElem.addChild(ageElem);
         personElem.addChild(weightElem);
 
-        try {
-            assertXMLEqual(expectedXML, personElem.toString());
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-
+        assertXMLEqual(expectedXML, personElem.toString());
     }
 
     public void testOMElementSerialize() throws Exception {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMBodyTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMBodyTest.java?rev=922656&r1=922655&r2=922656&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMBodyTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMBodyTest.java Sat Mar 13 19:24:56 2010
@@ -47,14 +47,9 @@ public class OMBodyTest extends OMTestCa
      */
     public void testAddFault() {
         log.debug("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());
-        }
+        soapBody.addChild(
+                soapFactory.createSOAPFault(soapBody,
+                                            new Exception("Testing soap fault")));
         log.debug("\t checking for SOAP Fault ...");
         assertTrue("SOAP body has no SOAP fault", soapBody.hasFault());
         log.debug("\t checking for not-nullity ...");

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMWrapperTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMWrapperTest.java?rev=922656&r1=922655&r2=922656&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMWrapperTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMWrapperTest.java Sat Mar 13 19:24:56 2010
@@ -24,77 +24,70 @@ import org.apache.axiom.om.impl.builder.
 import org.apache.axiom.om.impl.llom.OMStAXWrapper;
 import org.apache.axiom.om.util.StAXUtils;
 
-import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import java.io.StringReader;
 
 public class OMWrapperTest extends TestCase {
 
-    public void testSingleElementWrapper() {
-        try {
-            String xml = "<root>" +
-                    "<wrap1>" +
-                    "<wrap3>" +
-                    "<wrap2>" +
-                    "IncludedText" +
-                    "</wrap2>" +
-                    "</wrap3>" +
-                    "</wrap1>" +
-                    "</root>";
-
-            XMLStreamReader xmlStreamReader =
-                    StAXUtils.createXMLStreamReader(new StringReader(xml));
-            StAXOMBuilder b = new StAXOMBuilder(xmlStreamReader);
-
-            OMElement documentElement = b.getDocumentElement();
-            OMElement wrap2Element =
-                    documentElement.getFirstElement().
-                            getFirstElement().
-                            getFirstElement();
-
-            OMElement elt = OMAbstractFactory.getOMFactory().createOMElement(
-                    "testName", "urn:testNs", "ns1"
-            );
-
-            elt.addChild(wrap2Element);
-
-
-            XMLStreamReader reader = wrap2Element.getXMLStreamReaderWithoutCaching();
-            
-            // Make sure the reader is an OMStAXWrapper
-            if (reader instanceof OMStAXWrapper) {
-                OMStAXWrapper wrapper = (OMStAXWrapper) reader;
-                assertTrue(!wrapper.isClosed());
-                wrapper.releaseParserOnClose(true);
-            }
-            
-            int count = 0;
-            while (reader.hasNext()) {
-                reader.next();
-                count ++;
-            }
-
-            assertEquals(3, count);
-            
-            
-            // Make sure that the wrapper can be closed without failing
-            reader.close();
-            reader.close();  // This should be a noop since the parser is closed.
-            
-            // Closing the parser should also close the parser on the builder (since they are the same)
-            assertTrue(b.isClosed());
-            b.close(); // This should be a noop since the parser is closed
-            
-            // Calling getProperty after a close should return null, not an exception
-            assertTrue(reader.getProperty("dummyProperty") == null);
-            
-            // Calling builder.getReaderProperty should return null, not an exception
-            assertTrue(b.getReaderProperty("dummyProperty") == null);
-        } catch (XMLStreamException e) {
-            fail(e.getMessage());
+    public void testSingleElementWrapper() throws Exception {
+        String xml = "<root>" +
+                "<wrap1>" +
+                "<wrap3>" +
+                "<wrap2>" +
+                "IncludedText" +
+                "</wrap2>" +
+                "</wrap3>" +
+                "</wrap1>" +
+                "</root>";
+
+        XMLStreamReader xmlStreamReader =
+                StAXUtils.createXMLStreamReader(new StringReader(xml));
+        StAXOMBuilder b = new StAXOMBuilder(xmlStreamReader);
+
+        OMElement documentElement = b.getDocumentElement();
+        OMElement wrap2Element =
+                documentElement.getFirstElement().
+                        getFirstElement().
+                        getFirstElement();
+
+        OMElement elt = OMAbstractFactory.getOMFactory().createOMElement(
+                "testName", "urn:testNs", "ns1"
+        );
+
+        elt.addChild(wrap2Element);
+
+
+        XMLStreamReader reader = wrap2Element.getXMLStreamReaderWithoutCaching();
+        
+        // Make sure the reader is an OMStAXWrapper
+        if (reader instanceof OMStAXWrapper) {
+            OMStAXWrapper wrapper = (OMStAXWrapper) reader;
+            assertTrue(!wrapper.isClosed());
+            wrapper.releaseParserOnClose(true);
+        }
+        
+        int count = 0;
+        while (reader.hasNext()) {
+            reader.next();
+            count ++;
         }
 
-
+        assertEquals(3, count);
+        
+        
+        // Make sure that the wrapper can be closed without failing
+        reader.close();
+        reader.close();  // This should be a noop since the parser is closed.
+        
+        // Closing the parser should also close the parser on the builder (since they are the same)
+        assertTrue(b.isClosed());
+        b.close(); // This should be a noop since the parser is closed
+        
+        // Calling getProperty after a close should return null, not an exception
+        assertTrue(reader.getProperty("dummyProperty") == null);
+        
+        // Calling builder.getReaderProperty should return null, not an exception
+        assertTrue(b.getReaderProperty("dummyProperty") == null);
     }
 
 

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/SpacesTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/SpacesTest.java?rev=922656&r1=922655&r2=922656&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/SpacesTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/SpacesTest.java Sat Mar 13 19:24:56 2010
@@ -30,7 +30,6 @@ import org.xml.sax.SAXException;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.stream.XMLStreamException;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -51,39 +50,25 @@ public class SpacesTest extends Abstract
     }
 
     private void checkOMConformance(InputStream iStream) throws Exception {
-        try {
-            StAXOMBuilder staxOMBuilder = OMXMLBuilderFactory.
-                    createStAXOMBuilder(OMAbstractFactory.getOMFactory(),
-                                        StAXUtils.createXMLStreamReader(
-                                                iStream));
-            rootElement = staxOMBuilder.getDocumentElement();
-            boolean hasCDataNode = hasCDataNode(rootElement);
-            String file = hasCDataNode ? filePath : filePath2;
-
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            ((OMDocument) rootElement.getParent()).serialize(baos);
-
-            InputSource resultXML = new InputSource(new InputStreamReader(
-                    new ByteArrayInputStream(baos.toByteArray())));
-
-            Document dom1 = newDocument(new InputSource(getTestResource(file)));
-            Document dom2 = newDocument(resultXML);
-            Diff diff = compareXML(dom1, dom2);
-            assertXMLEqual(diff, true);
-            rootElement.close(false);
-        } 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);
-        }
+        StAXOMBuilder staxOMBuilder = OMXMLBuilderFactory.
+                createStAXOMBuilder(OMAbstractFactory.getOMFactory(),
+                                    StAXUtils.createXMLStreamReader(
+                                            iStream));
+        rootElement = staxOMBuilder.getDocumentElement();
+        boolean hasCDataNode = hasCDataNode(rootElement);
+        String file = hasCDataNode ? filePath : filePath2;
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ((OMDocument) rootElement.getParent()).serialize(baos);
+
+        InputSource resultXML = new InputSource(new InputStreamReader(
+                new ByteArrayInputStream(baos.toByteArray())));
+
+        Document dom1 = newDocument(new InputSource(getTestResource(file)));
+        Document dom2 = newDocument(resultXML);
+        Diff diff = compareXML(dom1, dom2);
+        assertXMLEqual(diff, true);
+        rootElement.close(false);
     }
 
     private boolean hasCDataNode(OMNode pNode) {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/ds/ParserInputStreamDataSourceTests.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/ds/ParserInputStreamDataSourceTests.java?rev=922656&r1=922655&r2=922656&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/ds/ParserInputStreamDataSourceTests.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/ds/ParserInputStreamDataSourceTests.java Sat Mar 13 19:24:56 2010
@@ -75,56 +75,40 @@ public class ParserInputStreamDataSource
 	
 	
 	
-	public void testCreateParserInputStreamDataSource(){
-		try{
-			ParserInputStreamDataSource peds = createPeds();
-			assertNotNull(peds);
-		}catch(Exception e){
-			fail(e.getMessage());
-		}
+	public void testCreateParserInputStreamDataSource() throws Exception {
+		ParserInputStreamDataSource peds = createPeds();
+		assertNotNull(peds);
 	}
 	
-	public void testParserInputStreamDataSourceSerialize(){
-		try{
-			ParserInputStreamDataSource peds = createPeds();
-			//lets test Serialze() call.
-			ByteArrayOutputStream output = new ByteArrayOutputStream();
-			peds.serialize(output, null);
-			String str = new String(output.toByteArray());
-			assertNotNull(str);
-			assertEquals(str, "<invokeOp>Hello Provider OM</invokeOp>");
-		}catch(Exception e){
-			fail(e.getMessage());
-		}
+	public void testParserInputStreamDataSourceSerialize() throws Exception {
+		ParserInputStreamDataSource peds = createPeds();
+		//lets test Serialze() call.
+		ByteArrayOutputStream output = new ByteArrayOutputStream();
+		peds.serialize(output, null);
+		String str = new String(output.toByteArray());
+		assertNotNull(str);
+		assertEquals(str, "<invokeOp>Hello Provider OM</invokeOp>");
 	}
 	
-	public void testParserInputStreamDataSourceSerializeWithWriter(){
-		try{
-			ParserInputStreamDataSource peds = createPeds();
-			//lets test Serialze() call.
-			ByteArrayOutputStream output = new ByteArrayOutputStream();
-			XMLStreamWriter writer = StAXUtils.createXMLStreamWriter(output);
-			peds.serialize(writer);
-			String str = new String(output.toByteArray());
-			assertNotNull(str);
-			assertEquals(str, "<invokeOp>Hello Provider OM</invokeOp>");
-		}catch(Exception e){
-			fail(e.getMessage());
-		}
+	public void testParserInputStreamDataSourceSerializeWithWriter() throws Exception {
+		ParserInputStreamDataSource peds = createPeds();
+		//lets test Serialze() call.
+		ByteArrayOutputStream output = new ByteArrayOutputStream();
+		XMLStreamWriter writer = StAXUtils.createXMLStreamWriter(output);
+		peds.serialize(writer);
+		String str = new String(output.toByteArray());
+		assertNotNull(str);
+		assertEquals(str, "<invokeOp>Hello Provider OM</invokeOp>");
 	}
 	
-	public void testParserInputStreamDataSourceGetXMLBytes(){
-		try{
-			ParserInputStreamDataSource peds = createPeds();
-			
-			//lets test getXMLBytes().
-			byte[] bytes = peds.getXMLBytes("UTF-8");
-			String str = new String(bytes);
-			assertNotNull(bytes);
-			assertEquals(str, "<invokeOp>Hello Provider OM</invokeOp>");
-		}catch(Exception e){
-			fail(e.getMessage());
-		}
+	public void testParserInputStreamDataSourceGetXMLBytes() throws Exception {
+		ParserInputStreamDataSource peds = createPeds();
+		
+		//lets test getXMLBytes().
+		byte[] bytes = peds.getXMLBytes("UTF-8");
+		String str = new String(bytes);
+		assertNotNull(bytes);
+		assertEquals(str, "<invokeOp>Hello Provider OM</invokeOp>");
 	}
 	
 	private void updatePedsDataWithMockInputStream(ParserInputStreamDataSource peds) throws Exception{

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/serializer/OMSerializerTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/serializer/OMSerializerTest.java?rev=922656&r1=922655&r2=922656&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/serializer/OMSerializerTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/serializer/OMSerializerTest.java Sat Mar 13 19:24:56 2010
@@ -310,15 +310,10 @@ public class OMSerializerTest extends Ab
                 !omse.isExpanded());
     }
 
-    public void testDefaultNsSerialization() {
-        try {
-            StAXOMBuilder builder = new StAXOMBuilder(getTestResource("original.xml"));
-            String xml = builder.getDocumentElement().toString();
-            assertEquals("There shouldn't be any xmlns=\"\"", -1, xml.indexOf("xmlns=\"\""));
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail(e.getMessage());
-        }
+    public void testDefaultNsSerialization() throws Exception {
+        StAXOMBuilder builder = new StAXOMBuilder(getTestResource("original.xml"));
+        String xml = builder.getDocumentElement().toString();
+        assertEquals("There shouldn't be any xmlns=\"\"", -1, xml.indexOf("xmlns=\"\""));
     }
     
     public void testXSITypePullStream() throws Exception {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAP11FaultImplConversionTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAP11FaultImplConversionTest.java?rev=922656&r1=922655&r2=922656&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAP11FaultImplConversionTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAP11FaultImplConversionTest.java Sat Mar 13 19:24:56 2010
@@ -31,26 +31,21 @@ public class SOAP11FaultImplConversionTe
 
     private String soap11FaulXmlPath = "soap/soap11/soapfault2.xml";
 
-    public void testConversion() {
-        try {
-            InputStream is = getTestResource(soap11FaulXmlPath);
-            XMLStreamReader reader = StAXUtils.createXMLStreamReader(is);
+    public void testConversion() throws Exception {
+        InputStream is = getTestResource(soap11FaulXmlPath);
+        XMLStreamReader reader = StAXUtils.createXMLStreamReader(is);
 
-            SOAPEnvelope env = new StAXSOAPModelBuilder(reader, null).getSOAPEnvelope();
+        SOAPEnvelope env = new StAXSOAPModelBuilder(reader, null).getSOAPEnvelope();
 
-            env.build();
+        env.build();
 
-            SOAPEnvelope env2 =
-                    new StAXSOAPModelBuilder(env.getXMLStreamReader(), null).getSOAPEnvelope();
+        SOAPEnvelope env2 =
+                new StAXSOAPModelBuilder(env.getXMLStreamReader(), null).getSOAPEnvelope();
 
-            env2.build();
+        env2.build();
 
-            env2.toString();
+        env2.toString();
 
-            //System.out.println(env2);
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail(e.getMessage());
-        }
+        //System.out.println(env2);
     }
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAP12FaultTestBase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAP12FaultTestBase.java?rev=922656&r1=922655&r2=922656&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAP12FaultTestBase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAP12FaultTestBase.java Sat Mar 13 19:24:56 2010
@@ -76,45 +76,40 @@ public class SOAP12FaultTestBase extends
 
 
     public void testMoreChildrenAddition() {
-        try {
-            SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory();
-            SOAPEnvelope envelope = soapFactory.getDefaultFaultEnvelope();
-
-            assertNotNull("Default FaultEnvelope must have a SOAPFault in it",
-                          envelope.getBody().getFault());
-            assertNotNull(
-                    "Default FaultEnvelope must have a SOAPFaultCode in it",
-                    envelope.getBody().getFault().getCode());
-            assertNotNull(
-                    "Default FaultEnvelope must have a SOAPFaultCodeValue in it",
-                    envelope.getBody().getFault().getCode().getValue());
-            assertNotNull(
-                    "Default FaultEnvelope must have a SOAPFaultReason in it",
-                    envelope.getBody().getFault().getReason());
-            assertNotNull(
-                    "Default FaultEnvelope must have a SOAPFaultText in it",
-                    envelope.getBody().getFault().getReason().getFirstSOAPText());
-
-            SOAPEnvelope soapEnvelope = soapFactory.getDefaultFaultEnvelope();
-            String errorCodeString = "Some Error occurred !!";
-            soapEnvelope.getBody().getFault().getCode().getValue().setText(
-                    errorCodeString);
-
-            SOAPFaultCode code = soapEnvelope.getBody().getFault().getCode();
-            envelope.getBody().getFault().setCode(code);
-
-            assertTrue("Parent Value of Code has not been set to new fault",
-                       code.getParent() == envelope.getBody().getFault());
-            assertTrue("Parent Value of Code is still pointing to old fault",
-                       code.getParent() != soapEnvelope.getBody().getFault());
-            assertNull("Old fault must not have a fault code",
-                       soapEnvelope.getBody().getFault().getCode());
-            assertEquals("The SOAP Code value must be " + errorCodeString,
-                         errorCodeString,
-                         envelope.getBody().getFault().getCode().getValue().getText());
-
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
+        SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory();
+        SOAPEnvelope envelope = soapFactory.getDefaultFaultEnvelope();
+
+        assertNotNull("Default FaultEnvelope must have a SOAPFault in it",
+                      envelope.getBody().getFault());
+        assertNotNull(
+                "Default FaultEnvelope must have a SOAPFaultCode in it",
+                envelope.getBody().getFault().getCode());
+        assertNotNull(
+                "Default FaultEnvelope must have a SOAPFaultCodeValue in it",
+                envelope.getBody().getFault().getCode().getValue());
+        assertNotNull(
+                "Default FaultEnvelope must have a SOAPFaultReason in it",
+                envelope.getBody().getFault().getReason());
+        assertNotNull(
+                "Default FaultEnvelope must have a SOAPFaultText in it",
+                envelope.getBody().getFault().getReason().getFirstSOAPText());
+
+        SOAPEnvelope soapEnvelope = soapFactory.getDefaultFaultEnvelope();
+        String errorCodeString = "Some Error occurred !!";
+        soapEnvelope.getBody().getFault().getCode().getValue().setText(
+                errorCodeString);
+
+        SOAPFaultCode code = soapEnvelope.getBody().getFault().getCode();
+        envelope.getBody().getFault().setCode(code);
+
+        assertTrue("Parent Value of Code has not been set to new fault",
+                   code.getParent() == envelope.getBody().getFault());
+        assertTrue("Parent Value of Code is still pointing to old fault",
+                   code.getParent() != soapEnvelope.getBody().getFault());
+        assertNull("Old fault must not have a fault code",
+                   soapEnvelope.getBody().getFault().getCode());
+        assertEquals("The SOAP Code value must be " + errorCodeString,
+                     errorCodeString,
+                     envelope.getBody().getFault().getCode().getValue().getText());
     }
 }
\ No newline at end of file

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/impl/llom/OMEnvelopeTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/impl/llom/OMEnvelopeTest.java?rev=922656&r1=922655&r2=922656&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/impl/llom/OMEnvelopeTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/impl/llom/OMEnvelopeTest.java Sat Mar 13 19:24:56 2010
@@ -26,7 +26,6 @@ import org.apache.axiom.om.TestConstants
 import org.apache.axiom.soap.SOAPBody;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPHeader;
-import org.apache.axiom.soap.SOAPProcessingException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -76,13 +75,7 @@ public class OMEnvelopeTest extends OMTe
     }
 
     public void testDefaultEnveleope() {
-        SOAPEnvelope env = null;
-        try {
-            env = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
-        } catch (SOAPProcessingException e) {
-            log.info(e.getMessage());
-            fail(e.getMessage());
-        }
+        SOAPEnvelope env = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
         assertNotNull(env);
         assertNotNull("Body should not be null", env.getBody());
     }