activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1441156 - /activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/OptimizedAckTest.java
Date Thu, 31 Jan 2013 19:34:22 GMT
Author: tabish
Date: Thu Jan 31 19:34:22 2013
New Revision: 1441156

URL: http://svn.apache.org/viewvc?rev=1441156&view=rev
Log:
apply fix for: https://issues.apache.org/jira/browse/AMQ-4288

Modified:
    activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/OptimizedAckTest.java

Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/OptimizedAckTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/OptimizedAckTest.java?rev=1441156&r1=1441155&r2=1441156&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/OptimizedAckTest.java
(original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/OptimizedAckTest.java
Thu Jan 31 19:34:22 2013
@@ -70,21 +70,22 @@ public class OptimizedAckTest extends Te
             }
         }));
 
-        for (int i = 0; i < 10; i++) {
+        for (int i = 0; i < 6; i++) {
             javax.jms.Message msg = consumer.receive(4000);
-            long inFlightCount = regionBroker.getDestinationStatistics().getInflight().getCount();
             assertNotNull(msg);
-            if (i < 7) {
-                assertEquals("all prefetch is still in flight", 10, inFlightCount);
-            } else {
-                assertTrue("most are acked but 3 remain", Wait.waitFor(new Wait.Condition()
{
-                    @Override
-                    public boolean isSatisified() throws Exception {
-                        LOG.info("inflight count: " + regionBroker.getDestinationStatistics().getInflight().getCount());
-                        return 3 == regionBroker.getDestinationStatistics().getInflight().getCount();
-                    }
-                }));
-            }
+            assertEquals("all prefetch is still in flight: " + i, 10, regionBroker.getDestinationStatistics().getInflight().getCount());
+        }
+
+        for (int i = 6; i < 10; i++) {
+            javax.jms.Message msg = consumer.receive(4000);
+            assertNotNull(msg);
+
+            assertTrue("most are acked but 3 remain", Wait.waitFor(new Wait.Condition() {
+                @Override
+                public boolean isSatisified() throws Exception {
+                    return 3 == regionBroker.getDestinationStatistics().getInflight().getCount();
+                }
+            }));
         }
     }
 
@@ -108,22 +109,26 @@ public class OptimizedAckTest extends Te
             }
         }));
 
-        for (int i = 0; i < 10; i++) {
+        for (int i = 0; i < 6; i++) {
             Thread.sleep(400);
             javax.jms.Message msg = consumer.receive(4000);
-            long inFlightCount = regionBroker.getDestinationStatistics().getInflight().getCount();
             assertNotNull(msg);
-            if (i < 7) {
-                assertEquals("all prefetch is still in flight: " + i, 10, inFlightCount);
-            } else {
-                assertTrue("most are acked but 3 remain", Wait.waitFor(new Wait.Condition()
{
-                    @Override
-                    public boolean isSatisified() throws Exception {
-                        return 3 == regionBroker.getDestinationStatistics().getInflight().getCount();
-                    }
-                }));
-            }
+            assertEquals("all prefetch is still in flight: " + i, 10, regionBroker.getDestinationStatistics().getInflight().getCount());
+        }
+
+        for (int i = 6; i < 10; i++) {
+            Thread.sleep(400);
+            javax.jms.Message msg = consumer.receive(4000);
+            assertNotNull(msg);
+
+            assertTrue("most are acked but 3 remain", Wait.waitFor(new Wait.Condition() {
+                @Override
+                public boolean isSatisified() throws Exception {
+                    return 3 == regionBroker.getDestinationStatistics().getInflight().getCount();
+                }
+            }));
         }
+
     }
 
     public void testReceivedMessageNotInFlightAfterScheduledAckFires() throws Exception {
@@ -147,21 +152,21 @@ public class OptimizedAckTest extends Te
             }
         }));
 
-        for (int i = 0; i < 10; i++) {
+        for (int i = 0; i < 6; i++) {
             javax.jms.Message msg = consumer.receive(4000);
-            long inFlightCount = regionBroker.getDestinationStatistics().getInflight().getCount();
             assertNotNull(msg);
-            if (i < 7) {
-                assertEquals("all prefetch is still in flight", 10, inFlightCount);
-            } else {
-                assertTrue("most are acked but 3 remain", Wait.waitFor(new Wait.Condition()
{
-                    @Override
-                    public boolean isSatisified() throws Exception {
-                        LOG.info("inflight count: " + regionBroker.getDestinationStatistics().getInflight().getCount());
-                        return 3 == regionBroker.getDestinationStatistics().getInflight().getCount();
-                    }
-                }));
-            }
+            assertEquals("all prefetch is still in flight: " + i, 10, regionBroker.getDestinationStatistics().getInflight().getCount());
+        }
+
+        for (int i = 6; i < 10; i++) {
+            javax.jms.Message msg = consumer.receive(4000);
+            assertNotNull(msg);
+            assertTrue("most are acked but 3 remain", Wait.waitFor(new Wait.Condition() {
+                @Override
+                public boolean isSatisified() throws Exception {
+                    return 3 == regionBroker.getDestinationStatistics().getInflight().getCount();
+                }
+            }));
         }
 
         assertTrue("After delay the scheduled ack should ack all inflight.", Wait.waitFor(new
Wait.Condition() {



Mime
View raw message