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 2018/04/11 11:20:47 UTC
qpid-jms git commit: QPIDJMS-376: fix tests to avoid
sporadic/erroneous failures due to races
Repository: qpid-jms
Updated Branches:
refs/heads/master 18c017da8 -> da0d4e50a
QPIDJMS-376: fix tests to avoid sporadic/erroneous failures due to races
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/da0d4e50
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/da0d4e50
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/da0d4e50
Branch: refs/heads/master
Commit: da0d4e50a43a51abd51a13a9996b116d851d2f62
Parents: 18c017d
Author: Robbie Gemmell <ro...@apache.org>
Authored: Wed Apr 11 12:20:03 2018 +0100
Committer: Robbie Gemmell <ro...@apache.org>
Committed: Wed Apr 11 12:20:03 2018 +0100
----------------------------------------------------------------------
.../integration/ConsumerIntegrationTest.java | 24 ++++++++++----------
1 file changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/da0d4e50/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConsumerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConsumerIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConsumerIntegrationTest.java
index e8a506a..c573972 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConsumerIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConsumerIntegrationTest.java
@@ -141,20 +141,20 @@ public class ConsumerIntegrationTest extends QpidJmsTestCase {
final String BREAD_CRUMB = "ErrorMessage";
try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
- final AtomicBoolean consumerClosed = new AtomicBoolean();
- final AtomicBoolean exceptionFired = new AtomicBoolean();
+ CountDownLatch consumerClosed = new CountDownLatch(1);
+ CountDownLatch exceptionFired = new CountDownLatch(1);
JmsConnection connection = (JmsConnection) testFixture.establishConnecton(testPeer);
connection.setExceptionListener(new ExceptionListener() {
@Override
public void onException(JMSException exception) {
- exceptionFired.set(true);
+ exceptionFired.countDown();
}
});
connection.addConnectionListener(new JmsDefaultConnectionListener() {
@Override
public void onConsumerClosed(MessageConsumer consumer, Throwable exception) {
- consumerClosed.set(true);
+ consumerClosed.countDown();
}
});
@@ -189,8 +189,8 @@ public class ConsumerIntegrationTest extends QpidJmsTestCase {
}
}, 10000, 10));
- assertTrue("Consumer closed callback didn't trigger", consumerClosed.get());
- assertFalse("JMS Exception listener shouldn't fire with no MessageListener", exceptionFired.get());
+ assertTrue("Consumer closed callback didn't trigger", consumerClosed.await(2000, TimeUnit.MILLISECONDS));
+ assertFalse("JMS Exception listener shouldn't fire with no MessageListener", exceptionFired.await(20, TimeUnit.MILLISECONDS));
// Try closing it explicitly, should effectively no-op in client.
// The test peer will throw during close if it sends anything.
@@ -203,21 +203,21 @@ public class ConsumerIntegrationTest extends QpidJmsTestCase {
final String BREAD_CRUMB = "ErrorMessage";
try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
- final AtomicBoolean consumerClosed = new AtomicBoolean();
- final AtomicBoolean exceptionFired = new AtomicBoolean();
+ CountDownLatch consumerClosed = new CountDownLatch(1);
+ CountDownLatch exceptionFired = new CountDownLatch(1);
JmsConnection connection = (JmsConnection) testFixture.establishConnecton(testPeer);
connection.setExceptionListener(new ExceptionListener() {
@Override
public void onException(JMSException exception) {
LOG.trace("JMS ExceptionListener: ", exception);
- exceptionFired.set(true);
+ exceptionFired.countDown();
}
});
connection.addConnectionListener(new JmsDefaultConnectionListener() {
@Override
public void onConsumerClosed(MessageConsumer consumer, Throwable exception) {
- consumerClosed.set(true);
+ consumerClosed.countDown();
}
});
@@ -258,8 +258,8 @@ public class ConsumerIntegrationTest extends QpidJmsTestCase {
}
}, 10000, 10));
- assertTrue("Consumer closed callback didn't trigger", consumerClosed.get());
- assertTrue("JMS Exception listener shouldn't fire with no MessageListener", exceptionFired.get());
+ assertTrue("Consumer closed callback didn't trigger", consumerClosed.await(2000, TimeUnit.MILLISECONDS));
+ assertTrue("JMS Exception listener should have fired with a MessageListener", exceptionFired.await(2000, TimeUnit.MILLISECONDS));
// Try closing it explicitly, should effectively no-op in client.
// The test peer will throw during close if it sends anything.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org