cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1153196 - in /cxf/branches/2.4.x-fixes: ./ systests/uncategorized/src/test/java/org/apache/cxf/systest/lifecycle/LifeCycleTest.java
Date Tue, 02 Aug 2011 17:02:29 GMT
Author: dkulp
Date: Tue Aug  2 17:02:28 2011
New Revision: 1153196

URL: http://svn.apache.org/viewvc?rev=1153196&view=rev
Log:
Merged revisions 1153155 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1153155 | dkulp | 2011-08-02 11:02:09 -0400 (Tue, 02 Aug 2011) | 1 line
  
  [CXF-3697] Add test case for client lifecycle events
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/lifecycle/LifeCycleTest.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.4.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/lifecycle/LifeCycleTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/lifecycle/LifeCycleTest.java?rev=1153196&r1=1153195&r2=1153196&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/lifecycle/LifeCycleTest.java
(original)
+++ cxf/branches/2.4.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/lifecycle/LifeCycleTest.java
Tue Aug  2 17:02:28 2011
@@ -22,13 +22,18 @@ package org.apache.cxf.systest.lifecycle
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.jws.WebService;
+import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Endpoint;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.ClientLifeCycleListener;
+import org.apache.cxf.endpoint.ClientLifeCycleManager;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.endpoint.ServerLifeCycleListener;
 import org.apache.cxf.endpoint.ServerLifeCycleManager;
@@ -36,6 +41,7 @@ import org.apache.cxf.feature.AbstractFe
 import org.apache.cxf.greeter_control.ControlImpl;
 import org.apache.cxf.testutil.common.TestUtil;
 import org.apache.cxf.ws.addressing.WSAddressingFeature;
+import org.apache.hello_world_soap_http.Greeter;
 
 import org.junit.After;
 import org.junit.Assert;
@@ -81,6 +87,43 @@ public class LifeCycleTest extends Asser
         bus.shutdown(true);
     }
     
+    @Test 
+    public void testClientLifecycle() throws Exception {
+        final AtomicBoolean created = new AtomicBoolean();
+        final AtomicBoolean destroyed = new AtomicBoolean();
+        
+        bus.getExtension(ClientLifeCycleManager.class)
+            .registerListener(new ClientLifeCycleListener() {
+                public void clientCreated(Client client) {
+                    created.set(true);
+                }
+
+                public void clientDestroyed(Client client) {
+                    destroyed.set(true);
+                }
+            });
+        
+        org.apache.hello_world_soap_http.SOAPService service 
+            = new org.apache.hello_world_soap_http.SOAPService();
+        
+        Greeter client = service.getSoapPort();
+        ((BindingProvider)client).getRequestContext()
+            .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+                 ADDRESSES[0]);
+        assertTrue("clientCreated not called", created.get());
+        client = null;
+        int count = 0;
+        while (count < 10 && !destroyed.get()) {
+            System.gc();
+            System.runFinalization();
+            count++;
+            if (count > 5) {
+                Thread.sleep(100);
+            }
+        }
+        assertTrue("clientDestroyed not called", destroyed.get());
+    }
+    
     @Test
     public void testRecursive() {        
         assertNotNull("unexpected non-null ServerLifeCycleManager", manager);
@@ -155,8 +198,8 @@ public class LifeCycleTest extends Asser
         greeter.stop();
         control.stop();
         for (int i = 0; i < 2; i++) {
-            verifyNotification(startNotificationMap, ADDRESSES[0], 1);
-            verifyNotification(stopNotificationMap, ADDRESSES[0], 1);
+            verifyNotification(startNotificationMap, ADDRESSES[i], 1);
+            verifyNotification(stopNotificationMap, ADDRESSES[i], 1);
         }
     }
     



Mime
View raw message