ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1070299 - in /webservices/commons/trunk/modules/axiom/modules/axiom-api/src: main/java/org/apache/axiom/om/util/ main/java/org/apache/axiom/util/stax/debug/ test/java/org/apache/axiom/util/stax/debug/
Date Sun, 13 Feb 2011 21:12:54 GMT
Author: veithen
Date: Sun Feb 13 21:12:54 2011
New Revision: 1070299

URL: http://svn.apache.org/viewvc?rev=1070299&view=rev
Log:
AXIOM-63: Fixed a couple of issues in OMXMLStreamReaderValidator that caused it to incorrectly
report mismatched END_ELEMENT events when nextTag or getElementText is used. Also refactored
the code so that (a) it can be used with plain XMLStreamReader implementations and (b) that
it uses XMLStreamReaderWrapper as base class.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/debug/XMLStreamReaderValidator.java
      - copied, changed from r1067000, webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/OMXMLStreamReaderValidator.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/debug/
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/debug/XMLStreamReaderValidatorTest.java
  (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/OMXMLStreamReaderValidator.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/OMXMLStreamReaderValidator.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/OMXMLStreamReaderValidator.java?rev=1070299&r1=1070298&r2=1070299&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/OMXMLStreamReaderValidator.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/OMXMLStreamReaderValidator.java
Sun Feb 13 21:12:54 2011
@@ -18,19 +18,10 @@
  */
 package org.apache.axiom.om.util;
 
-import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMXMLStreamReader;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.axiom.util.stax.debug.XMLStreamReaderValidator;
 
 import javax.activation.DataHandler;
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.namespace.QName;
-import javax.xml.stream.Location;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-
-import java.util.Stack;
 
 // TODO: this needs reformatting; the (generated) Javadoc is unreadable!
 /**
@@ -51,334 +42,27 @@ import java.util.Stack;
  *
  * @see org.apache.axiom.om.OMElement#getXMLStreamReader(boolean)
  */
-public class OMXMLStreamReaderValidator implements OMXMLStreamReader {
-
-    private static Log log = LogFactory.getLog(OMXMLStreamReaderValidator.class);
-    private static boolean IS_DEBUG_ENABLED = log.isDebugEnabled();
-    private static boolean IS_ADV_DEBUG_ENABLED = false;  // Turn this on to trace every
event
-    
-    
-    private final OMXMLStreamReader delegate;  // Actual XMLStreamReader implementation 
-    private boolean throwExceptions = false;   // Indicates whether OMException should be
thrown if errors are disovered
-    private Stack stack = new Stack();         // Stack keeps track of the nested element
QName
-    
-
+public class OMXMLStreamReaderValidator extends XMLStreamReaderValidator implements OMXMLStreamReader
{
     /**
      * @param delegate XMLStreamReader to validate
      * @param throwExceptions (true if exceptions should be thrown when errors are encountered)
      */
     public OMXMLStreamReaderValidator(OMXMLStreamReader delegate, boolean throwExceptions)
{
-        super();
-        this.delegate = delegate;
-        this.throwExceptions = throwExceptions;
-    }
-
- 
-    public int next() throws XMLStreamException {
-        int event = delegate.next();
-        logParserState();
-        
-        // Make sure that the start element and end element events match.
-        // Mismatched events are a key indication that the delegate stream reader is 
-        // broken or corrupted.
-        switch (event) {
-        case XMLStreamConstants.START_ELEMENT:
-            stack.push(delegate.getName());
-            break;
-        case XMLStreamConstants.END_ELEMENT:
-            QName delegateQName = delegate.getName();
-            if (stack.isEmpty()) {
-                reportMismatchedEndElement(null, delegateQName);
-            } else {
-                QName expectedQName = (QName) stack.pop();
-                
-                if (!expectedQName.equals(delegateQName)) {
-                    reportMismatchedEndElement(expectedQName, delegateQName);
-                }
-            }
-            break;
-            
-        default :
-        
-        }
-        
-        return event;
-    }
-    
-    
-    /**
-     * Report a mismatched end element.
-     * @param expectedQName
-     * @param delegateQName
-     */
-    private void reportMismatchedEndElement(QName expectedQName, QName delegateQName) {
-        String text = null;
-        if (expectedQName == null) {
-            text = "An END_ELEMENT event for " + delegateQName + 
-                " was encountered, but the START_ELEMENT stack is empty.";
-        } else {
-            text = "An END_ELEMENT event for " + delegateQName + 
-                " was encountered, but this doesn't match the corresponding START_ELEMENT
" + 
-                expectedQName + " event.";
-        }
-        if (IS_DEBUG_ENABLED) {
-            log.debug(text);
-        }       
-        if (throwExceptions) {
-            throw new OMException(text);
-        }
-    }
-    
-    public void close() throws XMLStreamException {
-        delegate.close();
-    }
-
-    public int getAttributeCount() {
-        return delegate.getAttributeCount();
-    }
-
-    public String getAttributeLocalName(int arg0) {
-        return delegate.getAttributeLocalName(arg0);
-    }
-
-    public QName getAttributeName(int arg0) {
-        return delegate.getAttributeName(arg0);
-    }
-
-    public String getAttributeNamespace(int arg0) {
-        return delegate.getAttributeNamespace(arg0);
-    }
-
-    public String getAttributePrefix(int arg0) {
-        return delegate.getAttributePrefix(arg0);
-    }
-
-    public String getAttributeType(int arg0) {
-        return delegate.getAttributeType(arg0);
-    }
-
-    public String getAttributeValue(int arg0) {
-        return delegate.getAttributeValue(arg0);
-    }
-
-    public String getAttributeValue(String arg0, String arg1) {
-        return delegate.getAttributeValue(arg0, arg1);
-    }
-
-    public String getCharacterEncodingScheme() {
-        return delegate.getCharacterEncodingScheme();
-    }
-
-    public String getElementText() throws XMLStreamException {
-        return delegate.getElementText();
-    }
-
-    public String getEncoding() {
-        return delegate.getEncoding();
-    }
-
-    public int getEventType() {
-        return delegate.getEventType();
-    }
-
-    public String getLocalName() {
-        return delegate.getLocalName();
-    }
-
-    public Location getLocation() {
-        return delegate.getLocation();
-    }
-
-    public QName getName() {
-        return delegate.getName();
-    }
-
-    public NamespaceContext getNamespaceContext() {
-        return delegate.getNamespaceContext();
-    }
-
-    public int getNamespaceCount() {
-        return delegate.getNamespaceCount();
-    }
-
-    public String getNamespacePrefix(int arg0) {
-        return delegate.getNamespacePrefix(arg0);
-    }
-
-    public String getNamespaceURI() {
-        return delegate.getNamespaceURI();
-    }
-
-    public String getNamespaceURI(int arg0) {
-        return delegate.getNamespaceURI(arg0);
-    }
-
-    public String getNamespaceURI(String arg0) {
-        return delegate.getNamespaceURI(arg0);
-    }
-
-    public String getPIData() {
-        return delegate.getPIData();
-    }
-
-    public String getPITarget() {
-        return delegate.getPITarget();
-    }
-
-    public String getPrefix() {
-        return delegate.getPrefix();
-    }
-
-    public Object getProperty(String arg0) throws IllegalArgumentException {
-        return delegate.getProperty(arg0);
-    }
-
-    public String getText() {
-        return delegate.getText();
-    }
-
-    public char[] getTextCharacters() {
-        return delegate.getTextCharacters();
-    }
-
-    public int getTextCharacters(int arg0, char[] arg1, int arg2, int arg3) throws XMLStreamException
{
-        return delegate.getTextCharacters(arg0, arg1, arg2, arg3);
-    }
-
-    public int getTextLength() {
-        return delegate.getTextLength();
-    }
-
-    public int getTextStart() {
-        return delegate.getTextStart();
-    }
-
-    public String getVersion() {
-        return delegate.getVersion();
-    }
-
-    public boolean hasName() {
-        return delegate.hasName();
-    }
-
-    public boolean hasNext() throws XMLStreamException {
-        return delegate.hasNext();
-    }
-
-    public boolean hasText() {
-        return delegate.hasText();
-    }
-
-    public boolean isAttributeSpecified(int arg0) {
-        return delegate.isAttributeSpecified(arg0);
-    }
-
-    public boolean isCharacters() {
-        return delegate.isCharacters();
-    }
-
-    public boolean isEndElement() {
-        return delegate.isEndElement();
-    }
-
-    public boolean isStandalone() {
-        return delegate.isStandalone();
-    }
-
-    public boolean isStartElement() {
-        return delegate.isStartElement();
-    }
-
-    public boolean isWhiteSpace() {
-        return delegate.isWhiteSpace();
-    }
-
-   
-
-    public int nextTag() throws XMLStreamException {
-        return delegate.nextTag();
-    }
-
-    public void require(int arg0, String arg1, String arg2) throws XMLStreamException {
-        delegate.require(arg0, arg1, arg2);
-    }
-
-    public boolean standaloneSet() {
-        return delegate.standaloneSet();
-    }
-    
-    
-    /**
-     * Dump the current event of the delegate.
-     */
-    protected void logParserState() {
-        if (IS_ADV_DEBUG_ENABLED) {
-            int currentEvent = delegate.getEventType();
-            
-            switch (currentEvent) {
-            case XMLStreamConstants.START_ELEMENT:
-                log.trace("START_ELEMENT: ");
-                log.trace("  QName: " + delegate.getName());
-                break;
-            case XMLStreamConstants.START_DOCUMENT:
-                log.trace("START_DOCUMENT: ");
-                break;
-            case XMLStreamConstants.CHARACTERS:
-                log.trace("CHARACTERS: ");
-                log.trace(   "[" + delegate.getText() + "]");
-                break;
-            case XMLStreamConstants.CDATA:
-                log.trace("CDATA: ");
-                log.trace(   "[" + delegate.getText() + "]");
-                break;
-            case XMLStreamConstants.END_ELEMENT:
-                log.trace("END_ELEMENT: ");
-                log.trace("  QName: " + delegate.getName());
-                break;
-            case XMLStreamConstants.END_DOCUMENT:
-                log.trace("END_DOCUMENT: ");
-                break;
-            case XMLStreamConstants.SPACE:
-                log.trace("SPACE: ");
-                log.trace(   "[" + delegate.getText() + "]");
-                break;
-            case XMLStreamConstants.COMMENT:
-                log.trace("COMMENT: ");
-                log.trace(   "[" + delegate.getText() + "]");
-                break;
-            case XMLStreamConstants.DTD:
-                log.trace("DTD: ");
-                log.trace(   "[" + delegate.getText() + "]");
-                break;
-            case XMLStreamConstants.PROCESSING_INSTRUCTION:
-                log.trace("PROCESSING_INSTRUCTION: ");
-                log.trace("   [" + delegate.getPITarget() + "][" +
-                            delegate.getPIData() + "]");
-                break;
-            case XMLStreamConstants.ENTITY_REFERENCE:
-                log.trace("ENTITY_REFERENCE: ");
-                log.trace("    " + delegate.getLocalName() + "[" +
-                            delegate.getText() + "]");
-                break;
-            default :
-                log.trace("UNKNOWN_STATE: " + currentEvent);
-            
-            }
-        }
+        super(delegate, throwExceptions);
     }
 
     public DataHandler getDataHandler(String blobcid) {
-        return delegate.getDataHandler(blobcid);
+        return ((OMXMLStreamReader)getParent()).getDataHandler(blobcid);
     }
 
 
     public boolean isInlineMTOM() {
-        return delegate.isInlineMTOM();
+        return ((OMXMLStreamReader)getParent()).isInlineMTOM();
     }
 
 
     public void setInlineMTOM(boolean value) {
-        delegate.setInlineMTOM(value);
+        ((OMXMLStreamReader)getParent()).setInlineMTOM(value);
     }
     
 

Copied: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/debug/XMLStreamReaderValidator.java
(from r1067000, webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/OMXMLStreamReaderValidator.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/debug/XMLStreamReaderValidator.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/debug/XMLStreamReaderValidator.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/OMXMLStreamReaderValidator.java&r1=1067000&r2=1070299&rev=1070299&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/OMXMLStreamReaderValidator.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/debug/XMLStreamReaderValidator.java
Sun Feb 13 21:12:54 2011
@@ -16,19 +16,17 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.axiom.om.util;
+package org.apache.axiom.util.stax.debug;
 
 import org.apache.axiom.om.OMException;
-import org.apache.axiom.om.OMXMLStreamReader;
+import org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import javax.activation.DataHandler;
-import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
-import javax.xml.stream.Location;
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
 
 import java.util.Stack;
 
@@ -37,28 +35,24 @@ import java.util.Stack;
  * There are several places in the code where events are passed from 
  * a source to a consumer using XMLStreamReader events. 
  * 
- *     OMXMLStreamReader (impl)--> consumer of XMLStreamReader events
+ *     XMLStreamReader (impl)--> consumer of XMLStreamReader events
  * 
  * This simple class can be interjected as a filter and used to do some simple validation.
  * Validating the events coming from source (impl) can help find and correct errors 
  * when they occur.  Otherwise the errors may be caught much further downstream and hard
to fix.
  * 
- *    OMXMLStreamReader (impl)--> OMXMLStreamReaderValiator-> consumer of XMLStreamReader
events
+ *    XMLStreamReader (impl)--> XMLStreamReaderValiator-> consumer of XMLStreamReader
events
  * 
  * 
  * In the initial version, the XMStreamValidator ensures that the start element events match
the 
  * end element events.
- *
- * @see org.apache.axiom.om.OMElement#getXMLStreamReader(boolean)
  */
-public class OMXMLStreamReaderValidator implements OMXMLStreamReader {
+public class XMLStreamReaderValidator extends XMLStreamReaderWrapper {
 
-    private static Log log = LogFactory.getLog(OMXMLStreamReaderValidator.class);
+    private static Log log = LogFactory.getLog(XMLStreamReaderValidator.class);
     private static boolean IS_DEBUG_ENABLED = log.isDebugEnabled();
     private static boolean IS_ADV_DEBUG_ENABLED = false;  // Turn this on to trace every
event
     
-    
-    private final OMXMLStreamReader delegate;  // Actual XMLStreamReader implementation 
     private boolean throwExceptions = false;   // Indicates whether OMException should be
thrown if errors are disovered
     private Stack stack = new Stack();         // Stack keeps track of the nested element
QName
     
@@ -67,15 +61,31 @@ public class OMXMLStreamReaderValidator 
      * @param delegate XMLStreamReader to validate
      * @param throwExceptions (true if exceptions should be thrown when errors are encountered)
      */
-    public OMXMLStreamReaderValidator(OMXMLStreamReader delegate, boolean throwExceptions)
{
-        super();
-        this.delegate = delegate;
+    public XMLStreamReaderValidator(XMLStreamReader delegate, boolean throwExceptions) {
+        super(delegate);
         this.throwExceptions = throwExceptions;
     }
 
  
     public int next() throws XMLStreamException {
-        int event = delegate.next();
+        int event = super.next();
+        trackEvent(event);
+        return event;
+    }
+    
+    public String getElementText() throws XMLStreamException {
+        String text = super.getElementText();
+        trackEvent(END_ELEMENT);
+        return text;
+    }
+
+    public int nextTag() throws XMLStreamException {
+        int event = super.nextTag();
+        trackEvent(event);
+        return event;
+    }
+
+    private void trackEvent(int event) {
         logParserState();
         
         // Make sure that the start element and end element events match.
@@ -83,10 +93,10 @@ public class OMXMLStreamReaderValidator 
         // broken or corrupted.
         switch (event) {
         case XMLStreamConstants.START_ELEMENT:
-            stack.push(delegate.getName());
+            stack.push(super.getName());
             break;
         case XMLStreamConstants.END_ELEMENT:
-            QName delegateQName = delegate.getName();
+            QName delegateQName = super.getName();
             if (stack.isEmpty()) {
                 reportMismatchedEndElement(null, delegateQName);
             } else {
@@ -101,8 +111,6 @@ public class OMXMLStreamReaderValidator 
         default :
         
         }
-        
-        return event;
     }
     
     
@@ -129,236 +137,57 @@ public class OMXMLStreamReaderValidator 
         }
     }
     
-    public void close() throws XMLStreamException {
-        delegate.close();
-    }
-
-    public int getAttributeCount() {
-        return delegate.getAttributeCount();
-    }
-
-    public String getAttributeLocalName(int arg0) {
-        return delegate.getAttributeLocalName(arg0);
-    }
-
-    public QName getAttributeName(int arg0) {
-        return delegate.getAttributeName(arg0);
-    }
-
-    public String getAttributeNamespace(int arg0) {
-        return delegate.getAttributeNamespace(arg0);
-    }
-
-    public String getAttributePrefix(int arg0) {
-        return delegate.getAttributePrefix(arg0);
-    }
-
-    public String getAttributeType(int arg0) {
-        return delegate.getAttributeType(arg0);
-    }
-
-    public String getAttributeValue(int arg0) {
-        return delegate.getAttributeValue(arg0);
-    }
-
-    public String getAttributeValue(String arg0, String arg1) {
-        return delegate.getAttributeValue(arg0, arg1);
-    }
-
-    public String getCharacterEncodingScheme() {
-        return delegate.getCharacterEncodingScheme();
-    }
-
-    public String getElementText() throws XMLStreamException {
-        return delegate.getElementText();
-    }
-
-    public String getEncoding() {
-        return delegate.getEncoding();
-    }
-
-    public int getEventType() {
-        return delegate.getEventType();
-    }
-
-    public String getLocalName() {
-        return delegate.getLocalName();
-    }
-
-    public Location getLocation() {
-        return delegate.getLocation();
-    }
-
-    public QName getName() {
-        return delegate.getName();
-    }
-
-    public NamespaceContext getNamespaceContext() {
-        return delegate.getNamespaceContext();
-    }
-
-    public int getNamespaceCount() {
-        return delegate.getNamespaceCount();
-    }
-
-    public String getNamespacePrefix(int arg0) {
-        return delegate.getNamespacePrefix(arg0);
-    }
-
-    public String getNamespaceURI() {
-        return delegate.getNamespaceURI();
-    }
-
-    public String getNamespaceURI(int arg0) {
-        return delegate.getNamespaceURI(arg0);
-    }
-
-    public String getNamespaceURI(String arg0) {
-        return delegate.getNamespaceURI(arg0);
-    }
-
-    public String getPIData() {
-        return delegate.getPIData();
-    }
-
-    public String getPITarget() {
-        return delegate.getPITarget();
-    }
-
-    public String getPrefix() {
-        return delegate.getPrefix();
-    }
-
-    public Object getProperty(String arg0) throws IllegalArgumentException {
-        return delegate.getProperty(arg0);
-    }
-
-    public String getText() {
-        return delegate.getText();
-    }
-
-    public char[] getTextCharacters() {
-        return delegate.getTextCharacters();
-    }
-
-    public int getTextCharacters(int arg0, char[] arg1, int arg2, int arg3) throws XMLStreamException
{
-        return delegate.getTextCharacters(arg0, arg1, arg2, arg3);
-    }
-
-    public int getTextLength() {
-        return delegate.getTextLength();
-    }
-
-    public int getTextStart() {
-        return delegate.getTextStart();
-    }
-
-    public String getVersion() {
-        return delegate.getVersion();
-    }
-
-    public boolean hasName() {
-        return delegate.hasName();
-    }
-
-    public boolean hasNext() throws XMLStreamException {
-        return delegate.hasNext();
-    }
-
-    public boolean hasText() {
-        return delegate.hasText();
-    }
-
-    public boolean isAttributeSpecified(int arg0) {
-        return delegate.isAttributeSpecified(arg0);
-    }
-
-    public boolean isCharacters() {
-        return delegate.isCharacters();
-    }
-
-    public boolean isEndElement() {
-        return delegate.isEndElement();
-    }
-
-    public boolean isStandalone() {
-        return delegate.isStandalone();
-    }
-
-    public boolean isStartElement() {
-        return delegate.isStartElement();
-    }
-
-    public boolean isWhiteSpace() {
-        return delegate.isWhiteSpace();
-    }
-
-   
-
-    public int nextTag() throws XMLStreamException {
-        return delegate.nextTag();
-    }
-
-    public void require(int arg0, String arg1, String arg2) throws XMLStreamException {
-        delegate.require(arg0, arg1, arg2);
-    }
-
-    public boolean standaloneSet() {
-        return delegate.standaloneSet();
-    }
-    
-    
     /**
      * Dump the current event of the delegate.
      */
     protected void logParserState() {
         if (IS_ADV_DEBUG_ENABLED) {
-            int currentEvent = delegate.getEventType();
+            int currentEvent = super.getEventType();
             
             switch (currentEvent) {
             case XMLStreamConstants.START_ELEMENT:
                 log.trace("START_ELEMENT: ");
-                log.trace("  QName: " + delegate.getName());
+                log.trace("  QName: " + super.getName());
                 break;
             case XMLStreamConstants.START_DOCUMENT:
                 log.trace("START_DOCUMENT: ");
                 break;
             case XMLStreamConstants.CHARACTERS:
                 log.trace("CHARACTERS: ");
-                log.trace(   "[" + delegate.getText() + "]");
+                log.trace(   "[" + super.getText() + "]");
                 break;
             case XMLStreamConstants.CDATA:
                 log.trace("CDATA: ");
-                log.trace(   "[" + delegate.getText() + "]");
+                log.trace(   "[" + super.getText() + "]");
                 break;
             case XMLStreamConstants.END_ELEMENT:
                 log.trace("END_ELEMENT: ");
-                log.trace("  QName: " + delegate.getName());
+                log.trace("  QName: " + super.getName());
                 break;
             case XMLStreamConstants.END_DOCUMENT:
                 log.trace("END_DOCUMENT: ");
                 break;
             case XMLStreamConstants.SPACE:
                 log.trace("SPACE: ");
-                log.trace(   "[" + delegate.getText() + "]");
+                log.trace(   "[" + super.getText() + "]");
                 break;
             case XMLStreamConstants.COMMENT:
                 log.trace("COMMENT: ");
-                log.trace(   "[" + delegate.getText() + "]");
+                log.trace(   "[" + super.getText() + "]");
                 break;
             case XMLStreamConstants.DTD:
                 log.trace("DTD: ");
-                log.trace(   "[" + delegate.getText() + "]");
+                log.trace(   "[" + super.getText() + "]");
                 break;
             case XMLStreamConstants.PROCESSING_INSTRUCTION:
                 log.trace("PROCESSING_INSTRUCTION: ");
-                log.trace("   [" + delegate.getPITarget() + "][" +
-                            delegate.getPIData() + "]");
+                log.trace("   [" + super.getPITarget() + "][" +
+                        super.getPIData() + "]");
                 break;
             case XMLStreamConstants.ENTITY_REFERENCE:
                 log.trace("ENTITY_REFERENCE: ");
-                log.trace("    " + delegate.getLocalName() + "[" +
-                            delegate.getText() + "]");
+                log.trace("    " + super.getLocalName() + "[" +
+                        super.getText() + "]");
                 break;
             default :
                 log.trace("UNKNOWN_STATE: " + currentEvent);
@@ -366,20 +195,4 @@ public class OMXMLStreamReaderValidator 
             }
         }
     }
-
-    public DataHandler getDataHandler(String blobcid) {
-        return delegate.getDataHandler(blobcid);
-    }
-
-
-    public boolean isInlineMTOM() {
-        return delegate.isInlineMTOM();
-    }
-
-
-    public void setInlineMTOM(boolean value) {
-        delegate.setInlineMTOM(value);
-    }
-    
-
 }

Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/debug/XMLStreamReaderValidatorTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/debug/XMLStreamReaderValidatorTest.java?rev=1070299&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/debug/XMLStreamReaderValidatorTest.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/debug/XMLStreamReaderValidatorTest.java
Sun Feb 13 21:12:54 2011
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.axiom.util.stax.debug;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.util.StAXUtils;
+
+public class XMLStreamReaderValidatorTest extends TestCase {
+    private static XMLStreamReaderValidator createValidatorForParser(String xml) throws XMLStreamException
{
+        return new XMLStreamReaderValidator(StAXUtils.createXMLStreamReader(new StringReader(xml)),
true);
+    }
+    
+    /**
+     * Test that {@link XMLStreamReaderValidator} correctly keeps track of events when
+     * {@link XMLStreamReader#getElementText()} is used. This is a regression test for
+     * <a href="https://issues.apache.org/jira/browse/AXIOM-63">AXIOM-63</a>.
+     * 
+     * @throws Exception
+     */
+    public void testGetElementText() throws Exception {
+        XMLStreamReaderValidator validator = createValidatorForParser("<root><a>text</a></root>");
+        assertEquals(XMLStreamReader.START_ELEMENT, validator.next());
+        assertEquals(XMLStreamReader.START_ELEMENT, validator.next());
+        assertEquals("text", validator.getElementText());
+        assertEquals(XMLStreamReader.END_ELEMENT, validator.getEventType());
+        assertEquals(XMLStreamReader.END_ELEMENT, validator.next());
+        assertEquals(XMLStreamReader.END_DOCUMENT, validator.next());
+    }
+
+    /**
+     * Test that {@link XMLStreamReaderValidator} correctly keeps track of events when
+     * {@link XMLStreamReader#nextTag()} is used. This is a regression test for
+     * <a href="https://issues.apache.org/jira/browse/AXIOM-63">AXIOM-63</a>.
+     * 
+     * @throws Exception
+     */
+    public void testNextTag() throws Exception {
+        XMLStreamReaderValidator validator = createValidatorForParser("<root>\n  <a/>\n</root>");
+        assertEquals(XMLStreamReader.START_ELEMENT, validator.nextTag());
+        assertEquals(XMLStreamReader.START_ELEMENT, validator.nextTag());
+        assertEquals(XMLStreamReader.END_ELEMENT, validator.next());
+        assertEquals(XMLStreamReader.END_ELEMENT, validator.nextTag());
+        assertEquals(XMLStreamReader.END_DOCUMENT, validator.next());
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/debug/XMLStreamReaderValidatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message