cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andreasm...@apache.org
Subject svn commit: r481250 - in /incubator/cxf/trunk: rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ systests/src/test/java/org/apache/cxf/systest/ws/rm/
Date Fri, 01 Dec 2006 14:28:40 GMT
Author: andreasmyth
Date: Fri Dec  1 06:28:35 2006
New Revision: 481250

URL: http://svn.apache.org/viewvc?view=rev&rev=481250
Log:
Fixed SequenceTest to not make assumptions about the ordering of partial vs. full responses.
Cancelled outstanding deferred acknowledgement timer tasks upon shutdown.

Modified:
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/DestinationSequence.java
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java

Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/DestinationSequence.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/DestinationSequence.java?view=diff&rev=481250&r1=481249&r2=481250
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/DestinationSequence.java
(original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/DestinationSequence.java
Fri Dec  1 06:28:35 2006
@@ -296,6 +296,16 @@
         destination.getManager().getTimer().schedule(da, delay);
         LOG.fine("Scheduled acknowledgment to be sent in " + delay + " ms");
     }
+    
+    synchronized void cancelDeferredAcknowledgments() {
+        if (null == deferredAcknowledgments) {
+            return;
+        }
+        for (int i = deferredAcknowledgments.size() - 1; i >= 0; i--) {
+            DeferredAcknowledgment da = deferredAcknowledgments.get(i);
+            da.cancel();
+        }
+    }
 
     final class DeferredAcknowledgment extends TimerTask {
 

Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java?view=diff&rev=481250&r1=481249&r2=481250
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java Fri Dec
 1 06:28:35 2006
@@ -26,6 +26,7 @@
 import java.util.Timer;
 
 import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import javax.annotation.Resource;
 
 import org.apache.cxf.Bus;
@@ -191,6 +192,27 @@
         }
 
         return seq;
+    }
+    
+    @PreDestroy
+    public void shutdown() {
+        // shutdown retransmission queue
+        if (null != retransmissionQueue) {
+            retransmissionQueue.stop();
+        }
+        
+        // cancel outstanding timer tasks (deferred acknowledgements) for all destination
sequences
+        for (RMEndpoint rme : reliableEndpoints.values()) {
+            for (DestinationSequence ds : rme.getDestination().getAllSequences()) {
+                ds.cancelDeferredAcknowledgments();
+            }
+        }
+        
+        // TODO: cancel outstanding timer tasks (acknowledgment requests) for all source
sequences
+        
+        // remove references to timer tasks cancelled above to make them eligible for garbage
collection
+        timer.purge();
+        
     }
 
     @PostConstruct

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java?view=diff&rev=481250&r1=481249&r2=481250
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java
Fri Dec  1 06:28:35 2006
@@ -34,7 +34,6 @@
 import org.apache.cxf.greeter_control.types.StartGreeterResponse;
 import org.apache.cxf.greeter_control.types.StopGreeterResponse;
 import org.apache.cxf.ws.rm.RMManager;
