cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1357091 - in /cxf/trunk: rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/ systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/
Date Wed, 04 Jul 2012 06:03:58 GMT
Author: ema
Date: Wed Jul  4 06:03:57 2012
New Revision: 1357091

URL: http://svn.apache.org/viewvc?rev=1357091&view=rev
Log:
[CXF-4405]:Fix OneWay faultTo request is not correctly transmitted to the specified address

Modified:
    cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/InternalContextUtils.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/InternalContextUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/InternalContextUtils.java?rev=1357091&r1=1357090&r2=1357091&view=diff
==============================================================================
--- cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/InternalContextUtils.java
(original)
+++ cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/InternalContextUtils.java
Wed Jul  4 06:03:57 2012
@@ -136,6 +136,10 @@ final class InternalContextUtils {
                             in.cacheInput();
                         }
                         inMessage.getInterceptorChain().reset();
+                        //cleanup pathinfo
+                        if (inMessage.get(Message.PATH_INFO) != null) {
+                            inMessage.remove(Message.PATH_INFO);
+                        }
                         inMessage.getInterceptorChain().doIntercept(inMessage);
 
                     }
@@ -246,7 +250,10 @@ final class InternalContextUtils {
                         // has been sent (i.e. to a oneway, or a partial response
                         // to a decoupled twoway)
                         
-        
+                        //cleanup pathinfo
+                        if (inMessage.get(Message.PATH_INFO) != null) {
+                            inMessage.remove(Message.PATH_INFO);
+                        }
                         // pause dispatch on current thread ...
                         inMessage.getInterceptorChain().pause();
 

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=1357091&r1=1357090&r2=1357091&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
Wed Jul  4 06:03:57 2012
@@ -19,23 +19,39 @@
 package org.apache.cxf.systest.ws.addr_feature;
 
 import java.io.IOException;
+import java.util.concurrent.Future;
 
+import javax.jws.WebService;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.Endpoint;
+import javax.xml.ws.Response;
+import javax.xml.ws.soap.Addressing;
 
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 import org.apache.cxf.ws.addressing.WSAddressingFeature;
 import org.apache.cxf.ws.addressing.soap.DecoupledFaultHandler;
+import org.apache.hello_world_soap_http.BadRecordLitFault;
+import org.apache.hello_world_soap_http.Greeter;
+import org.apache.hello_world_soap_http.NoSuchCodeLitFault;
+import org.apache.hello_world_soap_http.types.BareDocumentResponse;
+import org.apache.hello_world_soap_http.types.GreetMeLaterResponse;
+import org.apache.hello_world_soap_http.types.GreetMeResponse;
+import org.apache.hello_world_soap_http.types.GreetMeSometimeResponse;
+import org.apache.hello_world_soap_http.types.SayHiResponse;
+import org.apache.hello_world_soap_http.types.TestDocLitFaultResponse;
+import org.apache.hello_world_soap_http.types.TestNillableResponse;
 import org.eclipse.jetty.server.Request;
 import org.eclipse.jetty.server.handler.AbstractHandler;
 
-public class FaultToEndpointServer extends AbstractBusTestServerBase {
+public class FaultToEndpointServer extends AbstractBusTestServerBase {  
     static final String FAULT_PORT = allocatePort(FaultToEndpointServer.class);
     static final String PORT = allocatePort(FaultToEndpointServer.class, 1);
+   
     EndpointImpl ep;
     private org.eclipse.jetty.server.Server faultToserver;
     protected void run()  { 
@@ -46,16 +62,23 @@ public class FaultToEndpointServer exten
         } catch (Exception e) {
             e.printStackTrace();
         }
+
         
         setBus(BusFactory.getDefaultBus());
         Object implementor = new AddNumberImpl();
         String address = "http://localhost:" + PORT + "/jaxws/add";
-        //Endpoint.publish(address, implementor);
 
         ep = (EndpointImpl) Endpoint.create(implementor);
         ep.getInInterceptors().add(new DecoupledFaultHandler());
         ep.getFeatures().add(new WSAddressingFeature());
-        ep.publish(address);     
+        ep.publish(address); 
+        
+        Object implementor2 = new GreeterImpl();
+        String address2 = "http://localhost:" + PORT + "/jaxws/greeter";
+        ep = (EndpointImpl) Endpoint.create(implementor2);
+        ep.getInInterceptors().add(new DecoupledFaultHandler());
+        ep.getFeatures().add(new WSAddressingFeature());
+        ep.publish(address2);
     }
     
     public void tearDown() throws Exception {
@@ -80,15 +103,135 @@ public class FaultToEndpointServer exten
             System.out.println("done!");
         }
     }
+       
     
-    class HelloHandler extends AbstractHandler {
+
+
+    public static class HelloHandler extends AbstractHandler {
+        private static String faultRequestPath;
+
         public void handle(String target, Request baseRequest, HttpServletRequest request,
                            HttpServletResponse response) throws IOException, ServletException
{
             response.setContentType("text/html;charset=utf-8");
-            response.setStatus(HttpServletResponse.SC_OK);
+            faultRequestPath = request.getPathInfo();
+            if ("/faultTo".equals(faultRequestPath)) {
+                response.setStatus(HttpServletResponse.SC_OK);
+            } else {
+                response.setStatus(HttpServletResponse.SC_NOT_FOUND);
+            }
             baseRequest.setHandled(true);
             response.getWriter().println("Received");
         }
+
+        public static String getFaultRequestPath() {
+            return faultRequestPath;
+        }
+
+    }
+    
+    @WebService(serviceName = "SOAPServiceAddressing", 
+                portName = "SoapPort", 
+                endpointInterface = "org.apache.hello_world_soap_http.Greeter", 
+                targetNamespace = "http://apache.org/hello_world_soap_http",
+                wsdlLocation = "testutils/hello_world.wsdl")
+    @Addressing
+    public class GreeterImpl implements Greeter {
+
+        public String greetMe(String me) {
+            return "Hello " + me;
+        }
+
+        public String greetMeLater(long delay) {
+            if (delay > 0) {
+                try {
+                    Thread.sleep(delay);
+                } catch (InterruptedException ex) {
+                    // ignore
+                }
+            }
+            return "Hello, finally";
+        }
+
+        public void greetMeOneWay(String requestType) {
+            throw new RuntimeException("intended error"); 
+        }
+
+        public String sayHi() {
+            return null;
+        }
+        
+        public void testDocLitFault(String faultType) throws BadRecordLitFault, NoSuchCodeLitFault
{
+        }
+
+        public BareDocumentResponse testDocLitBare(String in) {
+            return null;
+        }
+
+        public String greetMeSometime(String me) {
+            return null;
+        }
+        
+        public Future<?>  greetMeSometimeAsync(String requestType, 
+                                               AsyncHandler<GreetMeSometimeResponse>
asyncHandler) { 
+            return null; 
+        }
+        
+        public Response<GreetMeSometimeResponse> greetMeSometimeAsync(String requestType)
{ 
+            return null; 
+        }
+        
+        public Response<TestDocLitFaultResponse> testDocLitFaultAsync(String faultType)
{  
+            return null; 
+        }
+        
+        public Response<BareDocumentResponse> testDocLitBareAsync(String bare) {
+            return null;
+        }
+        
+        public Future<?> greetMeAsync(String requestType, AsyncHandler<GreetMeResponse>
asyncHandler) { 
+            return null; 
+        }
+        
+        public Response<GreetMeResponse> greetMeAsync(String requestType) { 
+            return null; 
+        }
+        
+        public Future<?> greetMeLaterAsync(long requestType, AsyncHandler<GreetMeLaterResponse>
asyncHandler) { 
+            return null; 
+        }
+        
+        public Response<GreetMeLaterResponse> greetMeLaterAsync(long requestType) {

+            return null; 
+        }
+        
+        public Future<?> sayHiAsync(AsyncHandler<SayHiResponse> asyncHandler)
{ 
+            return null; 
+        }
+        
+        public Response<SayHiResponse> sayHiAsync() { 
+            return null; 
+        }
+
+        public String testNillable(String nillElem, int intElem) {
+            return null;
+        }
+
+        public Response<TestNillableResponse> testNillableAsync(String nillElem,
+                                                                int intElem) {
+            return null;
+        }
+        
+        public Future<?> testNillableAsync(String nillElem, 
+                                           int intElem,
+                                           AsyncHandler<TestNillableResponse> asyncHandler)
{
+            return null;
+        }
+
+        public Future<?> testDocLitFaultAsync(String faultType,
+                                              AsyncHandler<TestDocLitFaultResponse>
asyncHandler) {
+            return null;
+        }
+        
     }
 }   
 

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=1357091&r1=1357090&r2=1357091&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
Wed Jul  4 06:03:57 2012
@@ -27,19 +27,20 @@ import javax.xml.ws.BindingProvider;
 import javax.xml.ws.soap.AddressingFeature;
 
 import org.apache.cxf.systest.ws.AbstractWSATestBase;
+import org.apache.cxf.systest.ws.addr_feature.FaultToEndpointServer.HelloHandler;
 import org.apache.cxf.ws.addressing.AddressingProperties;
 import org.apache.cxf.ws.addressing.AttributedURIType;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 import org.apache.cxf.ws.addressing.JAXWSAConstants;
 import org.apache.cxf.ws.addressing.impl.AddressingPropertiesImpl;
+import org.apache.hello_world_soap_http.Greeter;
+import org.apache.hello_world_soap_http.SOAPService;
 
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
 public class WSAFaultToClientServerTest  extends AbstractWSATestBase {
-    private final QName serviceName = new QName("http://apache.org/cxf/systest/ws/addr_feature/",
-                                                "AddNumbersService");
 
     @Before
     public void setUp() throws Exception {
@@ -50,16 +51,47 @@ public class WSAFaultToClientServerTest 
     public static void startServers() throws Exception {
         assertTrue("FaultTo server did not launch correctly", launchServer(FaultToEndpointServer.class,
true));
     }
+    
+    @Test
+    public void testOneWayFaultTo() throws Exception {
+        URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
+        QName serviceName = new QName("http://apache.org/hello_world_soap_http", "SOAPServiceAddressing");
+
+        Greeter greeter = new SOAPService(wsdl, serviceName).getPort(Greeter.class, new AddressingFeature());
+        EndpointReferenceType faultTo = new EndpointReferenceType();
+        AddressingProperties addrProperties = new AddressingPropertiesImpl();
+        AttributedURIType epr = new AttributedURIType();
+        String faultToAddress = "http://localhost:" + FaultToEndpointServer.FAULT_PORT  +
"/faultTo";
+        epr.setValue(faultToAddress);
+        faultTo.setAddress(epr);
+        addrProperties.setFaultTo(faultTo);
+        
+        BindingProvider provider = (BindingProvider) greeter;
+        Map<String, Object> requestContext = provider.getRequestContext();
+        requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, 
+                           "http://localhost:" + FaultToEndpointServer.PORT + "/jaxws/greeter");
+        requestContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, addrProperties);
 
+        greeter.greetMeOneWay("test");
+        //wait for the fault request
+        int i = 2;
+        while (HelloHandler.getFaultRequestPath() == null && i > 0) {
+            Thread.sleep(500);
+            i--;
+        }
+        assertTrue("FaultTo request fpath isn't expected", 
+                   "/faultTo".equals(HelloHandler.getFaultRequestPath()));
+    }
+    
     @Test
-    public void testJaxwsWsaFeature() throws Exception {
+    public void testTwoWayFaultTo() throws Exception {
         ByteArrayOutputStream input = setupInLogging();
-        AddNumbersPortType port = getPort();
+        AddNumbersPortType port = getTwoWayPort();
 
         EndpointReferenceType faultTo = new EndpointReferenceType();
         AddressingProperties addrProperties = new AddressingPropertiesImpl();
         AttributedURIType epr = new AttributedURIType();
-        epr.setValue("http://localhost:" + FaultToEndpointServer.FAULT_PORT);
+        epr.setValue("http://localhost:" + FaultToEndpointServer.FAULT_PORT + "/faultTo");
         faultTo.setAddress(epr);
         addrProperties.setFaultTo(faultTo);
         
@@ -85,14 +117,16 @@ public class WSAFaultToClientServerTest 
                    new String(input.toByteArray()).indexOf("Negative numbers cant be added")
> -1);
     }
      
-    private AddNumbersPortType getPort() throws Exception {
+    private AddNumbersPortType getTwoWayPort() throws Exception {
         URL wsdl = getClass().getResource("/wsdl_systest_wsspec/add_numbers.wsdl");
         assertNotNull("WSDL is null", wsdl);
-
+        QName serviceName = new QName("http://apache.org/cxf/systest/ws/addr_feature/", "AddNumbersService");
         AddNumbersService service = new AddNumbersService(wsdl, serviceName);
         assertNotNull("Service is null ", service);
         AddNumbersPortType port = service.getAddNumbersPort(new AddressingFeature());
         //updateAddressPort(port, PORT);
         return port;
     }
+    
+    
 }



Mime
View raw message