qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r551197 - in /incubator/qpid/trunk/qpid: cpp/src/qpid/broker/BrokerAdapter.cpp cpp/src/qpid/broker/ExchangeRegistry.cpp cpp/src/qpid/broker/HeadersExchange.cpp cpp/src/tests/ExchangeTest.cpp python/tests_0-9/query.py
Date Wed, 27 Jun 2007 15:29:18 GMT
Author: gsim
Date: Wed Jun 27 08:29:17 2007
New Revision: 551197

URL: http://svn.apache.org/viewvc?view=rev&rev=551197
Log:
Fixes and tests:

    * ExchangeRegistry::get() caused a pair to be inserted with a 'null' pointer if the xchange
didn't exist
    * HeadersExchange::isBound() didn't check queue param


Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerAdapter.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/HeadersExchange.cpp
    incubator/qpid/trunk/qpid/cpp/src/tests/ExchangeTest.cpp
    incubator/qpid/trunk/qpid/python/tests_0-9/query.py

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerAdapter.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerAdapter.cpp?view=diff&rev=551197&r1=551196&r2=551197
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerAdapter.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerAdapter.cpp Wed Jun 27 08:29:17 2007
@@ -153,7 +153,6 @@
                 
 void BrokerAdapter::ExchangeHandlerImpl::delete_(const MethodContext& context, uint16_t
/*ticket*/, 
                                                  const string& name, bool /*ifUnused*/,
bool nowait){
-
     //TODO: implement unused
     Exchange::shared_ptr exchange(broker.getExchanges().get(name));
     if (exchange->isDurable()) broker.getStore().destroy(*exchange);

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp?view=diff&rev=551197&r1=551196&r2=551197
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp Wed Jun 27 08:29:17
2007
@@ -71,10 +71,10 @@
 
 Exchange::shared_ptr ExchangeRegistry::get(const string& name){
     Mutex::ScopedLock locker(lock);
-    Exchange::shared_ptr exchange =exchanges[name];
-    if (!exchange) 
+    ExchangeMap::iterator i =  exchanges.find(name);
+    if (i == exchanges.end()) 
         throw ChannelException(404, "Exchange not found:" + name);
-    return exchange;
+    return i->second;
 }
 
 namespace 

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/HeadersExchange.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/HeadersExchange.cpp?view=diff&rev=551197&r1=551196&r2=551197
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/HeadersExchange.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/HeadersExchange.cpp Wed Jun 27 08:29:17
2007
@@ -84,7 +84,7 @@
 bool HeadersExchange::isBound(Queue::shared_ptr queue, const string* const, const FieldTable*
const args)
 {
     for (Bindings::iterator i = bindings.begin(); i != bindings.end(); ++i) {
-        if ( (!args || equal(i->first, *args)) && i->second == queue) {
+        if ( (!args || equal(i->first, *args)) && (!queue || i->second == queue))
{
             return true;
         }
     }

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/ExchangeTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/ExchangeTest.cpp?view=diff&rev=551197&r1=551196&r2=551197
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/ExchangeTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/ExchangeTest.cpp Wed Jun 27 08:29:17 2007
@@ -19,10 +19,12 @@
  *
  */
 
+#include "qpid/Exception.h"
 #include "qpid/broker/BrokerExchange.h"
 #include "qpid/broker/BrokerQueue.h"
 #include "qpid/broker/DeliverableMessage.h"
 #include "qpid/broker/DirectExchange.h"
+#include "qpid/broker/ExchangeRegistry.h"
 #include "qpid/broker/FanOutExchange.h"
 #include "qpid/broker/HeadersExchange.h"
 #include "qpid/broker/TopicExchange.h"
@@ -33,12 +35,14 @@
 using namespace qpid::broker;
 using namespace qpid::framing;
 using namespace qpid::sys;
+using namespace qpid;
 
 class ExchangeTest : public CppUnit::TestCase
 {
     CPPUNIT_TEST_SUITE(ExchangeTest);
     CPPUNIT_TEST(testMe);
     CPPUNIT_TEST(testIsBound);
+    CPPUNIT_TEST(testDeleteGetAndRedeclare);
     CPPUNIT_TEST_SUITE_END();
 
   public:
@@ -157,6 +161,18 @@
         CPPUNIT_ASSERT(!headers.isBound(d, 0, &args1));
         CPPUNIT_ASSERT(!headers.isBound(d, 0, &args2));
         CPPUNIT_ASSERT(!headers.isBound(d, 0, &args3));
+    }
+
+    void testDeleteGetAndRedeclare() {
+        ExchangeRegistry exchanges;
+        exchanges.declare("my-exchange", "direct", false, FieldTable());
+        exchanges.destroy("my-exchange");
+        try {
+            exchanges.get("my-exchange");
+        } catch (const ChannelException&) {}
+        std::pair<Exchange::shared_ptr, bool> response = exchanges.declare("my-exchange",
"direct", false, FieldTable());
+        CPPUNIT_ASSERT_EQUAL(string("direct"), response.first->getType());
+  
     }
 };
     

Modified: incubator/qpid/trunk/qpid/python/tests_0-9/query.py
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/tests_0-9/query.py?view=diff&rev=551197&r1=551196&r2=551197
==============================================================================
--- incubator/qpid/trunk/qpid/python/tests_0-9/query.py (original)
+++ incubator/qpid/trunk/qpid/python/tests_0-9/query.py Wed Jun 27 08:29:17 2007
@@ -136,8 +136,23 @@
         channel.queue_declare(queue="unused-queue", exclusive=True)
         channel.queue_bind(exchange="amq.fanout", queue="used-queue")
 
+        # test detection of any binding to specific queue
         response = channel.binding_query(exchange="amq.fanout", queue="used-queue")
         self.assertEqual(False, response.exchange_not_found)
+        self.assertEqual(False, response.queue_not_found)
+        self.assertEqual(False, response.queue_not_matched)        
+
+        # test unmatched queue, unspecified binding
+        response = channel.binding_query(exchange="amq.fanout", queue="unused-queue")
+        self.assertEqual(False, response.exchange_not_found)
+        self.assertEqual(False, response.queue_not_found)
+        self.assertEqual(True, response.queue_not_matched)        
+
+        #test exchange not found
+        self.assertEqual(True, channel.binding_query(exchange="unknown-exchange").exchange_not_found)
+
+        #test queue not found
+        self.assertEqual(True, channel.binding_query(exchange="amq.fanout", queue="unknown-queue").queue_not_found)
 
     def test_binding_query_header(self):
         """
@@ -149,7 +164,61 @@
         channel.queue_declare(queue="unused-queue", exclusive=True)
         channel.queue_bind(exchange="amq.match", queue="used-queue", arguments={"x-match":"all",
"a":"A"} )
 
+        # test detection of any binding to specific queue
         response = channel.binding_query(exchange="amq.match", queue="used-queue")
         self.assertEqual(False, response.exchange_not_found)
+        self.assertEqual(False, response.queue_not_found)
+        self.assertEqual(False, response.queue_not_matched)        
+
+        # test detection of specific binding to any queue
+        response = channel.binding_query(exchange="amq.match", arguments={"x-match":"all",
"a":"A"})
+        self.assertEqual(False, response.exchange_not_found)
+        self.assertEqual(False, response.queue_not_found)
+        self.assertEqual(False, response.args_not_matched)        
+
+        # test detection of specific binding to specific queue
+        response = channel.binding_query(exchange="amq.match", queue="used-queue", arguments={"x-match":"all",
"a":"A"})
+        self.assertEqual(False, response.exchange_not_found)
+        self.assertEqual(False, response.queue_not_found)
+        self.assertEqual(False, response.queue_not_matched)        
+        self.assertEqual(False, response.args_not_matched)        
+
+        # test unmatched queue, unspecified binding
+        response = channel.binding_query(exchange="amq.match", queue="unused-queue")
+        self.assertEqual(False, response.exchange_not_found)
+        self.assertEqual(False, response.queue_not_found)
+        self.assertEqual(True, response.queue_not_matched)        
+
+        # test unspecified queue, unmatched binding
+        response = channel.binding_query(exchange="amq.match", arguments={"x-match":"all",
"b":"B"})
+        self.assertEqual(False, response.exchange_not_found)
+        self.assertEqual(False, response.queue_not_found)
+        self.assertEqual(True, response.args_not_matched)        
+
+        # test matched queue, unmatched binding
+        response = channel.binding_query(exchange="amq.match", queue="used-queue", arguments={"x-match":"all",
"b":"B"})
+        self.assertEqual(False, response.exchange_not_found)
+        self.assertEqual(False, response.queue_not_found)
+        self.assertEqual(False, response.queue_not_matched)        
+        self.assertEqual(True, response.args_not_matched)        
+
+        # test unmatched queue, matched binding
+        response = channel.binding_query(exchange="amq.match", queue="unused-queue", arguments={"x-match":"all",
"a":"A"})
+        self.assertEqual(False, response.exchange_not_found)
+        self.assertEqual(False, response.queue_not_found)
+        self.assertEqual(True, response.queue_not_matched)        
+        self.assertEqual(False, response.args_not_matched)        
+
+        # test unmatched queue, unmatched binding
+        response = channel.binding_query(exchange="amq.match", queue="unused-queue", arguments={"x-match":"all",
"b":"B"})
+        self.assertEqual(False, response.exchange_not_found)
+        self.assertEqual(False, response.queue_not_found)
+        self.assertEqual(True, response.queue_not_matched)        
+        self.assertEqual(True, response.args_not_matched)        
+
+        #test exchange not found
+        self.assertEqual(True, channel.binding_query(exchange="unknown-exchange").exchange_not_found)
 
+        #test queue not found
+        self.assertEqual(True, channel.binding_query(exchange="amq.match", queue="unknown-queue").queue_not_found)
         



Mime
View raw message