[jboss-cvs] JBoss Messaging SVN: r2731 - branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/server/destination.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun May 27 05:05:55 EDT 2007
Author: timfox
Date: 2007-05-27 05:05:55 -0400 (Sun, 27 May 2007)
New Revision: 2731
Modified:
branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/server/destination/QueueManagementTest.java
Log:
Fix test for cc run
Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/server/destination/QueueManagementTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/server/destination/QueueManagementTest.java 2007-05-26 20:57:39 UTC (rev 2730)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/server/destination/QueueManagementTest.java 2007-05-27 09:05:55 UTC (rev 2731)
@@ -243,7 +243,7 @@
try
{
- Queue queue = (Queue)ic.lookup("/queue/QueueMessageCount2");
+ Queue queue = (Queue)ic.lookup("/queue/QueueMessageCount2");
conn = cf.createConnection();
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -274,12 +274,17 @@
{
receivedCount++;
- log.info(receivedCount + " messages received");
Thread.sleep(500);
int mc = ((Integer)ServerManagement.
getAttribute(destObjectName, "MessageCount")).intValue();
+
+ if ((MESSAGE_COUNT - receivedCount)!=mc)
+ {
+ retryForLogs(mc, receivedCount, MESSAGE_COUNT, destObjectName);
+ }
+
assertEquals(MESSAGE_COUNT - receivedCount, mc);
}
@@ -459,6 +464,26 @@
}
// Private -------------------------------------------------------
+
+ /** this method will retry getting MessageCount until it gets a sucessful result.
+ * This is done just so you can visualize a logs what's the real racing condition. (caused by the delivery thread at the time of the construction of this method)
+ */
+ private void retryForLogs(int mc, int receivedCount, int MESSAGE_COUNT, ObjectName destObjectName) throws Exception
+ {
+ int retry=0;
+ while ((MESSAGE_COUNT - receivedCount != mc) && retry < 10)
+ {
+ log.info("******************** Still failing");
+ mc = ((Integer) ServerManagement.
+ getAttribute(destObjectName, "MessageCount")).intValue();
+ Thread.sleep(50);
+ retry++;
+ }
+ if (retry<10)
+ {
+ log.info("There is a racing condition that was fixed after " + retry + " retries. Look at log4j traces.");
+ }
+ }
// Inner classes -------------------------------------------------
}
More information about the jboss-cvs-commits
mailing list