You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2015/08/25 15:40:19 UTC

[2/2] qpid-jms git commit: QPIDJMS-97, QPIDJMS-98: make the test resilient against the transfers not all arriving and all being rejected in the single short receive timeout

QPIDJMS-97, QPIDJMS-98: make the test resilient against the transfers not all arriving and all being rejected in the single short receive timeout


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/a03ce1e4
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/a03ce1e4
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/a03ce1e4

Branch: refs/heads/master
Commit: a03ce1e4aa372d0685daf81250ba4d4b2ba57980
Parents: c32d83b
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue Aug 25 13:22:31 2015 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue Aug 25 13:22:53 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/qpid/jms/JmsMessageConsumer.java   |  2 +-
 .../qpid/jms/integration/SessionIntegrationTest.java   | 13 ++++++++++---
 .../apache/qpid/jms/test/testpeer/TestAmqpPeer.java    | 12 ++++++++----
 3 files changed, 19 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/a03ce1e4/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsMessageConsumer.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsMessageConsumer.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsMessageConsumer.java
index f3f7740..80f16fc 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsMessageConsumer.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsMessageConsumer.java
@@ -691,7 +691,7 @@ public class JmsMessageConsumer implements MessageConsumer, JmsMessageAvailableC
                         LOG.trace("{} filtered expired message: {}", getConsumerId(), envelope);
                         doAckExpired(envelope);
                     } else if (redeliveryExceeded(envelope)) {
-                        LOG.trace("{} filtered message with excessive redlivery count: {}", getConsumerId(), envelope);
+                        LOG.trace("{} filtered message with excessive redelivery count: {}", getConsumerId(), envelope);
                         doAckUndeliverable(envelope);
                     } else {
                         boolean autoAckOrDupsOk = acknowledgementMode == Session.AUTO_ACKNOWLEDGE ||

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/a03ce1e4/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
index 6b91559..25e05ba 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
@@ -32,6 +32,7 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.io.IOException;
+import java.util.concurrent.TimeUnit;
 
 import javax.jms.Connection;
 import javax.jms.Destination;
@@ -927,10 +928,16 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
                 testPeer.expectDisposition(true, modified);
             }
 
-            MessageConsumer consumer = session.createConsumer(queue);
-            consumer.receive(100);
+            final MessageConsumer consumer = session.createConsumer(queue);
 
-            testPeer.waitForAllHandlersToComplete(1000);
+            assertTrue("Messages were not rejected as expected",
+                            Wait.waitFor(new Wait.Condition() {
+                                @Override
+                                public boolean isSatisified() throws Exception {
+                                    consumer.receive(20);
+                                    return testPeer.waitForAllHandlersToCompleteNoAssert(10);
+                                }
+                            }, TimeUnit.SECONDS.toMillis(5), TimeUnit.MILLISECONDS.toMillis(2)));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/a03ce1e4/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
index d5f84c0..f9ca641 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
@@ -301,15 +301,19 @@ public class TestAmqpPeer implements AutoCloseable
 
     public void waitForAllHandlersToComplete(int timeoutMillis) throws InterruptedException
     {
+        boolean countedDownOk =  waitForAllHandlersToCompleteNoAssert(timeoutMillis);
+
+        Assert.assertTrue("All handlers should have completed within the " + timeoutMillis + "ms timeout", countedDownOk);
+    }
+
+    public boolean waitForAllHandlersToCompleteNoAssert(int timeoutMillis) throws InterruptedException
+    {
         synchronized(_handlersLock)
         {
             _handlersCompletedLatch = new CountDownLatch(_handlers.size());
         }
 
-        boolean countedDownOk = _handlersCompletedLatch.await(timeoutMillis, TimeUnit.MILLISECONDS);
-
-        Assert.assertTrue(
-                "All handlers should have completed within the " + timeoutMillis + "ms timeout", countedDownOk);
+        return _handlersCompletedLatch.await(timeoutMillis, TimeUnit.MILLISECONDS);
     }
 
     void sendHeader(byte[] header)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org