cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [2/4] git commit: Add a test for the possible growing MAPCodec leak
Date Tue, 07 Oct 2014 16:57:10 GMT
Add a test for the possible growing MAPCodec leak


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/96e6fa6b
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/96e6fa6b
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/96e6fa6b

Branch: refs/heads/3.0.x-fixes
Commit: 96e6fa6b664d8dfb1f5a5662a0907cfb60682da5
Parents: 94022f9
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed Sep 24 19:34:01 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Tue Oct 7 12:57:02 2014 -0400

----------------------------------------------------------------------
 .../cxf/systest/ws/addr_wsdl/AddNumberImpl.java |  7 +++
 .../systest/ws/addr_wsdl/WSAPureWsdlTest.java   | 63 ++++++++++++++++++++
 2 files changed, 70 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/96e6fa6b/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/AddNumberImpl.java
----------------------------------------------------------------------
diff --git a/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/AddNumberImpl.java
b/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/AddNumberImpl.java
index e69539d..1f29d56 100644
--- a/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/AddNumberImpl.java
+++ b/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/AddNumberImpl.java
@@ -48,6 +48,13 @@ public class AddNumberImpl implements AddNumbersPortType {
     }
 
     int execute(int number1, int number2) throws AddNumbersFault_Exception {
+        if (number1 == 5092) {
+            try {
+                Thread.sleep(2000);
+            } catch (InterruptedException e) {
+                //ignore
+            }
+        }
         if (number1 < 0 || number2 < 0) {
             AddNumbersFault fb = new AddNumbersFault();
             fb.setDetail("Negative numbers cant be added!");

http://git-wip-us.apache.org/repos/asf/cxf/blob/96e6fa6b/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/WSAPureWsdlTest.java
----------------------------------------------------------------------
diff --git a/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/WSAPureWsdlTest.java
b/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/WSAPureWsdlTest.java
index 51e333b..d82c6ad 100644
--- a/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/WSAPureWsdlTest.java
+++ b/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/WSAPureWsdlTest.java
@@ -28,6 +28,7 @@ import java.util.concurrent.ExecutionException;
 import javax.xml.namespace.QName;
 import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Dispatch;
 import javax.xml.ws.Response;
@@ -43,6 +44,7 @@ import org.apache.cxf.systest.ws.AbstractWSATestBase;
 import org.apache.cxf.systest.ws.addr_feature.AddNumbersPortType;
 import org.apache.cxf.systest.ws.addr_feature.AddNumbersResponse;
 import org.apache.cxf.systest.ws.addr_feature.AddNumbersService;
+import org.apache.cxf.transport.http.HTTPConduit;
 import org.apache.cxf.ws.addressing.ContextUtils;
 import org.apache.cxf.ws.addressing.soap.MAPCodec;
 
@@ -52,6 +54,7 @@ import org.junit.Test;
 
 public class WSAPureWsdlTest extends AbstractWSATestBase {
     static final String PORT = allocatePort(Server.class);
+    static final String PORT2 = allocatePort(Server.class, 1);
     
     private final QName serviceName = new QName("http://apache.org/cxf/systest/ws/addr_feature/",
                                                 "AddNumbersService");
@@ -67,6 +70,66 @@ public class WSAPureWsdlTest extends AbstractWSATestBase {
     }
 
     @Test
+    public void testBasicInvocationTimeouts() throws Exception {
+        AddNumbersPortType port = getPort();
+
+        ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,

+                                                        "http://localhost:" + PORT + "/jaxws/add");
+        HTTPConduit conduit = (HTTPConduit)((Client)port).getConduit();
+        conduit.getClient().setConnectionTimeout(25);
+        conduit.getClient().setReceiveTimeout(10);
+        
+        try {
+            //read timeout
+            port.addNumbersAsync(5092, 25).get();
+            fail("should have failed");
+        } catch (Exception t) {
+            //expected
+            assertTrue(t.getCause().toString(), t.getCause() instanceof  java.net.SocketTimeoutException);
+        }
+        
+        AsyncHandler<AddNumbersResponse> handler = new AsyncHandler<AddNumbersResponse>()
{
+            public void handleResponse(Response<AddNumbersResponse> res) {
+                //System.out.println("in handle response");
+                synchronized (this) {
+                    notifyAll();
+                }
+            }
+        };
+        synchronized (handler) {
+            port.addNumbersAsync(5092,  25, handler);
+            handler.wait(1000);
+        }
+        
+        try {
+            //connection timeout
+            ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,

+                                                            "http://localhost:" + PORT2 +
"/jaxws/add");
+            port.addNumbersAsync(25, 25).get();
+            fail("should have failed");
+        } catch (Exception t) {
+            //expected
+            assertTrue(t.getCause().getCause().toString(),
+                       t.getCause().getCause() instanceof  java.net.ConnectException);
+        }
+        synchronized (handler) {
+            port.addNumbersAsync(25,  25, handler);
+            handler.wait(1000);
+        }
+        MAPCodec mp = getMAPCodec((Client)port);
+        assertEquals(0, mp.getUncorrelatedExchanges().size());
+    }
+    
+    MAPCodec getMAPCodec(Client port) {
+        for (Interceptor<? extends Message> f : port.getOutInterceptors()) {
+            if (f instanceof MAPCodec) {
+                return (MAPCodec)f;
+            }
+        }
+        return null;
+    }
+    
+    @Test
     public void testBasicInvocation() throws Exception {
         ByteArrayOutputStream input = setupInLogging();
         ByteArrayOutputStream output = setupOutLogging();


Mime
View raw message