cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject git commit: Reader needs to read until the END_ELEMENT beyond the level we started at to get all the content of the element
Date Fri, 02 May 2014 18:04:29 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 0eeefee28 -> 126775733


Reader needs to read until the END_ELEMENT beyond the level we started at to get all the content
of the element


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/12677573
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/12677573
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/12677573

Branch: refs/heads/master
Commit: 12677573382ff87cb7f0fd105ea44b3b3916888b
Parents: 0eeefee
Author: Daniel Kulp <dkulp@apache.org>
Authored: Fri May 2 12:17:17 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri May 2 13:32:57 2014 -0400

----------------------------------------------------------------------
 .../org/apache/cxf/staxutils/StaxUtils.java     |  2 +-
 .../cxf/staxutils/W3CDOMStreamWriter.java       |  9 ++++++---
 .../ws/addressing/EndpointReferenceUtils.java   |  3 ---
 .../org/apache/cxf/staxutils/StaxUtilsTest.java |  7 ++++---
 .../handler/logical/LogicalMessageImpl.java     | 21 +++++++-------------
 .../ws/action/SignatureWhitespaceTest.java      |  1 -
 6 files changed, 18 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/12677573/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java b/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
index 624828a..a9590fd 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
@@ -736,7 +736,7 @@ public final class StaxUtils {
                     writer.writeEndElement();
                 }
                 read--;
