summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2009-12-04 18:59:29 +0000
committerTed Ross <tross@apache.org>2009-12-04 18:59:29 +0000
commit344d932451f98abeb249cd38b49663e438a1ecdc (patch)
treeae3c25f04760e5000743746375cf11be03850190
parent876fea5cfb56d2f10fe8cf4561956afd38bd11e7 (diff)
downloadqpid-python-344d932451f98abeb249cd38b49663e438a1ecdc.tar.gz
QPID-2246 - QMF - Querying objects using a selector of type ObjectId yields incorrect results
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@887320 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/bindings/qmf/python/qmf.py5
-rw-r--r--qpid/cpp/bindings/qmf/ruby/qmf.rb3
-rwxr-xr-xqpid/cpp/bindings/qmf/tests/agent_ruby.rb4
-rwxr-xr-xqpid/cpp/bindings/qmf/tests/python_console.py15
-rwxr-xr-xqpid/cpp/bindings/qmf/tests/ruby_console_test.rb16
-rw-r--r--qpid/cpp/src/qmf/engine/ObjectIdImpl.cpp51
-rw-r--r--qpid/cpp/src/qmf/engine/ObjectIdImpl.h16
7 files changed, 82 insertions, 28 deletions
diff --git a/qpid/cpp/bindings/qmf/python/qmf.py b/qpid/cpp/bindings/qmf/python/qmf.py
index e97279a8fa..233f1c83d8 100644
--- a/qpid/cpp/bindings/qmf/python/qmf.py
+++ b/qpid/cpp/bindings/qmf/python/qmf.py
@@ -35,7 +35,6 @@ from qmfengine import (TYPE_ABSTIME, TYPE_ARRAY, TYPE_BOOL, TYPE_DELTATIME,
from qmfengine import (O_EQ, O_NE, O_LT, O_LE, O_GT, O_GE, O_RE_MATCH, O_RE_NOMATCH,
E_NOT, E_AND, E_OR, E_XOR)
-
##==============================================================================
## CONNECTION
##==============================================================================
@@ -561,9 +560,7 @@ class ObjectId:
def __eq__(self, other):
if not isinstance(other, self.__class__): return False
- return (self.impl.getObjectNumHi() == other.impl.getObjectNumHi() and
- self.impl.getObjectNumLo() == other.impl.getObjectNumLo())
-
+ return self.impl == other.impl
def __ne__(self, other):
return not self.__eq__(other)
diff --git a/qpid/cpp/bindings/qmf/ruby/qmf.rb b/qpid/cpp/bindings/qmf/ruby/qmf.rb
index b52f2bce5e..857dd64aeb 100644
--- a/qpid/cpp/bindings/qmf/ruby/qmf.rb
+++ b/qpid/cpp/bindings/qmf/ruby/qmf.rb
@@ -472,8 +472,7 @@ module Qmf
end
def ==(other)
- return (@impl.getObjectNumHi == other.impl.getObjectNumHi) &&
- (@impl.getObjectNumLo == other.impl.getObjectNumLo)
+ return @impl == other.impl
end
def to_s
diff --git a/qpid/cpp/bindings/qmf/tests/agent_ruby.rb b/qpid/cpp/bindings/qmf/tests/agent_ruby.rb
index 426a284e7d..adf91a8b66 100755
--- a/qpid/cpp/bindings/qmf/tests/agent_ruby.rb
+++ b/qpid/cpp/bindings/qmf/tests/agent_ruby.rb
@@ -83,7 +83,7 @@ end
class App < Qmf::AgentHandler
def get_query(context, query, userId)
-# puts "Query: user=#{userId} context=#{context} class=#{query.class_name} object_num=#{query.object_id.object_num_low if query.object_id}"
+# puts "Query: user=#{userId} context=#{context} class=#{query.class_name} object_num=#{query.object_id if query.object_id}"
if query.class_name == 'parent'
@agent.query_response(context, @parent)
elsif query.object_id == @parent_oid
@@ -93,7 +93,7 @@ class App < Qmf::AgentHandler
end
def method_call(context, name, object_id, args, userId)
-# puts "Method: user=#{userId} context=#{context} method=#{name} object_num=#{object_id.object_num_low if object_id} args=#{args}"
+# puts "Method: user=#{userId} context=#{context} method=#{name} object_num=#{object_id if object_id} args=#{args}"
retCode = 0
retText = "OK"
diff --git a/qpid/cpp/bindings/qmf/tests/python_console.py b/qpid/cpp/bindings/qmf/tests/python_console.py
index 798e4dddda..6f366d1a3d 100755
--- a/qpid/cpp/bindings/qmf/tests/python_console.py
+++ b/qpid/cpp/bindings/qmf/tests/python_console.py
@@ -151,6 +151,21 @@ class QmfInteropTests(TestBase010):
newList = qmf.getObjects(_objectId=parent.getObjectId())
self.assertEqual(len(newList), 1)
+ def test_E_filter_by_object_id(self):
+ self.startQmf()
+ qmf = self.qmf
+
+ list = qmf.getObjects(_class="exchange", name="qpid.management")
+ self.assertEqual(len(list), 1, "No Management Exchange")
+ mgmt_exchange = list[0]
+
+ bindings = qmf.getObjects(_class="binding", exchangeRef=mgmt_exchange.getObjectId())
+ if len(bindings) == 0:
+ self.fail("No bindings found on management exchange")
+
+ for binding in bindings:
+ self.assertEqual(binding.exchangeRef, mgmt_exchange.getObjectId())
+
def getProperty(self, msg, name):
for h in msg.headers:
if hasattr(h, name): return getattr(h, name)
diff --git a/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb b/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb
index 98180a97cd..c5c7b141dd 100755
--- a/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb
+++ b/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb
@@ -214,9 +214,21 @@ class ConsoleTest < ConsoleTestBase
fail("Didn't find a non-broker agent")
end
-end
+ def test_E_filter_by_object_id
+ mgmt_exchange = @qmfc.object(:class => "exchange", 'name' => "qpid.management")
+ assert(mgmt_exchange, "No Management Exchange")
-app = ConsoleTest.new
+ bindings = @qmfc.objects(:class => "binding", 'exchangeRef' => mgmt_exchange.object_id)
+ if bindings.size == 0
+ fail("No bindings found on management exchange")
+ end
+
+ bindings.each do |binding|
+ assert_equal(binding.exchangeRef, mgmt_exchange.object_id)
+ end
+ end
+end
+app = ConsoleTest.new
diff --git a/qpid/cpp/src/qmf/engine/ObjectIdImpl.cpp b/qpid/cpp/src/qmf/engine/ObjectIdImpl.cpp
index b08ae2756c..76db6d91f9 100644
--- a/qpid/cpp/src/qmf/engine/ObjectIdImpl.cpp
+++ b/qpid/cpp/src/qmf/engine/ObjectIdImpl.cpp
@@ -24,7 +24,6 @@ using namespace std;
using namespace qmf::engine;
using qpid::framing::Buffer;
-
void AgentAttachment::setBanks(uint32_t broker, uint32_t agent)
{
first =
@@ -121,25 +120,57 @@ const string& ObjectIdImpl::asString() const
return repr;
}
-bool ObjectIdImpl::operator==(const ObjectIdImpl& other) const
+#define ACTUAL_FIRST (agent == 0 ? first : first | agent->first)
+#define ACTUAL_OTHER (other.agent == 0 ? other.first : other.first | other.agent->first)
+
+uint8_t ObjectIdImpl::getFlags() const
{
- uint64_t otherFirst = agent == 0 ? other.first : other.first & 0xffff000000000000LL;
+ return (ACTUAL_FIRST & 0xF000000000000000LL) >> 60;
+}
- return first == otherFirst && second == other.second;
+uint16_t ObjectIdImpl::getSequence() const
+{
+ return (ACTUAL_FIRST & 0x0FFF000000000000LL) >> 48;
}
-bool ObjectIdImpl::operator<(const ObjectIdImpl& other) const
+uint32_t ObjectIdImpl::getBrokerBank() const
{
- uint64_t otherFirst = agent == 0 ? other.first : other.first & 0xffff000000000000LL;
+ return (ACTUAL_FIRST & 0x0000FFFFF0000000LL) >> 28;
+}
- return (first < otherFirst) || ((first == otherFirst) && (second < other.second));
+uint32_t ObjectIdImpl::getAgentBank() const
+{
+ return ACTUAL_FIRST & 0x000000000FFFFFFFLL;
}
-bool ObjectIdImpl::operator>(const ObjectIdImpl& other) const
+uint64_t ObjectIdImpl::getObjectNum() const
+{
+ return second;
+}
+
+uint32_t ObjectIdImpl::getObjectNumHi() const
+{
+ return (uint32_t) (second >> 32);
+}
+
+uint32_t ObjectIdImpl::getObjectNumLo() const
{
- uint64_t otherFirst = agent == 0 ? other.first : other.first & 0xffff000000000000LL;
+ return (uint32_t) (second & 0x00000000FFFFFFFFLL);
+}
+
+bool ObjectIdImpl::operator==(const ObjectIdImpl& other) const
+{
+ return ACTUAL_FIRST == ACTUAL_OTHER && second == other.second;
+}
- return (first > otherFirst) || ((first == otherFirst) && (second > other.second));
+bool ObjectIdImpl::operator<(const ObjectIdImpl& other) const
+{
+ return (ACTUAL_FIRST < ACTUAL_OTHER) || ((ACTUAL_FIRST == ACTUAL_OTHER) && (second < other.second));
+}
+
+bool ObjectIdImpl::operator>(const ObjectIdImpl& other) const
+{
+ return (ACTUAL_FIRST > ACTUAL_OTHER) || ((ACTUAL_FIRST == ACTUAL_OTHER) && (second > other.second));
}
diff --git a/qpid/cpp/src/qmf/engine/ObjectIdImpl.h b/qpid/cpp/src/qmf/engine/ObjectIdImpl.h
index d9871ac217..d70c8efff4 100644
--- a/qpid/cpp/src/qmf/engine/ObjectIdImpl.h
+++ b/qpid/cpp/src/qmf/engine/ObjectIdImpl.h
@@ -51,15 +51,15 @@ namespace engine {
void encode(qpid::framing::Buffer& buffer) const;
void fromString(const std::string& repr);
const std::string& asString() const;
- uint8_t getFlags() const { return (first & 0xF000000000000000LL) >> 60; }
- uint16_t getSequence() const { return (first & 0x0FFF000000000000LL) >> 48; }
- uint32_t getBrokerBank() const { return (first & 0x0000FFFFF0000000LL) >> 28; }
- uint32_t getAgentBank() const { return first & 0x000000000FFFFFFFLL; }
- uint64_t getObjectNum() const { return second; }
- uint32_t getObjectNumHi() const { return (uint32_t) (second >> 32); }
- uint32_t getObjectNumLo() const { return (uint32_t) (second & 0x00000000FFFFFFFFLL); }
+ uint8_t getFlags() const;
+ uint16_t getSequence() const;
+ uint32_t getBrokerBank() const;
+ uint32_t getAgentBank() const;
+ uint64_t getObjectNum() const;
+ uint32_t getObjectNumHi() const;
+ uint32_t getObjectNumLo() const;
bool isDurable() const { return getSequence() == 0; }
- void setValue(uint64_t f, uint64_t s) { first = f; second = s; }
+ void setValue(uint64_t f, uint64_t s) { first = f; second = s; agent = 0; }
bool operator==(const ObjectIdImpl& other) const;
bool operator<(const ObjectIdImpl& other) const;