Author: ritchiem
Date: Tue Oct 13 11:28:31 2009
New Revision: 824703

URL: http://svn.apache.org/viewvc?rev=824703&view=rev
Log:
QPID-1816 : Ensured the lastCount value is always correctly set to 
NUM_MESSAGES, calling getCount() after the connection has started may result in 
getting a value lower than NUM_MESSAGES and then cause the test to end early.  
Fixed spelling errors

Modified:
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeAfterFailoverOnMessageTest.java
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeAfterFailoverTest.java
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeOnMessageTest.java

Modified: 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeAfterFailoverOnMessageTest.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeAfterFailoverOnMessageTest.java?rev=824703&r1=824702&r2=824703&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeAfterFailoverOnMessageTest.java
 (original)
+++ 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeAfterFailoverOnMessageTest.java
 Tue Oct 13 11:28:31 2009
@@ -155,7 +155,7 @@
         public void onMessage(Message message)
         {
             // Stop processing if we have an error and had to stop running.
-            if (_receviedAll.getCount() == 0)
+            if (_receivedAll.getCount() == 0)
             {
                 _logger.debug("Dumping msgs due to error(" + 
_causeOfFailure.get().getMessage() + "):" + message);
                 return;
@@ -191,7 +191,7 @@
                     // Acknowledge the first message if we are now on the 
cleaned pass
                     if (cleaned)
                     {
-                        _receviedAll.countDown();
+                        _receivedAll.countDown();
                     }
 
                     return;
@@ -234,7 +234,7 @@
                 // this will then trigger test teardown.
                 if (cleaned)
                 {
-                    _receviedAll.countDown();
+                    _receivedAll.countDown();
                 }
 
                 //Reset message count so we can try again.

Modified: 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeAfterFailoverTest.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeAfterFailoverTest.java?rev=824703&r1=824702&r2=824703&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeAfterFailoverTest.java
 (original)
+++ 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeAfterFailoverTest.java
 Tue Oct 13 11:28:31 2009
@@ -299,7 +299,7 @@
         }
         catch (InterruptedException e)
         {
-            fail("Failover was interuppted");
+            fail("Failover was interrupted");
         }
     }
 

Modified: 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeOnMessageTest.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeOnMessageTest.java?rev=824703&r1=824702&r2=824703&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeOnMessageTest.java
 (original)
+++ 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeOnMessageTest.java
 Tue Oct 13 11:28:31 2009
@@ -34,7 +34,7 @@
 
 public class AcknowledgeOnMessageTest extends AcknowledgeTest implements 
MessageListener
 {
-    protected CountDownLatch _receviedAll;
+    protected CountDownLatch _receivedAll;
     protected AtomicReference<Exception> _causeOfFailure = new 
AtomicReference<Exception>(null);
 
     @Override
@@ -46,7 +46,7 @@
     @Override
     public void init(boolean transacted, int mode) throws Exception
     {
-        _receviedAll = new CountDownLatch(NUM_MESSAGES);
+        _receivedAll = new CountDownLatch(NUM_MESSAGES);
 
         super.init(transacted, mode);
         _consumer.setMessageListener(this);
@@ -64,26 +64,36 @@
 
         _connection.start();
 
-        int lastCount = (int) _receviedAll.getCount();
+        // Set the lastCount to NUM_MESSAGES, this ensures that the compare
+        // against the receviedAll count is accurate.
+        int lastCount = NUM_MESSAGES;
 
-        boolean complete = _receviedAll.await(5000L, TimeUnit.MILLISECONDS);
+        // Wait for messages to arrive
+        boolean complete = _receivedAll.await(5000L, TimeUnit.MILLISECONDS);
 
+        // If the messasges haven't arrived
         while (!complete)
         {
-            int currentCount = (int) _receviedAll.getCount();
+            // Check how many we have received
+            int currentCount = (int) _receivedAll.getCount();
 
             // make sure we have received a message in the last cycle.
             if (lastCount == currentCount)
             {
+                // If we didn't receive any messages then stop.
+                // Something must have gone wrong.
+                System.err.println("Giving up waiting as we didn't receive 
anything.");
                 break;
             }
             // Remember the currentCount as the lastCount for the next cycle.
             // so we can exit if things get locked up.
             lastCount = currentCount;
 
-            complete = _receviedAll.await(5000L, TimeUnit.MILLISECONDS);
+            // Wait again for messages to arrive.
+            complete = _receivedAll.await(5000L, TimeUnit.MILLISECONDS);
         }
 
+        // If we failed to receive all the messages then fail the test.
         if (!complete)
         {
             // Check to see if we ended due to an exception in the onMessage 
handler
@@ -95,10 +105,11 @@
             }
             else
             {
-                fail("All messages not received missing:" + 
_receviedAll.getCount() + "/" + NUM_MESSAGES);
+                fail("All messages not received missing:" + 
_receivedAll.getCount() + "/" + NUM_MESSAGES);
             }
         }
 
+        // Even if we received all the messages.
         // Check to see if we ended due to an exception in the onMessage 
handler
         Exception cause = _causeOfFailure.get();
         if (cause != null)
@@ -131,7 +142,7 @@
     {
         try
         {
-            int count = NUM_MESSAGES - (int) _receviedAll.getCount();
+            int count = NUM_MESSAGES - (int) _receivedAll.getCount();
 
             assertEquals("Incorrect message received", count, 
message.getIntProperty(INDEX));
 
@@ -144,7 +155,7 @@
 
             doAcknowlegement(message);
 
-            _receviedAll.countDown();
+            _receivedAll.countDown();
         }
         catch (Exception e)
         {
@@ -162,9 +173,9 @@
     {
         _causeOfFailure.set(e);
         // End the test.
-        while (_receviedAll.getCount() != 0)
+        while (_receivedAll.getCount() != 0)
         {
-            _receviedAll.countDown();
+            _receivedAll.countDown();
         }
     }
 }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to