-                if (read <= 0 && fragment) {
+                if (read < 0 && fragment) {
                     return;
                 }
                 if (isThreshold && !countStack.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/12677573/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java b/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
index bd25321..6903c4c 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
@@ -24,7 +24,6 @@ import java.util.Stack;
 
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
@@ -46,7 +45,7 @@ public class W3CDOMStreamWriter implements XMLStreamWriter {
     private boolean nsRepairing;
     private Map<String, Object> properties = Collections.emptyMap();
 
-    public W3CDOMStreamWriter() throws ParserConfigurationException {
+    public W3CDOMStreamWriter() {
         document = DOMUtils.newDocument();
     }
 
@@ -299,7 +298,11 @@ public class W3CDOMStreamWriter implements XMLStreamWriter {
     }
 
     public void writeCharacters(String text) throws XMLStreamException {
-        currentNode.appendChild(document.createTextNode(text));
+        if (currentNode != null) {
+            currentNode.appendChild(document.createTextNode(text));
+        } else {
+            document.appendChild(document.createTextNode(text));
+        }
     }
 
     public void writeCharacters(char[] text, int start, int len) throws XMLStreamException
{

http://git-wip-us.apache.org/repos/asf/cxf/blob/12677573/core/src/main/java/org/apache/cxf/ws/addressing/EndpointReferenceUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/ws/addressing/EndpointReferenceUtils.java b/core/src/main/java/org/apache/cxf/ws/addressing/EndpointReferenceUtils.java
index d2333fe..7ca7387 100644
--- a/core/src/main/java/org/apache/cxf/ws/addressing/EndpointReferenceUtils.java
+++ b/core/src/main/java/org/apache/cxf/ws/addressing/EndpointReferenceUtils.java
@@ -43,7 +43,6 @@ import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 import javax.xml.namespace.QName;
-import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.Source;
@@ -918,8 +917,6 @@ public final class EndpointReferenceUtils {
             return new DOMSource(writer.getDocument());
         } catch (JAXBException e) {
             //ignore
-        } catch (ParserConfigurationException e) {
-            //ignore
         }
         return null;
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/12677573/core/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java b/core/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java
index 02e6503..89b2ce9 100644
--- a/core/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java
+++ b/core/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java
@@ -370,10 +370,10 @@ public class StaxUtilsTest extends Assert {
         String innerXml =
                 "<inner>\n"
                 + "<body>body text here</body>\n"
-                + "</inner>";
+                + "</inner>\n";
         String xml =
                 "<outer>\n"
-                + innerXml + "\n"
+                + innerXml
                 + "</outer>";
 
         StringReader reader = new StringReader(xml);
@@ -397,7 +397,8 @@ public class StaxUtilsTest extends Assert {
         swriter.flush();
         swriter.close();
 
-        System.out.println(sw.toString());
+        //System.out.println(innerXml);
+        //System.out.println(sw.toString());
         assertEquals(innerXml, sw.toString());
     }    
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/12677573/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalMessageImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalMessageImpl.java
b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalMessageImpl.java
index f9895f7..dfe6ad0 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalMessageImpl.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalMessageImpl.java
@@ -27,7 +27,6 @@ import java.util.logging.Logger;
 import javax.activation.DataSource;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
-import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPMessage;
 import javax.xml.stream.XMLStreamException;
@@ -40,6 +39,7 @@ import javax.xml.ws.LogicalMessage;
 import javax.xml.ws.Service;
 import javax.xml.ws.WebServiceException;
 
+import org.w3c.dom.Document;
 import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -98,15 +98,15 @@ public class LogicalMessageImpl implements LogicalMessage {
 
                 if (source == null) {
                     try {
-                        W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
+                        Document doc = DOMUtils.newDocument();
+                        W3CDOMStreamWriter writer = new W3CDOMStreamWriter(doc.createDocumentFragment());
                         reader = message.getContent(XMLStreamReader.class);
                         //content must be an element thing, skip over any whitespace
                         StaxUtils.toNextTag(reader);
                         StaxUtils.copy(reader, writer, true);
-                        source = new DOMSource(writer.getDocument().getDocumentElement());
-                        reader = StaxUtils.createXMLStreamReader(writer.getDocument());
-                    } catch (ParserConfigurationException e) {
-                        throw new Fault(e);
+                        doc.appendChild(DOMUtils.getFirstElement(writer.getCurrentFragment()));
+                        source = new DOMSource(doc.getDocumentElement());
+                        reader = StaxUtils.createXMLStreamReader(doc.getDocumentElement());
                     } catch (XMLStreamException e) {
                         throw new Fault(e);
                     }
@@ -114,12 +114,7 @@ public class LogicalMessageImpl implements LogicalMessage {
                 message.setContent(XMLStreamReader.class, reader);
                 message.setContent(Source.class, source);
             } else if (!(source instanceof DOMSource)) {
-                W3CDOMStreamWriter writer;
-                try {
-                    writer = new W3CDOMStreamWriter();
-                } catch (ParserConfigurationException e) {
-                    throw new Fault(e);
-                }
+                W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
                 XMLStreamReader reader = message.getContent(XMLStreamReader.class);
                 if (reader == null) {
                     reader = StaxUtils.createXMLStreamReader(source);
@@ -266,8 +261,6 @@ public class LogicalMessageImpl implements LogicalMessage {
             Source source = new DOMSource(writer.getDocument().getDocumentElement());   
        
             
             setPayload(source);
-        } catch (ParserConfigurationException e) {
-            throw new WebServiceException(e);
         } catch (JAXBException e) {
             throw new WebServiceException(e);
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/12677573/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/SignatureWhitespaceTest.java
----------------------------------------------------------------------
diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/SignatureWhitespaceTest.java
b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/SignatureWhitespaceTest.java
index 823d30d..42084f0 100644
--- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/SignatureWhitespaceTest.java
+++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/SignatureWhitespaceTest.java
@@ -84,7 +84,6 @@ public class SignatureWhitespaceTest extends AbstractBusClientServerTestBase
{
     
     // TODO test not working
     @org.junit.Test
-    @org.junit.Ignore
     public void testTrailingWhitespaceInSOAPBody() throws Exception {
         SpringBusFactory bf = new SpringBusFactory();
         URL busFile = SignatureWhitespaceTest.class.getResource("client.xml");


Mime
View raw message