summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2010-02-17 20:21:10 +0000
committerRafael H. Schloming <rhs@apache.org>2010-02-17 20:21:10 +0000
commit5fb7281ee4a8d0ed5821ed5f0e295ea26dda7ca6 (patch)
tree6ed05ca20346bcb277d0fe61e55ed06f8d11be3d
parenta753a0f8d2770b7400664898cec598db618f01e0 (diff)
downloadqpid-python-5fb7281ee4a8d0ed5821ed5f0e295ea26dda7ca6.tar.gz
fixed subject defaulting and added test
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@911166 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/python/qpid/driver.py10
-rw-r--r--qpid/python/qpid/tests/messaging.py13
2 files changed, 21 insertions, 2 deletions
diff --git a/qpid/python/qpid/driver.py b/qpid/python/qpid/driver.py
index 3b9d7aa9fa..ed6fbc3b6a 100644
--- a/qpid/python/qpid/driver.py
+++ b/qpid/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/qpid/python/qpid/tests/messaging.py b/qpid/python/qpid/tests/messaging.py
index ca35c56166..125f1b7157 100644
--- a/qpid/python/qpid/tests/messaging.py
+++ b/qpid/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"