servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r584075 - in /incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src: main/java/org/apache/servicemix/cxfbc/ main/java/org/apache/servicemix/cxfbc/interceptors/ test/java/org/apache/servicemix/cxfbc/
Date Fri, 12 Oct 2007 06:46:05 GMT
Author: ffang
Date: Thu Oct 11 23:46:04 2007
New Revision: 584075

URL: http://svn.apache.org/viewvc?rev=584075&view=rev
Log:
add fault handle test for cxf bc provider

Modified:
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderTest.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/GreeterImplForProvider.java

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java?rev=584075&r1=584074&r2=584075&view=diff
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java
(original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java
Thu Oct 11 23:46:04 2007
@@ -22,6 +22,7 @@
 import java.util.List;
 
 import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.Fault;
 import javax.jbi.messaging.InOptionalOut;
 import javax.jbi.messaging.InOut;
 import javax.jbi.messaging.MessageExchange;
@@ -103,7 +104,12 @@
             soapMessage.setInterceptorChain(inChain);
             inChain.doIntercept(soapMessage);
             
-            if (messageExchange instanceof InOut) {
+            if (soapMessage.get("jbiFault") != null 
+                    &&  soapMessage.get("jbiFault").equals(true)) {
+                Fault fault = messageExchange.createFault();
+                fault.setContent(soapMessage.getContent(Source.class));
+                messageExchange.setFault(fault);
+            } else  if (messageExchange instanceof InOut) {
                 NormalizedMessage msg = messageExchange.createMessage();
                 msg.setContent(soapMessage.getContent(Source.class));
                 messageExchange.setMessage(msg, "out");

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java?rev=584075&r1=584074&r2=584075&view=diff
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
(original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
Thu Oct 11 23:46:04 2007
@@ -32,6 +32,8 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import org.apache.cxf.binding.jbi.JBIConstants;
+import org.apache.cxf.binding.jbi.JBIFault;
 import org.apache.cxf.binding.soap.SoapHeader;
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
@@ -58,7 +60,6 @@
 public class JbiInWsdl1Interceptor extends AbstractSoapInterceptor {
 
     public JbiInWsdl1Interceptor() {
-        //super(Phase.UNMARSHAL);
         super(Phase.PRE_INVOKE);
         addAfter(JbiOperationInterceptor.class.getName());
     }
@@ -102,9 +103,15 @@
         if (style == null) {
             style = binding.getStyle();
         }
+
+        
         Element body = getBodyElement(message);
         if (body == null) {
-            //SOAP:Body is empty
+            return;
+        }
+        
+        if (body.getLocalName().equals("Fault")) {
+            handleJBIFault(message, body);
             return;
         }
         List<SoapHeaderInfo> headers = wsdlMessage.getExtensors(SoapHeaderInfo.class);
@@ -131,6 +138,21 @@
                 }
             }
         }
+        processHeader(message, headers, headerElement, parts);
+        for (Object part : parts) {
+            if (part instanceof Node) {
+                addPart(root, (Node) part);
+            } else if (part instanceof NodeList) {
+                addPart(root, (NodeList) part);
+            } else if (part instanceof SoapHeader) {
+                addPart(root, (Node)((SoapHeader)part).getObject());
+            }
+        }
+        
+        message.setContent(Source.class, new DOMSource(document));
+    }
+
+    private void processHeader(SoapMessage message, List<SoapHeaderInfo> headers, List<Header>
headerElement, List<Object> parts) {
         if (headers != null) {
             for (SoapHeaderInfo header : headers) {
                 MessagePartInfo part = header.getPart();
@@ -151,17 +173,19 @@
                 }
             }
         }
-        for (Object part : parts) {
-            if (part instanceof Node) {
-                addPart(root, (Node) part);
-            } else if (part instanceof NodeList) {
-                addPart(root, (NodeList) part);
-            } else if (part instanceof SoapHeader) {
-                addPart(root, (Node)((SoapHeader)part).getObject());
-            }
-        }
+    }
+
+    private void handleJBIFault(SoapMessage message, Element soapFault) {
+        Document doc = DomUtil.createDocument();
         
-        message.setContent(Source.class, new DOMSource(document));
+        Element jbiFault = DomUtil.createElement(doc, new QName(JBIConstants.NS_JBI_BINDING,
JBIFault.JBI_FAULT_ROOT));
+        /*Node jbiFaultString = doc.importNode(soapFault.getElementsByTagName(
+                JBIFault.JBI_FAULT_STRING).item(0), true);
+        jbiFault.appendChild(jbiFaultString);*/
+        Node jbiFaultDetail = doc.importNode(soapFault.getElementsByTagName(JBIFault.JBI_FAULT_DETAIL).item(0).getFirstChild(),
true);
+        jbiFault.appendChild(jbiFaultDetail);
+        message.setContent(Source.class, new DOMSource(doc));
+        message.put("jbiFault", true);
     }
 
     private NodeList wrapNodeList(final NodeList childNodes) {
@@ -196,6 +220,8 @@
             throw new Fault(e);
         }
     }
+    
+    
     
     protected Header getHeaderElement(SoapMessage message, QName name) {
         Exchange exchange = message.getExchange();

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderTest.java?rev=584075&r1=584074&r2=584075&view=diff
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderTest.java
(original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderTest.java
Thu Oct 11 23:46:04 2007
@@ -91,7 +91,7 @@
               + "</message>"));
         client.sendSync(io);
         assertTrue(new SourceTransformer().contentToString(
-                io.getOutMessage()).indexOf("Hello ffang 3") > 0);
+                io.getOutMessage()).indexOf("Hello ffang 3Negative number cant be added!")
>= 0);
     }
     
     @Override

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/GreeterImplForProvider.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/GreeterImplForProvider.java?rev=584075&r1=584074&r2=584075&view=diff
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/GreeterImplForProvider.java
(original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/GreeterImplForProvider.java
Thu Oct 11 23:46:04 2007
@@ -19,6 +19,7 @@
 import javax.jbi.component.ComponentContext;
 import javax.jws.WebService;
 
+import org.apache.cxf.calculator.AddNumbersFault;
 import org.apache.cxf.calculator.CalculatorPortType;
 
 @WebService(serviceName = "SOAPService", 
@@ -30,13 +31,16 @@
     private ComponentContext context;
     private CalculatorPortType calculator;
     public String greetMe(String me) {
-        int ret = 0;
+        String ret = "";
         try {
             
-            ret = getCalculator().add(1, 2);
+            ret = ret + getCalculator().add(1, 2);
+            ret = ret + getCalculator().add(1, -1);
                         
-        } catch (Exception e) {
-            e.printStackTrace();
+        } catch (AddNumbersFault e) {
+            //should catch exception here
+            
+            ret = ret + e.getFaultInfo().getMessage();
         }
         return "Hello " + me  + " " + ret;
     }



Mime
View raw message