activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r798852 - in /activemq/trunk/activemq-core/src/test/java/org/apache/activemq: network/DemandForwardingBridgeTest.java util/Wait.java
Date Wed, 29 Jul 2009 10:46:41 GMT
Author: gtully
Date: Wed Jul 29 10:46:38 2009
New Revision: 798852

URL: http://svn.apache.org/viewvc?rev=798852&view=rev
Log:
make test more tolerant to slower machines, resolve intermittent failure

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/DemandForwardingBridgeTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/Wait.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/DemandForwardingBridgeTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/DemandForwardingBridgeTest.java?rev=798852&r1=798851&r2=798852&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/DemandForwardingBridgeTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/DemandForwardingBridgeTest.java
Wed Jul 29 10:46:38 2009
@@ -26,6 +26,7 @@
 import org.apache.activemq.command.Message;
 import org.apache.activemq.command.ProducerInfo;
 import org.apache.activemq.command.SessionInfo;
+import org.apache.activemq.util.Wait;
 
 public class DemandForwardingBridgeTest extends NetworkTestSupport {
 
@@ -53,7 +54,7 @@
         destination = createDestinationInfo(connection1, connectionInfo1, destinationType);
 
         // Start a consumer on a remote broker
-        StubConnection connection2 = createRemoteConnection();
+        final StubConnection connection2 = createRemoteConnection();
         ConnectionInfo connectionInfo2 = createConnectionInfo();
         SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
         connection2.send(connectionInfo2);
@@ -73,11 +74,14 @@
         // Now create remote consumer that should cause message to move to this
         // remote consumer.
         ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, destination);
-        connection2.send(consumerInfo2);
+        connection2.request(consumerInfo2);
 
         // Make sure the message was delivered via the remote.
-        m = receiveMessage(connection2);
-        assertNotNull(m);
+        assertTrue("message was received", Wait.waitFor(new Wait.Condition() {
+            public boolean isSatisified() throws Exception {
+                return receiveMessage(connection2) != null;
+            }            
+        }));
     }
 
     public void initCombosForTestAddConsumerThenSend() {

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/Wait.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/Wait.java?rev=798852&r1=798851&r2=798852&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/Wait.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/Wait.java Wed Jul
29 10:46:38 2009
@@ -32,9 +32,11 @@
     
     public static boolean waitFor(final Condition condition, final long duration) throws
Exception {
         final long expiry = System.currentTimeMillis() + duration;
-        while (!condition.isSatisified() && System.currentTimeMillis() < expiry)
{
+        boolean conditionSatisified = condition.isSatisified();
+        while (!conditionSatisified && System.currentTimeMillis() < expiry) {
             Thread.sleep(1000);
+            conditionSatisified = condition.isSatisified();
         }   
-        return condition.isSatisified();
+        return conditionSatisified;
     }  
 }



Mime
View raw message