cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1559173 - in /cxf/trunk: core/src/main/java/org/apache/cxf/helpers/ rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/
Date Fri, 17 Jan 2014 16:33:47 GMT
Author: dkulp
Date: Fri Jan 17 16:33:46 2014
New Revision: 1559173

URL: http://svn.apache.org/r1559173
Log:
[CXF-5493] DOMUtils isn't handling CDATASections when grabbing text content

Added:
    cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/cxf5493.xml
  (with props)
Modified:
    cxf/trunk/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java
    cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/SoapFaultSerializerTest.java

Modified: cxf/trunk/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java?rev=1559173&r1=1559172&r2=1559173&view=diff
==============================================================================
--- cxf/trunk/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java (original)
+++ cxf/trunk/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java Fri Jan 17 16:33:46
2014
@@ -150,7 +150,7 @@ public final class DOMUtils {
         String s = null;
         Node n1 = n.getFirstChild();
         while (n1 != null) {
-            if (n1.getNodeType() == Node.TEXT_NODE) {
+            if (n1.getNodeType() == Node.TEXT_NODE || n1.getNodeType() == Node.CDATA_SECTION_NODE)
{
                 if (b != null) {
                     b.append(((Text)n1).getNodeValue());
                 } else if (s == null) {
@@ -159,7 +159,7 @@ public final class DOMUtils {
                     b = new StringBuilder(s).append(((Text)n1).getNodeValue());
                     s = null;
                 }
-            }
+            } 
             n1 = n1.getNextSibling();
         }
         if (b != null) {

Modified: cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/SoapFaultSerializerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/SoapFaultSerializerTest.java?rev=1559173&r1=1559172&r2=1559173&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/SoapFaultSerializerTest.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/SoapFaultSerializerTest.java
Fri Jan 17 16:33:46 2014
@@ -336,4 +336,48 @@ public class SoapFaultSerializerTest ext
         assertEquals(new QName("http://schemas.xmlsoap.org/ws/2005/02/trust", "FailedAuthentication"),

              fault2.getSubCode());
     }
+    
+    
+    @Test
+    public void testCXF5493() throws Exception {
+
+        SoapMessage m = new SoapMessage(new MessageImpl());
+        m.setVersion(Soap11.getInstance());        
+
+
+        XMLStreamReader reader = StaxUtils.createXMLStreamReader(this.getClass()
+                                                                 .getResourceAsStream("cxf5493.xml"));
+        m.setContent(XMLStreamReader.class, reader);
+        reader.nextTag(); //env
+        reader.nextTag(); //body
+        reader.nextTag(); //fault
+
+        Soap11FaultInInterceptor inInterceptor = new Soap11FaultInInterceptor();
+        inInterceptor.handleMessage(m);
+
+        SoapFault fault2 = (SoapFault)m.getContent(Exception.class);
+        assertNotNull(fault2);
+        assertEquals(Soap11.getInstance().getReceiver(), fault2.getFaultCode());
+        assertEquals("some text containing a xml tag <xml-tag>", fault2.getMessage());
+        
+        
+        
+        m = new SoapMessage(new MessageImpl());
+        m.put(Message.HTTP_REQUEST_METHOD, "POST");
+        m.setVersion(Soap11.getInstance());        
+        reader = StaxUtils.createXMLStreamReader(this.getClass().getResourceAsStream("cxf5493.xml"));
+
+        m.setContent(XMLStreamReader.class, reader);
+
+        new SAAJPreInInterceptor().handleMessage(m);
+        new ReadHeadersInterceptor(null).handleMessage(m);
+        new StartBodyInterceptor().handleMessage(m);
+        new SAAJInInterceptor().handleMessage(m);
+        new Soap11FaultInInterceptor().handleMessage(m);
+
+        fault2 = (SoapFault)m.getContent(Exception.class);
+        assertNotNull(fault2);
+        assertEquals(Soap11.getInstance().getReceiver(), fault2.getFaultCode());
+        assertEquals("some text containing a xml tag <xml-tag>", fault2.getMessage());
+    }
 }

Added: cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/cxf5493.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/cxf5493.xml?rev=1559173&view=auto
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/cxf5493.xml
(added)
+++ cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/cxf5493.xml
Fri Jan 17 16:33:46 2014
@@ -0,0 +1,8 @@
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+   <soap:Fault>
+     <faultcode>soap:Server</faultcode>
+     <faultstring><![CDATA[some text containing a xml tag <xml-tag>]]></faultstring>
+   </soap:Fault>
+ </soap:Body>
+</soap:Envelope>
\ No newline at end of file

Propchange: cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/cxf5493.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/cxf5493.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message