cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1345416 - /cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ServiceInvocationAckBase.java
Date Sat, 02 Jun 2012 01:54:19 GMT
Author: dkulp
Date: Sat Jun  2 01:54:19 2012
New Revision: 1345416

URL: http://svn.apache.org/viewvc?rev=1345416&view=rev
Log:
Shorten the wait times on fast computers

Modified:
    cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ServiceInvocationAckBase.java

Modified: cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ServiceInvocationAckBase.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ServiceInvocationAckBase.java?rev=1345416&r1=1345415&r2=1345416&view=diff
==============================================================================
--- cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ServiceInvocationAckBase.java
(original)
+++ cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ServiceInvocationAckBase.java
Sat Jun  2 01:54:19 2012
@@ -37,6 +37,7 @@ import org.apache.cxf.phase.Phase;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 import org.apache.cxf.ws.rm.RMManager;
+import org.apache.cxf.ws.rm.RetransmissionQueue;
 
 import org.junit.After;
 import org.junit.Test;
@@ -117,16 +118,16 @@ public abstract class ServiceInvocationA
 
         // the message is acked and the invocation takes place
         greeter.greetMeOneWay("one");
-        Thread.sleep(6000L);
-        assertTrue("RetransmissionQueue must be empty", manager.getRetransmissionQueue().isEmpty());
+        waitForEmpty(manager.getRetransmissionQueue());
     
         control.setFaultLocation(location);
 
         // the invocation fails but the message is acked because the delivery succeeds
         greeter.greetMeOneWay("two");
-        Thread.sleep(6000L);
-        assertTrue("RetransmissionQueue must be empty", manager.getRetransmissionQueue().isEmpty());
+        waitForEmpty(manager.getRetransmissionQueue());
     }
+    
+    
 
     @Test
     public void testRobustInvocationHandling() throws Exception {
@@ -144,25 +145,50 @@ public abstract class ServiceInvocationA
         
         // the message is acked and the invocation takes place
         greeter.greetMeOneWay("one");
-        Thread.sleep(6000L);
-        assertTrue("RetransmissionQueue must be empty", manager.getRetransmissionQueue().isEmpty());
+        waitForEmpty(manager.getRetransmissionQueue());
 
         control.setFaultLocation(location);
 
         // the invocation fails but the message is acked because the delivery succeeds
         greeter.greetMeOneWay("two");
-        Thread.sleep(6000L);
-        assertFalse("RetransmissionQueue must not be empty", manager.getRetransmissionQueue().isEmpty());
-        
+        waitForNotEmpty(manager.getRetransmissionQueue());
+
         location.setPhase(null);
         control.setFaultLocation(location);
 
         // the retransmission succeeds and the invocation succeeds, the message is acked
-        Thread.sleep(6000L);
-        assertTrue("RetransmissionQueue must be empty", manager.getRetransmissionQueue().isEmpty());
+        waitForEmpty(manager.getRetransmissionQueue());
         
     }
 
+    private void waitForNotEmpty(RetransmissionQueue retransmissionQueue) throws Exception
{
+        long start = System.currentTimeMillis();
+        while (true) {
+            Thread.sleep(100);
+            if (!retransmissionQueue.isEmpty()) {
+                return;
+            }
+            long total = System.currentTimeMillis() - start;
+            if (total > 10000L) {
+                fail("RetransmissionQueue must not be empty");
+            }
+        }
+    }
+
+    private void waitForEmpty(RetransmissionQueue retransmissionQueue) throws Exception {
+        long start = System.currentTimeMillis();
+        while (true) {
+            Thread.sleep(100);
+            if (retransmissionQueue.isEmpty()) {
+                return;
+            }
+            long total = System.currentTimeMillis() - start;
+            if (total > 10000L) {
+                fail("RetransmissionQueue must be empty");
+            }
+        }
+    }
+
     protected void setupGreeter(String cfgResource) throws NumberFormatException, MalformedURLException
{
         
         SpringBusFactory bf = new SpringBusFactory();



Mime
View raw message