You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2016/03/11 00:08:53 UTC

svn commit: r1734477 - in /webservices/axiom/trunk: aspects/core-aspects/src/main/java/org/apache/axiom/core/ aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/ axiom-api/src/main/java/org/apache/axiom/om/ axiom-compat/src/main/j...

Author: veithen
Date: Thu Mar 10 23:08:52 2016
New Revision: 1734477

URL: http://svn.apache.org/viewvc?rev=1734477&view=rev
Log:
Remove the next() method from OMXMLParserWrapper. It should not be part of the public API because for application code there is no need to manipulate the state of the underlying parser directly. Also, since it returns the event type, it is tightly coupled to StAX, but builders may be created from other sources.

Removed:
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestNextBeforeGetDocumentElement.java
Modified:
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/Builder.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/PushBuilder.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMXMLParserWrapper.java
    webservices/axiom/trunk/axiom-compat/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java
    webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestIOExceptionInGetText.java
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestInvalidXML.java

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/Builder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/Builder.java?rev=1734477&r1=1734476&r2=1734477&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/Builder.java (original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/Builder.java Thu Mar 10 23:08:52 2016
@@ -19,7 +19,7 @@
 package org.apache.axiom.core;
 
 public interface Builder {
-    int next();
+    void next();
     boolean isCompleted();
     void close();
     boolean isClosed();

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/PushBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/PushBuilder.java?rev=1734477&r1=1734476&r2=1734477&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/PushBuilder.java (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/PushBuilder.java Thu Mar 10 23:08:52 2016
@@ -37,13 +37,12 @@ public final class PushBuilder extends A
     }
     
     @Override
-    public int next() throws OMException {
+    public void next() throws OMException {
         try {
             reader.proceed();
         } catch (StreamException ex) {
             throw new DeferredParsingException(ex);
         }
-        return -1;
     }
 
     public final OMElement getDocumentElement() {

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java?rev=1734477&r1=1734476&r2=1734477&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java Thu Mar 10 23:08:52 2016
@@ -115,7 +115,7 @@ public class StAXOMBuilder extends Abstr
      * @return Returns int.
      * @throws OMException
      */
-    public int next() throws OMException {
+    public void next() throws OMException {
         if (builderHandler.done) {
             throw new OMException();
         }
@@ -141,8 +141,6 @@ public class StAXOMBuilder extends Abstr
             }
             builderHandler.done = true;
         }
-        
-        return event;
     }
     
     public final OMElement getDocumentElement() {

Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMXMLParserWrapper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMXMLParserWrapper.java?rev=1734477&r1=1734476&r2=1734477&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMXMLParserWrapper.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMXMLParserWrapper.java Thu Mar 10 23:08:52 2016
@@ -31,16 +31,6 @@ import org.w3c.dom.Node;
 
 /** Interface OMXMLParserWrapper */
 public interface OMXMLParserWrapper {
-    /**
-     * Proceed the parser one step and return the event value.
-     *
-     * @return Returns int.
-     * @throws org.apache.axiom.om.OMException
-     *
-     * @throws OMException
-     */
-    int next() throws OMException;
-
     /** @return Returns the complete status. */
     boolean isCompleted();
 

Modified: webservices/axiom/trunk/axiom-compat/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-compat/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java?rev=1734477&r1=1734476&r2=1734477&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-compat/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java (original)
+++ webservices/axiom/trunk/axiom-compat/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java Thu Mar 10 23:08:52 2016
@@ -23,7 +23,6 @@ import javax.xml.stream.XMLStreamReader;
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMDocument;
 import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMXMLBuilderFactory;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPFactory;
@@ -63,10 +62,6 @@ public class StAXSOAPModelBuilder implem
         return target.getSOAPEnvelope();
     }
 
-    public int next() throws OMException {
-        return target.next();
-    }
-
     public SOAPMessage getSOAPMessage() {
         return target.getSOAPMessage();
     }

Modified: webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java?rev=1734477&r1=1734476&r2=1734477&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java (original)
+++ webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java Thu Mar 10 23:08:52 2016
@@ -64,9 +64,9 @@ public class FOMBuilder extends StAXOMBu
      * @return Returns int.
      * @throws OMException
      */
-    public int next() throws OMException {
+    public void next() throws OMException {
         try {
-            return super.next();
+            super.next();
         } catch (OMException e) {
             // TODO: transforming the OMException here is not ideal!
             throw new ParseException(e);

Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java?rev=1734477&r1=1734476&r2=1734477&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java Thu Mar 10 23:08:52 2016
@@ -138,7 +138,6 @@ public class OMTestSuiteBuilder extends
         addTest(new org.apache.axiom.ts.om.builder.TestInvalidXML(metaFactory));
         addTest(new org.apache.axiom.ts.om.builder.TestIOExceptionInGetText(metaFactory));
         addTest(new org.apache.axiom.ts.om.builder.TestMalformedDocument(metaFactory));
-        addTest(new org.apache.axiom.ts.om.builder.TestNextBeforeGetDocumentElement(metaFactory));
         addTest(new org.apache.axiom.ts.om.builder.TestReadAttachmentBeforeRootPartComplete(metaFactory));
         addTest(new org.apache.axiom.ts.om.builder.TestRegisterCustomBuilderForPayloadJAXBPlain(metaFactory));
         addTest(new org.apache.axiom.ts.om.builder.TestRegisterCustomBuilderForPayloadJAXBWithDataHandlerReaderExtension(metaFactory));

Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestIOExceptionInGetText.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestIOExceptionInGetText.java?rev=1734477&r1=1734476&r2=1734477&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestIOExceptionInGetText.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestIOExceptionInGetText.java Thu Mar 10 23:08:52 2016
@@ -23,9 +23,9 @@ import java.io.InputStream;
 
 import javax.xml.stream.XMLStreamReader;
 
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMXMLBuilderFactory;
-import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axiom.testutils.InvocationCounter;
 import org.apache.axiom.testutils.io.ExceptionInputStream;
@@ -59,12 +59,12 @@ public class TestIOExceptionInGetText ex
         InvocationCounter invocationCounter = new InvocationCounter();
         XMLStreamReader reader = (XMLStreamReader)invocationCounter.createProxy(originalReader);
         
-        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(metaFactory.getOMFactory(), reader);
+        OMElement element = OMXMLBuilderFactory.createStAXOMBuilder(
+                metaFactory.getOMFactory(), reader).getDocumentElement();
         
         try {
-            while (true) {
-                builder.next();
-            }
+            element.getNextOMSibling();
+            fail("Expected exception");
         } catch (Exception ex) {
             // Expected
         }
@@ -72,15 +72,11 @@ public class TestIOExceptionInGetText ex
         assertTrue(invocationCounter.getInvocationCount() > 0);
         invocationCounter.reset();
 
-        Exception exception;
         try {
-            builder.next();
-            exception = null;
-        } catch (Exception ex) {
-            exception = ex;
-        }
-        if (exception == null) {
+            element.getNextOMSibling();
             fail("Expected exception");
+        } catch (Exception ex) {
+            // Expected
         }
         
         assertEquals(0, invocationCounter.getInvocationCount());

Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestInvalidXML.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestInvalidXML.java?rev=1734477&r1=1734476&r2=1734477&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestInvalidXML.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestInvalidXML.java Thu Mar 10 23:08:52 2016
@@ -18,11 +18,14 @@
  */
 package org.apache.axiom.ts.om.builder;
 
+import static com.google.common.truth.Truth.assertThat;
+
 import javax.xml.stream.XMLStreamReader;
 
+import org.apache.axiom.om.DeferredParsingException;
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMXMLBuilderFactory;
-import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axiom.testutils.InvocationCounter;
 import org.apache.axiom.ts.AxiomTestCase;
@@ -38,36 +41,34 @@ public class TestInvalidXML extends Axio
         InvocationCounter invocationCounter = new InvocationCounter();
         XMLStreamReader reader = (XMLStreamReader)invocationCounter.createProxy(originalReader);
         
-        OMXMLParserWrapper stAXOMBuilder =
-                OMXMLBuilderFactory.createStAXOMBuilder(metaFactory.getOMFactory(),
-                                                        reader);
-        
-        Exception exception = null;
-        while (exception == null || stAXOMBuilder.isCompleted()) {
-            try {
-                stAXOMBuilder.next();
-            } catch (Exception e) {
-                exception =e;
-            }
+        OMElement element = OMXMLBuilderFactory.createStAXOMBuilder(
+                metaFactory.getOMFactory(), reader).getDocumentElement();
+        
+        DeferredParsingException exception;
+        try {
+            element.getNextOMSibling();
+            exception = null;
+        } catch (DeferredParsingException ex) {
+            exception = ex;
         }
         
-        assertTrue("Expected an exception because invalid_xml.xml is wrong", exception != null);
+        assertThat(exception).isNotNull();
         
         assertTrue(invocationCounter.getInvocationCount() > 0);
         invocationCounter.reset();
         
         // Intentionally call builder again to make sure the same error is returned.
-        Exception exception2 = null;
+        DeferredParsingException exception2;
         try {
-            stAXOMBuilder.next();
-        } catch (Exception e) {
-            exception2 = e;
+            element.getNextOMSibling();
+            exception2 = null;
+        } catch (DeferredParsingException ex) {
+            exception2 = ex;
         }
         
-        assertEquals(0, invocationCounter.getInvocationCount());
+        assertThat(invocationCounter.getInvocationCount()).isEqualTo(0);
         
-        assertTrue("Expected a second exception because invalid_xml.xml is wrong", exception2 != null);
-        assertTrue("Expected the same exception. first=" + exception + " second=" + exception2, 
-                    exception.getMessage().equals(exception2.getMessage()));
+        assertThat(exception2).isNotNull();
+        assertThat(exception2.getMessage()).isEqualTo(exception.getMessage());
     }
 }