cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1379515 - in /cxf/trunk: rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/ systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/
Date Fri, 31 Aug 2012 17:23:32 GMT
Author: dkulp
Date: Fri Aug 31 17:23:31 2012
New Revision: 1379515

URL: http://svn.apache.org/viewvc?rev=1379515&view=rev
Log:
[CXF-4491] Make sure the fault goes to the faultTo and is handled like a replyTo...

Modified:
    cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
    cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/DecoupledFaultHandler.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/FaultToEndpointServer.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAFaultToClientServerTest.java

Modified: cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java?rev=1379515&r1=1379514&r2=1379515&view=diff
==============================================================================
--- cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
(original)
+++ cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
Fri Aug 31 17:23:31 2012
@@ -883,9 +883,14 @@ public class MAPAggregatorImpl extends M
  
             if (isFault
                 && !ContextUtils.isGenericAddress(inMAPs.getFaultTo())) {
+                
+                Message m = message.getExchange().getInFaultMessage();
+                if (m == null) {
+                    m = message;
+                }
                 InternalContextUtils.rebaseResponse(inMAPs.getFaultTo(),
                                             inMAPs,
-                                            message);
+                                            m);
             }
         }
     }

Modified: cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/DecoupledFaultHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/DecoupledFaultHandler.java?rev=1379515&r1=1379514&r2=1379515&view=diff
==============================================================================
--- cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/DecoupledFaultHandler.java
(original)
+++ cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/DecoupledFaultHandler.java
Fri Aug 31 17:23:31 2012
@@ -67,6 +67,9 @@ public class DecoupledFaultHandler exten
             
             if (maps != null && !ContextUtils.isGenericAddress(maps.getFaultTo()))
{
                 //Just keep the wsa headers to remove the not understand headers
+                if (exchange.getOutMessage() != null) {
+                    message = (SoapMessage)exchange.getOutMessage();
+                }
                 Iterator<Header> iterator = message.getHeaders().iterator();
                 while (iterator.hasNext()) {
                     Header header = iterator.next();

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/FaultToEndpointServer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/FaultToEndpointServer.java?rev=1379515&r1=1379514&r2=1379515&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/FaultToEndpointServer.java
(original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/FaultToEndpointServer.java
Fri Aug 31 17:23:31 2012
@@ -19,6 +19,8 @@
 package org.apache.cxf.systest.ws.addr_feature;
 
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
 import java.util.concurrent.Future;
 
 import javax.jws.WebService;
@@ -50,6 +52,7 @@ import org.eclipse.jetty.server.handler.
 
 public class FaultToEndpointServer extends AbstractBusTestServerBase {  
     static final String FAULT_PORT = allocatePort(FaultToEndpointServer.class);
+    static final String FAULT_PORT2 = allocatePort(FaultToEndpointServer.class, 2);
     static final String PORT = allocatePort(FaultToEndpointServer.class, 1);
    
     EndpointImpl ep;
@@ -113,14 +116,25 @@ public class FaultToEndpointServer exten
         public void handle(String target, Request baseRequest, HttpServletRequest request,
                            HttpServletResponse response) throws IOException, ServletException
{
             response.setContentType("text/html;charset=utf-8");
+            
+            //System.out.println("In handler: " + request.getContentLength());
+            
+            byte bytes[] = new byte[1024];
+            InputStream in = request.getInputStream();
+            while (in.read(bytes) > -1) {
+                //nothing
+            }
+
             faultRequestPath = request.getPathInfo();
             if ("/faultTo".equals(faultRequestPath)) {
-                response.setStatus(HttpServletResponse.SC_OK);
+                response.setStatus(HttpServletResponse.SC_ACCEPTED);
             } else {
                 response.setStatus(HttpServletResponse.SC_NOT_FOUND);
             }
+            PrintWriter writer = response.getWriter();
+            writer.println("Received");
+            writer.close();
             baseRequest.setHandled(true);
-            response.getWriter().println("Received");
         }
 
         public static String getFaultRequestPath() {

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAFaultToClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAFaultToClientServerTest.java?rev=1379515&r1=1379514&r2=1379515&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAFaultToClientServerTest.java
(original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAFaultToClientServerTest.java
Fri Aug 31 17:23:31 2012
@@ -19,6 +19,7 @@
 package org.apache.cxf.systest.ws.addr_feature;
 
 import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
 import java.net.URL;
 import java.util.Map;
 
@@ -26,8 +27,10 @@ import javax.xml.namespace.QName;
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.soap.AddressingFeature;
 
+import org.apache.cxf.frontend.ClientProxy;
 import org.apache.cxf.systest.ws.AbstractWSATestBase;
 import org.apache.cxf.systest.ws.addr_feature.FaultToEndpointServer.HelloHandler;
+import org.apache.cxf.transport.http.HTTPConduit;
 import org.apache.cxf.ws.addressing.AddressingProperties;
 import org.apache.cxf.ws.addressing.AttributedURIType;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
@@ -87,11 +90,15 @@ public class WSAFaultToClientServerTest 
     public void testTwoWayFaultTo() throws Exception {
         ByteArrayOutputStream input = setupInLogging();
         AddNumbersPortType port = getTwoWayPort();
-
+        
+        //setup a real decoupled endpoint that will process the fault correctly
+        HTTPConduit c = (HTTPConduit)ClientProxy.getClient(port).getConduit();
+        c.getClient().setDecoupledEndpoint("http://localhost:" + FaultToEndpointServer.FAULT_PORT2
+ "/sendFaultHere");
+        
         EndpointReferenceType faultTo = new EndpointReferenceType();
         AddressingProperties addrProperties = new AddressingPropertiesImpl();
         AttributedURIType epr = new AttributedURIType();
-        epr.setValue("http://localhost:" + FaultToEndpointServer.FAULT_PORT + "/faultTo");
+        epr.setValue("http://localhost:" + FaultToEndpointServer.FAULT_PORT2 + "/sendFaultHere");
         faultTo.setAddress(epr);
         addrProperties.setFaultTo(faultTo);
         
@@ -107,14 +114,18 @@ public class WSAFaultToClientServerTest 
         } catch (Exception e) {
             //do nothing
         }
-               
-        assertTrue("The response from faultTo endpoint is expected and actual response is
" 
-                   + new String(input.toByteArray()) , 
-                   new String(input.toByteArray()).indexOf("The server sent HTTP status code
:200") > -1);
+
+        String in = new String(input.toByteArray());
+        //System.out.println(in);
+        assertTrue("The response from faultTo endpoint is expected and actual response is
" + in,
+                   in.indexOf("Address: http://localhost:" + FaultToEndpointServer.FAULT_PORT2

+                                     + "/sendFaultHere") > -1);
         assertTrue("WS addressing header is expected", 
-                   new String(input.toByteArray()).indexOf("http://www.w3.org/2005/08/addressing")
> -1);       
+                   in.indexOf("http://www.w3.org/2005/08/addressing") > -1);       
         assertTrue("Fault deatil is expected", 
-                   new String(input.toByteArray()).indexOf("Negative numbers cant be added")
> -1);
+                   in.indexOf("Negative numbers cant be added") > -1);
+        
+        ((Closeable)port).close();
     }
      
     private AddNumbersPortType getTwoWayPort() throws Exception {



Mime
View raw message