cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1437152 - in /cxf/branches/2.6.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature: FaultToEndpointServer.java WSAFaultToClientServerTest.java
Date Tue, 22 Jan 2013 20:38:08 GMT
Author: ay
Date: Tue Jan 22 20:38:08 2013
New Revision: 1437152

URL: http://svn.apache.org/viewvc?rev=1437152&view=rev
Log:
fix the connection hanging issue for systests/ws-specs

Modified:
    cxf/branches/2.6.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/FaultToEndpointServer.java
    cxf/branches/2.6.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAFaultToClientServerTest.java

Modified: cxf/branches/2.6.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/FaultToEndpointServer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/FaultToEndpointServer.java?rev=1437152&r1=1437151&r2=1437152&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/FaultToEndpointServer.java
(original)
+++ cxf/branches/2.6.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/FaultToEndpointServer.java
Tue Jan 22 20:38:08 2013
@@ -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/branches/2.6.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAFaultToClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAFaultToClientServerTest.java?rev=1437152&r1=1437151&r2=1437152&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAFaultToClientServerTest.java
(original)
+++ cxf/branches/2.6.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAFaultToClientServerTest.java
Tue Jan 22 20:38:08 2013
@@ -27,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;
@@ -88,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);
         
@@ -108,14 +114,16 @@ 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());
+        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();        
     }
      



Mime
View raw message