-import org.apache.cxf.ws.rm.RetransmissionQueue;
 
 
 @WebService(serviceName = "ControlService", 
@@ -76,10 +75,7 @@
         endpoint = null;
         if (null != greeterBus) {
             RMManager manager = greeterBus.getExtension(RMManager.class);
-            RetransmissionQueue queue = manager.getRetransmissionQueue();
-            if (null != queue) {
-                queue.stop();
-            }
+            manager.shutdown();
             greeterBus.shutdown(true);
         }
         return true;

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java?view=diff&rev=481250&r1=481249&r2=481250
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
Fri Dec  1 06:28:35 2006
@@ -35,7 +35,6 @@
 import org.apache.cxf.systest.common.ClientServerTestBase;
 import org.apache.cxf.ws.rm.RMConstants;
 import org.apache.cxf.ws.rm.RMManager;
-import org.apache.cxf.ws.rm.RetransmissionQueue;
 
 
 /**
@@ -92,25 +91,12 @@
             }
         };
     }
-
-    public void setUp() throws Exception {
-        SpringBusFactory bf = new SpringBusFactory();
-        controlBus = bf.createBus();
-        bf.setDefaultBus(controlBus);
-        controlBus = new SpringBusFactory().getDefaultBus();
-
-        ControlService service = new ControlService();
-        control = service.getControlPort();
-    }
     
     public void tearDown() {
         if (null != greeter) {
             assertTrue("Failed to stop greeter.", control.stopGreeter());               
        
             RMManager manager = greeterBus.getExtension(RMManager.class);
-            RetransmissionQueue queue = manager.getRetransmissionQueue();
-            if (null != queue) {
-                queue.stop();
-            }
+            manager.shutdown();
             greeterBus.shutdown(true);
             greeterBus = null;
         }
@@ -212,17 +198,20 @@
         mf.verifyActions(expectedActions, true);
         mf.verifyMessageNumbers(new String[] {null, "1", "2"}, true);
 
-        // CreateSequenceResponse plus two partial responses, no
+        // CreateSequenceResponse plus three partial responses, no
         // acknowledgments included
 
         mf.verifyMessages(4, false);
-        expectedActions = new String[] {null, RMConstants.getCreateSequenceResponseAction(),

-                                        null, null};
-        expectedActions = new String[] {RMConstants.getCreateSequenceResponseAction()};
-        mf.verifyActionsIgnoringPartialResponses(expectedActions);
         mf.verifyMessageNumbers(new String[4], false);
         mf.verifyAcknowledgements(new boolean[4], false);
-
+        
+        mf.verifyPartialResponses(3);        
+        mf.purgePartialResponses();
+  
+        expectedActions = new String[] {RMConstants.getCreateSequenceResponseAction()};
+        mf.verifyActionsIgnoringPartialResponses(expectedActions);
+        mf.purge();
+        
         try {
             Thread.sleep(3 * 1000);
         } catch (InterruptedException ex) {
@@ -232,7 +221,7 @@
         // a standalone acknowledgement should have been sent from the server
         // side by now
         
-        awaitMessages(3, 5);
+        awaitMessages(0, 1);
         mf.reset(outRecorder.getOutboundMessages(), inRecorder.getInboundMessages());
 
         mf.verifyMessages(0, true);
@@ -402,34 +391,32 @@
         mf.verifyAcknowledgements(new boolean[3], true);
 
         // CreateSequenceResponse plus 2 greetMeResponse messages plus
-        // one partial response for each of the four messages no acknowledgments
+        // one partial response for each of the three messages no acknowledgments
         // included
 
         mf.verifyMessages(6, false);
-        expectedActions = new String[] {null, 
-                                        RMConstants.getCreateSequenceResponseAction(), 
-                                        null,
-                                        GREETME_RESPONSE_ACTION,
-                                        null, 
-                                        GREETME_RESPONSE_ACTION};
-        mf.verifyActions(expectedActions, false);
-        mf.verifyMessageNumbers(new String[] {null, null, null, "1", null, "2"}, false);
         mf.verifyLastMessage(new boolean[6], false);
         mf.verifyAcknowledgements(new boolean[6], false);
+        
+        mf.verifyPartialResponses(3);
+        mf.purgePartialResponses();
+        expectedActions = new String[] {RMConstants.getCreateSequenceResponseAction(), 
+                                        GREETME_RESPONSE_ACTION, 
+                                        GREETME_RESPONSE_ACTION};
+        mf.verifyActions(expectedActions, false);
+        mf.verifyMessageNumbers(new String[] {null, "1", "2"}, false);
+        mf.purge();
+        
 
         // one standalone acknowledgement should have been sent from the client and one
         // should have been received from the server
    
-        awaitMessages(4, 7, 3000);
+        awaitMessages(1, 0);
         mf.reset(outRecorder.getOutboundMessages(), inRecorder.getInboundMessages());
         
         mf.verifyMessageNumbers(new String[1], true);
         mf.verifyLastMessage(new boolean[1], true);
         mf.verifyAcknowledgements(new boolean[] {true}, true);
-        
-        mf.verifyMessageNumbers(new String[1], true);
-        mf.verifyLastMessage(new boolean[1], true);
-        mf.verifyAcknowledgements(new boolean[] {true}, true);
 
     }
     
@@ -613,6 +600,14 @@
     private void setupGreeter(String cfgResource) {
         
         SpringBusFactory bf = new SpringBusFactory();
+        
+        controlBus = bf.createBus();
+        bf.setDefaultBus(controlBus);
+        controlBus = new SpringBusFactory().getDefaultBus();
+
+        ControlService cs = new ControlService();
+        control = cs.getControlPort();
+        
         greeterBus = bf.createBus(cfgResource);
         bf.setDefaultBus(greeterBus);
         LOG.fine("Initialised greeter bus with configuration: " + cfgResource);
@@ -625,8 +620,8 @@
 
         assertTrue("Failed to start greeter", control.startGreeter(cfgResource));
         
-        GreeterService service = new GreeterService();
-        greeter = service.getGreeterPort();
+        GreeterService gs = new GreeterService();
+        greeter = gs.getGreeterPort();
         LOG.fine("Created greeter client.");
     }
     



Mime
View raw message