summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2011-03-17 13:03:08 +0000
committerRafael H. Schloming <rhs@apache.org>2011-03-17 13:03:08 +0000
commitfa356bee994518e9f196be596199b5d518c048c8 (patch)
tree21a3cda37d453e399e57f77116c3cb21c56791ae /python
parent887da9b9cbe998b94563ad63be56eae4379e4d0a (diff)
downloadqpid-python-fa356bee994518e9f196be596199b5d518c048c8.tar.gz
added support for address assertion
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1082478 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python')
-rw-r--r--python/qpid/messaging/driver.py8
-rw-r--r--python/qpid/tests/messaging/endpoints.py7
2 files changed, 14 insertions, 1 deletions
diff --git a/python/qpid/messaging/driver.py b/python/qpid/messaging/driver.py
index 1323e4185c..67b0ff909d 100644
--- a/python/qpid/messaging/driver.py
+++ b/python/qpid/messaging/driver.py
@@ -930,6 +930,7 @@ class Engine:
def resolve_declare(self, sst, lnk, dir, action):
declare = lnk.options.get("create") in ("always", dir)
+ assrt = lnk.options.get("assert") in ("always", dir)
def do_resolved(type, subtype):
err = None
if type is None:
@@ -938,7 +939,12 @@ class Engine:
else:
err = NotFound(text="no such queue: %s" % lnk.name)
else:
- action(type, subtype)
+ if assrt:
+ expected = lnk.options.get("node", {}).get("type")
+ if type != expected:
+ err = AssertionFailed(text="expected %s, got %s" % (expected, type))
+ if err is None:
+ action(type, subtype)
if err:
tgt = lnk.target
diff --git a/python/qpid/tests/messaging/endpoints.py b/python/qpid/tests/messaging/endpoints.py
index 419d0cb395..1929a47a6b 100644
--- a/python/qpid/tests/messaging/endpoints.py
+++ b/python/qpid/tests/messaging/endpoints.py
@@ -1186,6 +1186,13 @@ test-link-bindings-queue; {
snd.send(m)
self.drain(qrcv, expected=msgs)
+ def testAssert(self):
+ try:
+ snd = self.ssn.sender("amq.topic; {assert: always, node: {type: queue}}")
+ assert 0, "assertion failed to trigger"
+ except AssertionFailed, e:
+ pass
+
NOSUCH_Q = "this-queue-should-not-exist"
UNPARSEABLE_ADDR = "name/subject; {bad options"
UNLEXABLE_ADDR = "\0x0\0x1\0x2\0x3"