You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2011/08/02 17:02:10 UTC
svn commit: r1153155 -
/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/lifecycle/LifeCycleTest.java
Author: dkulp
Date: Tue Aug 2 15:02:09 2011
New Revision: 1153155
URL: http://svn.apache.org/viewvc?rev=1153155&view=rev
Log:
[CXF-3697] Add test case for client lifecycle events
Modified:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/lifecycle/LifeCycleTest.java
Modified: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/lifecycle/LifeCycleTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/lifecycle/LifeCycleTest.java?rev=1153155&r1=1153154&r2=1153155&view=diff
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/lifecycle/LifeCycleTest.java (original)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/lifecycle/LifeCycleTest.java Tue Aug 2 15:02:09 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);
}
}