From 3add7d150984e7904acf0898cab8cb7941de27ba Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Wed, 17 Feb 2010 20:21:10 +0000 Subject: fixed subject defaulting and added test git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@911166 13f79535-47bb-0310-9956-ffa450edef68 --- python/qpid/driver.py | 10 ++++++++-- python/qpid/tests/messaging.py | 13 +++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/python/qpid/driver.py b/python/qpid/driver.py index 3b9d7aa9fa..ed6fbc3b6a 100644 --- a/python/qpid/driver.py +++ b/python/qpid/driver.py @@ -950,6 +950,12 @@ class Driver: rk = _snd._routing_key else: rk = msg.subject + + if msg.subject is None: + subject = _snd.subject + else: + subject = msg.subject + # XXX: do we need to query to figure out how to create the reply-to interoperably? if msg.reply_to: rt = addr2reply_to(msg.reply_to) @@ -962,10 +968,10 @@ class Driver: correlation_id=msg.correlation_id, content_type=msg.content_type, application_headers=msg.properties) - if msg.subject is not None: + if subject is not None: if mp.application_headers is None: mp.application_headers = {} - mp.application_headers[SUBJECT] = msg.subject + mp.application_headers[SUBJECT] = subject if msg.to is not None: if mp.application_headers is None: mp.application_headers = {} diff --git a/python/qpid/tests/messaging.py b/python/qpid/tests/messaging.py index ca35c56166..125f1b7157 100644 --- a/python/qpid/tests/messaging.py +++ b/python/qpid/tests/messaging.py @@ -799,6 +799,19 @@ test-bindings-additive-queue; { self.drain(rcv_a, expected=[m1]) self.drain(rcv_b, expected=[m2]) + def testSubjectDefault(self): + m1 = self.content("testSubjectDefault", 1) + m2 = self.content("testSubjectDefault", 2) + snd = self.ssn.sender("amq.topic/a") + rcv = self.ssn.receiver("amq.topic") + snd.send(m1) + snd.send(Message(subject="b", content=m2)) + e1 = rcv.fetch(timeout=0) + e2 = rcv.fetch(timeout=0) + assert e1.subject == "a", "subject: %s" % e1.subject + assert e2.subject == "b", "subject: %s" % e2.subject + self.assertEmpty(rcv) + NOSUCH_Q = "this-queue-should-not-exist" UNPARSEABLE_ADDR = "name/subject; {bad options" UNLEXABLE_ADDR = "\0x0\0x1\0x2\0x3" -- cgit v1.2.1