cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1066886 - in /cxf/branches/2.3.x-fixes: ./ common/common/src/main/java/org/apache/cxf/staxutils/ common/common/src/test/java/org/apache/cxf/staxutils/ rt/core/src/main/java/org/apache/cxf/databinding/source/ systests/jaxws/src/test/java/or...
Date Thu, 03 Feb 2011 17:36:21 GMT
Author: dkulp
Date: Thu Feb  3 17:36:21 2011
New Revision: 1066886

URL: http://svn.apache.org/viewvc?rev=1066886&view=rev
Log:
Merged revisions 1066876 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1066876 | dkulp | 2011-02-03 12:18:52 -0500 (Thu, 03 Feb 2011) | 2 lines
  
  [CXF-3305] Fix problems with Provider<Source> getting a Source that
  doesn't properly have the streamreader set to START_DOCUMENT.
........

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/FragmentStreamReader.java
    cxf/branches/2.3.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/FragmentStreamReaderTest.java
    cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
    cxf/branches/2.3.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AbstractSourcePayloadProvider.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/FragmentStreamReader.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/FragmentStreamReader.java?rev=1066886&r1=1066885&r2=1066886&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/FragmentStreamReader.java
(original)
+++ cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/FragmentStreamReader.java
Thu Feb  3 17:36:21 2011
@@ -28,14 +28,13 @@ import javax.xml.stream.XMLStreamReader;
  * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
  */
 public class FragmentStreamReader extends DepthXMLStreamReader {
-    private boolean startDoc;
     private boolean startElement;
     private boolean middle = true;
     private boolean endDoc;
     private boolean doDocEvents = true;
 
     private int depth;
-    private int current = -1;
+    private int current = XMLStreamReader.START_DOCUMENT;
     private boolean filter = true;
     private boolean advanceAtEnd = true;
     
@@ -46,11 +45,11 @@ public class FragmentStreamReader extend
         super(reader);
         this.doDocEvents = doDocEvents;
         if (!doDocEvents) {
-            startDoc = true;
-            
             depth = getDepth();
             current = reader.getEventType();
-            startElement = true;
+            if (current != XMLStreamReader.START_DOCUMENT) {
+                startElement = true;
+            }
         }
     }    
    
@@ -59,9 +58,6 @@ public class FragmentStreamReader extend
     }
 
     public boolean hasNext() throws XMLStreamException {
-        if (!startDoc) {
-            return true;
-        }
         
         if (endDoc) {
             return false;
@@ -71,10 +67,7 @@ public class FragmentStreamReader extend
     }
     
     public final int next() throws XMLStreamException {
-        if (!startDoc) {
-            startDoc = true;
-            current = START_DOCUMENT;
-        } else if (!startElement) {
+        if (!startElement) {
             depth = getDepth();
             
             current = reader.getEventType();

Modified: cxf/branches/2.3.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/FragmentStreamReaderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/FragmentStreamReaderTest.java?rev=1066886&r1=1066885&r2=1066886&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/FragmentStreamReaderTest.java
(original)
+++ cxf/branches/2.3.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/FragmentStreamReaderTest.java
Thu Feb  3 17:36:21 2011
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.staxutils;
 
+import java.io.StringReader;
+
 import javax.xml.stream.XMLStreamReader;
 
 import org.junit.Assert;
@@ -40,7 +42,6 @@ public class FragmentStreamReaderTest ex
         FragmentStreamReader fsr = new FragmentStreamReader(dr);
         assertTrue(fsr.hasNext());
         
-        assertEquals(XMLStreamReader.START_DOCUMENT, fsr.next());
         assertEquals(XMLStreamReader.START_DOCUMENT, fsr.getEventType());
         
         fsr.next();
@@ -51,4 +52,47 @@ public class FragmentStreamReaderTest ex
         
         fsr.close();
     }
+    
+    
+    @Test
+    public void testEvents() throws Exception {
+        String test = "<foo><foo2/></foo>";
+        //test the full stream
+        XMLStreamReader reader = StaxUtils.createXMLStreamReader(new StringReader(test));
+        reader = new FragmentStreamReader(reader);
+        assertEvents(reader, 7, 1, 1, 2, 2, 8);
+
+        reader = StaxUtils.createXMLStreamReader(new StringReader(test));
+        reader = new FragmentStreamReader(reader, true);
+        assertEvents(reader, 7, 1, 1, 2, 2, 8);
+
+        reader = StaxUtils.createXMLStreamReader(new StringReader(test));
+        reader = new FragmentStreamReader(reader, false);
+        assertEvents(reader, 7, 1, 1, 2, 2, 8);
+
+    
+        //test a partial stream, skip over the startdoc even prior to creating
+        //the FragmentStreamReader to make sure the event could be generated
+        reader = StaxUtils.createXMLStreamReader(new StringReader(test));
+        reader.next();
+        reader = new FragmentStreamReader(reader);
+        assertEvents(reader, 7, 1, 1, 2, 2, 8);
+        
+        reader = StaxUtils.createXMLStreamReader(new StringReader(test));
+        reader.next();
+        reader = new FragmentStreamReader(reader, true);
+        assertEvents(reader, 7, 1, 1, 2, 2, 8);
+
+        reader = StaxUtils.createXMLStreamReader(new StringReader(test));
+        reader.next();
+        reader = new FragmentStreamReader(reader, false);
+        assertEvents(reader, 1, 1, 2, 2);
+    }
+    
+    private void assertEvents(XMLStreamReader reader, int initial, int ... events) throws
Exception {
+        assertEquals(initial, reader.getEventType());
+        for (int x : events) {
+            assertEquals(x, reader.next());
+        }
+    }
 }

Modified: cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java?rev=1066886&r1=1066885&r2=1066886&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
Thu Feb  3 17:36:21 2011
@@ -163,7 +163,7 @@ public class XMLStreamDataReader impleme
             final InputStream ins = message.getContent(InputStream.class);
             message.removeContent(InputStream.class);
             
-            input = new FragmentStreamReader(input) {
+            input = new FragmentStreamReader(input, true) {
                 boolean closed;
                 public boolean hasNext() throws XMLStreamException {
                     boolean b = super.hasNext();

Modified: cxf/branches/2.3.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AbstractSourcePayloadProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AbstractSourcePayloadProvider.java?rev=1066886&r1=1066885&r2=1066886&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AbstractSourcePayloadProvider.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AbstractSourcePayloadProvider.java
Thu Feb  3 17:36:21 2011
@@ -72,6 +72,12 @@ public abstract class AbstractSourcePayl
         
         try {
             System.out.println(request.getClass().getName());
+            if (request instanceof StaxSource) {
+                StaxSource ss = (StaxSource)request;
+                if (ss.getXMLStreamReader().getEventType() == -1) {
+                    throw new RuntimeException("Should not be a -1 event");
+                }
+            }
             String input = getSourceAsString(request);
             System.out.println(input);  
             



Mime
View raw message