servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r792813 - in /servicemix/components/bindings/servicemix-cxf-bc/trunk/src: main/java/org/apache/servicemix/cxfbc/interceptors/ test/java/org/apache/servicemix/cxfbc/interceptors/ test/resources/org/apache/servicemix/cxfbc/
Date Fri, 10 Jul 2009 06:21:52 GMT
Author: ffang
Date: Fri Jul 10 06:21:51 2009
New Revision: 792813

URL: http://svn.apache.org/viewvc?rev=792813&view=rev
Log:
[SMXCOMP-585]add test for this fix

Added:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/interceptors/ReviseFaultInterceptor.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/soap-fault.xml
Modified:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider.xml

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java?rev=792813&r1=792812&r2=792813&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
(original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
Fri Jul 10 06:21:51 2009
@@ -243,12 +243,12 @@
             
         } else {
             NodeList nodeList = soapFault.getElementsByTagName("soap:Code");
-            String faultCode = nodeList.item(0).getFirstChild().getTextContent();
+            String faultCode = DomUtil.getFirstChildElement(nodeList.item(0)).getTextContent();
             String prefix = faultCode.substring(0, faultCode.indexOf(":"));
             String localName = faultCode.substring(faultCode.indexOf(":") + 1);
             message.put("faultcode", new QName(prefix, localName));
             nodeList = soapFault.getElementsByTagName("soap:Reason");
-            message.put("faultstring", nodeList.item(0).getFirstChild().getTextContent());
+            message.put("faultstring", DomUtil.getFirstChildElement(nodeList.item(0)).getTextContent());
             nodeList = soapFault.getElementsByTagName("soap:Detail");
             if (nodeList != null && nodeList.getLength() > 0
                 && DomUtil.getFirstChildElement(nodeList.item(0)) != null) {
@@ -256,7 +256,7 @@
             } else {
                 message.put("hasdetail", false);
                 nodeList = soapFault.getElementsByTagName("faultstring");
-                jbiFaultDetail = doc.importNode(nodeList.item(0).getFirstChild(), true);
+                jbiFaultDetail = doc.importNode(DomUtil.getFirstChildElement(nodeList.item(0)),
true);
             }
             
         }

Added: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/interceptors/ReviseFaultInterceptor.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/interceptors/ReviseFaultInterceptor.java?rev=792813&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/interceptors/ReviseFaultInterceptor.java
(added)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/interceptors/ReviseFaultInterceptor.java
Fri Jul 10 06:21:51 2009
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.cxfbc.interceptors;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+
+public class ReviseFaultInterceptor extends AbstractPhaseInterceptor<Message> {
+
+    public ReviseFaultInterceptor() {
+        super(Phase.RECEIVE);
+        addAfter(LoggingInInterceptor.class.getName());
+    }
+
+    public void handleMessage(Message message) throws Fault {
+        InputStream is = message.getContent(InputStream.class);
+        if (is != null) {
+            CachedOutputStream bos = new CachedOutputStream();
+            try {
+                IOUtils.copy(is, bos);
+
+                bos.flush();
+                is.close();
+                message.setContent(InputStream.class, bos.getInputStream());
+                bos.close();
+                String soapMessage = new String(bos.getBytes());
+                if (soapMessage.indexOf("Negative number cant be added!") >= 0) {
+                    is = getClass().getClassLoader().getResourceAsStream(
+                            "org/apache/servicemix/cxfbc/soap-fault.xml");
+                    if (is != null) {
+                        message.setContent(InputStream.class, is);
+                    }
+                }
+            } catch (IOException e) {
+                throw new Fault(e);
+            }
+        }
+
+    }
+
+}

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider.xml?rev=792813&r1=792812&r2=792813&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider.xml
(original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider.xml
Fri Jul 10 06:21:51 2009
@@ -38,6 +38,7 @@
                     >
                 <cxfbc:inInterceptors>
                     <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+                    <bean class="org.apache.servicemix.cxfbc.interceptors.ReviseFaultInterceptor"/>
                 </cxfbc:inInterceptors>
                 <cxfbc:outInterceptors>
                     <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>

Added: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/soap-fault.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/soap-fault.xml?rev=792813&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/soap-fault.xml
(added)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/soap-fault.xml
Fri Jul 10 06:21:51 2009
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
+	<soap:Body>
+		<soap:Fault>
+			<soap:Code>
+				<soap:Value>soap:Receiver</soap:Value>
+			</soap:Code>
+			<soap:Reason>
+				<soap:Text xml:lang ="en">Negative number cant be added!</soap:Text>
+			</soap:Reason>
+			<soap:Detail>
+				<CalculatorFault xmlns="http://apache.org/cxf/calculator/types">
+					<faultInfo>Numbers: 1, -1</faultInfo>
+					<message>Negative number cant be added!</message>
+				</CalculatorFault>
+			</soap:Detail>
+		</soap:Fault>
+	</soap:Body>
+</soap:Envelope>



Mime
View raw message