cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [1/5] cxf git commit: Adding @Ignore'd unit test for CXF-6900
Date Tue, 17 May 2016 15:13:23 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes e2fb04839 -> 43caf8316


Adding @Ignore'd unit test for CXF-6900


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

Branch: refs/heads/3.1.x-fixes
Commit: d07ed4764ef8a4c0d29bd895663c735c794398e2
Parents: e2fb048
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Tue May 17 12:43:58 2016 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Tue May 17 16:02:09 2016 +0100

----------------------------------------------------------------------
 .../cxf/binding/soap/saaj/ParseBodyTest.java    | 61 ++++++++++++++++++++
 .../cxf/binding/soap/saaj/soap12-fault.xml      |  6 ++
 2 files changed, 67 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d07ed476/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/ParseBodyTest.java
----------------------------------------------------------------------
diff --git a/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/ParseBodyTest.java
b/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/ParseBodyTest.java
index 4e8d5bc..bcdb6f9 100644
--- a/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/ParseBodyTest.java
+++ b/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/ParseBodyTest.java
@@ -20,12 +20,25 @@ package org.apache.cxf.binding.soap.saaj;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
 
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPConstants;
 import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.dom.DOMSource;
 
+import org.w3c.dom.Document;
+
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.helpers.DOMUtils.NullResolver;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.staxutils.StaxUtils;
 import org.junit.Assert;
 import org.junit.Test;
@@ -71,6 +84,43 @@ public class ParseBodyTest extends Assert {
     public void testUsingStaxUtilsCopyWithSAAJWriterData2() throws Exception {
         testUsingStaxUtilsCopyWithSAAJWriter(2);
     }
+    
+    // TODO - See CXF-6900
+    @Test
+    @org.junit.Ignore
+    public void testReadSOAPFault() throws Exception {
+        InputStream inStream = getClass().getResourceAsStream("soap12-fault.xml");
+        Document doc = StaxUtils.read(inStream);
+
+        SoapMessage msg = new SoapMessage(new MessageImpl());
+        Exchange ex = new ExchangeImpl();
+        ex.setInMessage(msg);
+        
+        SOAPMessage saajMsg = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createMessage();
+        SOAPPart part = saajMsg.getSOAPPart();
+        part.setContent(new DOMSource(doc));
+        saajMsg.saveChanges();
+
+        msg.setContent(SOAPMessage.class, saajMsg);
+        doc = part;
+        
+        // System.out.println("OUTPUT: " + StaxUtils.toString(doc));
+        
+        byte[] docbytes = getMessageBytes(doc);
+        XMLStreamReader reader = StaxUtils.createXMLStreamReader(new ByteArrayInputStream(docbytes));
+
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+
+        dbf.setValidating(false);
+        dbf.setIgnoringComments(false);
+        dbf.setIgnoringElementContentWhitespace(true);
+        dbf.setNamespaceAware(true);
+
+        DocumentBuilder db = dbf.newDocumentBuilder();
+        db.setEntityResolver(new NullResolver());
+        doc = StaxUtils.read(db, reader, false);
+
+    }
 
     private void testUsingStaxUtilsCopyWithSAAJWriter(int n) throws Exception {
         prepare(n);
@@ -86,4 +136,15 @@ public class ParseBodyTest extends Assert {
         //System.out.println("UsingStaxUtilsCopyWithSAAJWriter: " + result);
         assertEquals(DATA[n], result);
     }
+    
+    private byte[] getMessageBytes(Document doc) throws Exception {
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+
+        XMLStreamWriter byteArrayWriter = StaxUtils.createXMLStreamWriter(outputStream);
+
+        StaxUtils.writeDocument(doc, byteArrayWriter, false);
+
+        byteArrayWriter.flush();
+        return outputStream.toByteArray();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/d07ed476/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/saaj/soap12-fault.xml
----------------------------------------------------------------------
diff --git a/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/saaj/soap12-fault.xml
b/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/saaj/soap12-fault.xml
new file mode 100644
index 0000000..7539a49
--- /dev/null
+++ b/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/saaj/soap12-fault.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <s:Body>
+        <Fault xmlns="http://www.w3.org/2003/05/soap-envelope"><Code><Value>Receiver</Value></Code><Reason><Text
xml:lang="en">Error Message.</Text></Reason></Fault>
+    </s:Body>
+</s:Envelope>


Mime
View raw message