qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r585952 - in /incubator/qpid/trunk/qpid: cpp/src/qpid/broker/MessageHandlerImpl.cpp cpp/src/qpid/framing/SequenceNumberSet.cpp cpp/src/tests/SequenceNumberTest.cpp python/tests_0-10/message.py
Date Thu, 18 Oct 2007 12:53:47 GMT
Author: gsim
Date: Thu Oct 18 05:53:46 2007
New Revision: 585952

URL: http://svn.apache.org/viewvc?rev=585952&view=rev
Log:
Fixed return of acquired message ranges (and added tests)


Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageHandlerImpl.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/framing/SequenceNumberSet.cpp
    incubator/qpid/trunk/qpid/cpp/src/tests/SequenceNumberTest.cpp
    incubator/qpid/trunk/qpid/python/tests_0-10/message.py

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageHandlerImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageHandlerImpl.cpp?rev=585952&r1=585951&r2=585952&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageHandlerImpl.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageHandlerImpl.cpp Thu Oct 18 05:53:46
2007
@@ -198,7 +198,7 @@
     //TODO: implement mode
 
     SequenceNumberSet results;
-    RangedOperation op = boost::bind(&SemanticState::acquire, &state, _1, _2, results);
+    RangedOperation op = boost::bind(&SemanticState::acquire, &state, _1, _2, boost::ref(results));
     transfers.processRanges(op);
     results = results.condense();
     getProxy().getMessage().acquired(results);

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/SequenceNumberSet.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/SequenceNumberSet.cpp?rev=585952&r1=585951&r2=585952&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/SequenceNumberSet.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/SequenceNumberSet.cpp Thu Oct 18 05:53:46
2007
@@ -48,14 +48,20 @@
 {
     SequenceNumberSet result;
     const_iterator last = end();
+    const_iterator start = end();
     for (const_iterator i = begin(); i != end(); i++) {
-        if (last == end()) {
-            last = i;
+        if (start == end()) {
+            start = i;
         } else if (*i - *last > 1) {
-            result.push_back(*last);
-            result.push_back(*i);            
-            last = end();
+            result.push_back(*start);
+            result.push_back(*last);            
+            start = i;
         }
+        last = i;
+    }
+    if (start != end()) {
+        result.push_back(*start);
+        result.push_back(*last);            
     }
     return result;
 }

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/SequenceNumberTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/SequenceNumberTest.cpp?rev=585952&r1=585951&r2=585952&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/SequenceNumberTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/SequenceNumberTest.cpp Thu Oct 18 05:53:46 2007
@@ -22,6 +22,7 @@
 #include "qpid_test_plugin.h"
 #include <iostream>
 #include "qpid/framing/SequenceNumber.h"
+#include "qpid/framing/SequenceNumberSet.h"
 
 using namespace qpid::framing;
 
@@ -31,6 +32,9 @@
     CPPUNIT_TEST(testIncrementPostfix);
     CPPUNIT_TEST(testIncrementPrefix);
     CPPUNIT_TEST(testWrapAround);
+    CPPUNIT_TEST(testCondense);
+    CPPUNIT_TEST(testCondenseSingleRange);
+    CPPUNIT_TEST(testCondenseSingleItem);
     CPPUNIT_TEST(testDifference);
     CPPUNIT_TEST(testDifferenceWithWrapAround1);
     CPPUNIT_TEST(testDifferenceWithWrapAround2);
@@ -110,6 +114,50 @@
         }
         CPPUNIT_ASSERT(a == b);
         CPPUNIT_ASSERT(++a > b);
+    }
+
+    void testCondense()
+    {
+        SequenceNumberSet set;
+        for (uint i = 0; i < 6; i++) {
+            set.push_back(SequenceNumber(i));
+        }
+        set.push_back(SequenceNumber(7));
+        for (uint i = 9; i < 13; i++) {
+            set.push_back(SequenceNumber(i));
+        }
+        set.push_back(SequenceNumber(13));
+        SequenceNumberSet actual = set.condense();
+
+        SequenceNumberSet expected;
+        expected.addRange(SequenceNumber(0), SequenceNumber(5));
+        expected.addRange(SequenceNumber(7), SequenceNumber(7));
+        expected.addRange(SequenceNumber(9), SequenceNumber(13));
+        CPPUNIT_ASSERT_EQUAL(expected, actual);
+    }
+
+    void testCondenseSingleRange()
+    {
+        SequenceNumberSet set;
+        for (uint i = 0; i < 6; i++) {
+            set.push_back(SequenceNumber(i));
+        }
+        SequenceNumberSet actual = set.condense();
+
+        SequenceNumberSet expected;
+        expected.addRange(SequenceNumber(0), SequenceNumber(5));
+        CPPUNIT_ASSERT_EQUAL(expected, actual);
+    }
+
+    void testCondenseSingleItem()
+    {
+        SequenceNumberSet set;
+        set.push_back(SequenceNumber(1));
+        SequenceNumberSet actual = set.condense();
+
+        SequenceNumberSet expected;
+        expected.addRange(SequenceNumber(1), SequenceNumber(1));
+        CPPUNIT_ASSERT_EQUAL(expected, actual);
     }
 
     void testDifference()

Modified: incubator/qpid/trunk/qpid/python/tests_0-10/message.py
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/tests_0-10/message.py?rev=585952&r1=585951&r2=585952&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/tests_0-10/message.py (original)
+++ incubator/qpid/trunk/qpid/python/tests_0-10/message.py Thu Oct 18 05:53:46 2007
@@ -571,11 +571,19 @@
 
         self.subscribe(queue = "q", destination = "a", acquire_mode = 1, confirm_mode = 1)
         msg = self.client.queue("a").get(timeout = 1)
-        channel.message_acquire([msg.command_id, msg.command_id])
-        msg.complete()
+        #message should still be on the queue:
+        self.assertEquals(1, channel.queue_query(queue = "q").message_count)
 
+        channel.message_acquire([msg.command_id, msg.command_id])
+        #check that we get notification (i.e. message_acquired)
+        response = channel.control_queue.get(timeout=1)
+        self.assertEquals(response.transfers, [msg.command_id, msg.command_id])
         #message should have been removed from the queue:
         self.assertEquals(0, channel.queue_query(queue = "q").message_count)
+        msg.complete()
+
+
+
 
     def test_release(self):
         """



Mime
View raw message