cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1004725 - in /cxf/trunk/common/common/src: main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java test/java/org/apache/cxf/staxutils/StaxUtilsTest.java
Date Tue, 05 Oct 2010 17:23:58 GMT
Author: dkulp
Date: Tue Oct  5 17:23:58 2010
New Revision: 1004725

URL: http://svn.apache.org/viewvc?rev=1004725&view=rev
Log:
[CXF-3034] Fix issue with StaxUtils and DOMs with comments

Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
    cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java?rev=1004725&r1=1004724&r2=1004725&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
Tue Oct  5 17:23:58 2010
@@ -27,6 +27,7 @@ import javax.xml.stream.XMLStreamExcepti
 
 import org.w3c.dom.Attr;
 
+import org.w3c.dom.Comment;
 import org.w3c.dom.Document;
 import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.Element;
@@ -330,6 +331,8 @@ public class W3CDOMStreamReader extends 
     public String getText() {
         if (content instanceof Text) {
             return ((Text)content).getData();
+        } else if (content instanceof Comment) {
+            return ((Comment)content).getData();
         }
         return DOMUtils.getRawContent(getCurrentNode());
     }

Modified: cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java?rev=1004725&r1=1004724&r2=1004725&view=diff
==============================================================================
--- cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java (original)
+++ cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java Tue
Oct  5 17:23:58 2010
@@ -50,7 +50,15 @@ public class StaxUtilsTest extends Asser
     private InputStream getTestStream(String resource) {
         return getClass().getResourceAsStream(resource);
     }
-
+    @Test
+    public void testCommentNode() throws Exception {
+        //CXF-3034
+        Document document = DocumentBuilderFactory.newInstance()
+            .newDocumentBuilder().newDocument();
+        Element root = document.createElementNS("urn:test", "root");
+        root.appendChild(document.createComment("test comment"));
+        StaxUtils.copy(StaxUtils.createXMLStreamReader(root), StaxUtils.createXMLStreamWriter(System.out));
+    }
     @Test
     public void testToNextElement() {
         String soapMessage = "./resources/sayHiRpcLiteralReq.xml";



Mime
View raw message