summaryrefslogtreecommitdiff
path: root/qpid/python
diff options
context:
space:
mode:
authorKim van der Riet <kpvdr@apache.org>2013-09-20 18:59:30 +0000
committerKim van der Riet <kpvdr@apache.org>2013-09-20 18:59:30 +0000
commitc70bf3ea28cdf6bafd8571690d3e5c466a0658a2 (patch)
tree68b24940e433f3f9c278b054d9ea1622389bd332 /qpid/python
parentfcdf1723c7b5cdf0772054a93edb6e7d97c4bb1e (diff)
downloadqpid-python-c70bf3ea28cdf6bafd8571690d3e5c466a0658a2.tar.gz
QPID-4984: WIP - Merge from trunk r.1525056
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/linearstore@1525101 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python')
-rwxr-xr-xqpid/python/examples/api/spout4
-rw-r--r--qpid/python/qpid/tests/messaging/__init__.py27
-rw-r--r--qpid/python/qpid/tests/messaging/implementation.py24
-rw-r--r--qpid/python/qpid/tests/messaging/message.py23
-rwxr-xr-xqpid/python/setup.py2
5 files changed, 73 insertions, 7 deletions
diff --git a/qpid/python/examples/api/spout b/qpid/python/examples/api/spout
index e4d7cfb970..6584b853fc 100755
--- a/qpid/python/examples/api/spout
+++ b/qpid/python/examples/api/spout
@@ -45,6 +45,8 @@ parser.add_option("-l", "--reconnect-limit", type="int",
help="maximum number of reconnect attempts")
parser.add_option("-c", "--count", type="int", default=1,
help="stop after count messages have been sent, zero disables (default %default)")
+parser.add_option("-d", "--durable", action="store_true",
+ help="make the message persistent")
parser.add_option("-t", "--timeout", type="float", default=None,
help="exit after the specified time")
parser.add_option("-I", "--id", help="use the supplied id instead of generating one")
@@ -111,6 +113,8 @@ try:
msg = Message(subject=opts.subject,
reply_to=opts.reply_to,
content=content)
+ if opts.durable:
+ msg.durable = True
if content_type is not None:
msg.content_type = content_type
msg.properties["spout-id"] = "%s:%s" % (spout_id, count)
diff --git a/qpid/python/qpid/tests/messaging/__init__.py b/qpid/python/qpid/tests/messaging/__init__.py
index 8f6680d5e3..38a5b066d6 100644
--- a/qpid/python/qpid/tests/messaging/__init__.py
+++ b/qpid/python/qpid/tests/messaging/__init__.py
@@ -20,7 +20,7 @@
import time
from math import ceil
from qpid.harness import Skipped
-from qpid.messaging import *
+from qpid.tests.messaging.implementation import *
from qpid.tests import Test
class Base(Test):
@@ -115,7 +115,7 @@ class Base(Test):
echo = echo.content
assert msg == echo, "expected %s, got %s" % (msg, echo)
else:
- delta = self.diff(msg, echo, ("x-amqp-0-10.routing-key",))
+ delta = self.diff(msg, echo, ("x-amqp-0-10.routing-key","qpid.subject"))
mttl, ettl = delta.pop("ttl", (0, 0))
if redelivered:
assert echo.redelivered, \
@@ -179,7 +179,26 @@ class Base(Test):
return "tcp"
def connection_options(self):
- return {"reconnect": self.reconnect(),
- "transport": self.transport()}
+ protocol_version = self.config.defines.get("protocol_version")
+ if protocol_version:
+ return {"reconnect": self.reconnect(),
+ "transport": self.transport(),
+ "protocol":protocol_version}
+ else:
+ return {"reconnect": self.reconnect(),
+ "transport": self.transport()}
+
+class VersionTest (Base):
+ def create_connection(self, version="amqp1.0", force=False):
+ opts = self.connection_options()
+ if force or not 'protocol' in opts:
+ opts['protocol'] = version;
+ return Connection.establish(self.broker, **opts)
+
+ def setup_connection(self):
+ return self.create_connection()
+
+ def setup_session(self):
+ return self.conn.session()
import address, endpoints, message
diff --git a/qpid/python/qpid/tests/messaging/implementation.py b/qpid/python/qpid/tests/messaging/implementation.py
new file mode 100644
index 0000000000..c81fb6c99c
--- /dev/null
+++ b/qpid/python/qpid/tests/messaging/implementation.py
@@ -0,0 +1,24 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+try:
+ from qpid_messaging import *
+ from qpid.datatypes import uuid4
+except ImportError, e:
+ print "Falling back to pure bindings, %s" % e
+ from qpid.messaging import *
diff --git a/qpid/python/qpid/tests/messaging/message.py b/qpid/python/qpid/tests/messaging/message.py
index 7328165db7..bfdd2c79e5 100644
--- a/qpid/python/qpid/tests/messaging/message.py
+++ b/qpid/python/qpid/tests/messaging/message.py
@@ -17,7 +17,8 @@
# under the License.
#
-from qpid.messaging import *
+from qpid.tests.messaging.implementation import *
+from qpid.messaging.address import parse
from qpid.tests.messaging import Base
class MessageTests(Base):
@@ -110,6 +111,17 @@ class MessageEchoTests(Base):
msg.reply_to = "reply-address"
self.check(msg)
+ def testApplicationProperties(self):
+ msg = Message()
+ msg.properties["a"] = u"A"
+ msg.properties["b"] = 1
+ msg.properties["c"] = ["x", 2]
+ msg.properties["d"] = "D"
+ #make sure deleting works as expected
+ msg.properties["foo"] = "bar"
+ del msg.properties["foo"]
+ self.check(msg)
+
def testContentTypeUnknown(self):
msg = Message(content_type = "this-content-type-does-not-exist")
self.check(msg)
@@ -126,7 +138,14 @@ class MessageEchoTests(Base):
msg = Message(reply_to=addr)
self.snd.send(msg)
echo = self.rcv.fetch(0)
- assert echo.reply_to == expected, echo.reply_to
+ #reparse addresses and check individual parts as this avoids
+ #failing due to differenecs in whitespace when running over
+ #swigged client:
+ (actual_name, actual_subject, actual_options) = parse(echo.reply_to)
+ (expected_name, expected_subject, expected_options) = parse(expected)
+ assert actual_name == expected_name, (actual_name, expected_name)
+ assert actual_subject == expected_subject, (actual_subject, expected_subject)
+ assert actual_options == expected_options, (actual_options, expected_options)
self.ssn.acknowledge(echo)
def testReplyTo(self):
diff --git a/qpid/python/setup.py b/qpid/python/setup.py
index bc8c3e3fa4..aefd86e293 100755
--- a/qpid/python/setup.py
+++ b/qpid/python/setup.py
@@ -298,7 +298,7 @@ class install_lib(_install_lib):
return outfiles + extra
setup(name="qpid-python",
- version="0.23",
+ version="0.25",
author="Apache Qpid",
author_email="dev@qpid.apache.org",
packages=["mllib", "qpid", "qpid.messaging", "qpid.tests",