From 77a319a41c90efeabbfe42b7b85d6c7ac30a68e6 Mon Sep 17 00:00:00 2001 From: Keith Wall Date: Sat, 2 Apr 2016 22:28:45 +0000 Subject: QPID-7180: [Python Test Suite] Adapt broker url to match expectations of the C++ client if swigged client is in-use git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1737539 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/python/qpid/tests/messaging/__init__.py | 34 +++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/qpid/python/qpid/tests/messaging/__init__.py b/qpid/python/qpid/tests/messaging/__init__.py index 38a5b066d6..be7000f9c9 100644 --- a/qpid/python/qpid/tests/messaging/__init__.py +++ b/qpid/python/qpid/tests/messaging/__init__.py @@ -22,6 +22,7 @@ from math import ceil from qpid.harness import Skipped from qpid.tests.messaging.implementation import * from qpid.tests import Test +from qpid.util import URL class Base(Test): @@ -39,7 +40,11 @@ class Base(Test): def setup(self): self.test_id = uuid4() - self.broker = self.config.broker + if self.is_swigged_qpid_messaging(): + self.broker = CompatURL(self.config.broker) + else: + self.broker = self.config.broker + try: self.conn = self.setup_connection() except ConnectError, e: @@ -188,6 +193,9 @@ class Base(Test): return {"reconnect": self.reconnect(), "transport": self.transport()} + def is_swigged_qpid_messaging(self): + return Connection.__module__ == 'qpid_messaging' + class VersionTest (Base): def create_connection(self, version="amqp1.0", force=False): opts = self.connection_options() @@ -201,4 +209,28 @@ class VersionTest (Base): def setup_session(self): return self.conn.session() +class CompatURL(URL): + """The formation of the URL for the C++ client is different to that of the pure Python client in that + the C++ client expects :/.. whereas the pure Python's URL class expects + ://:..""" + def __init__(self, *args, **kwargs): + URL.__init__(self, *args, **kwargs) + + def __str__(self): + s = "" + if self.scheme: + s += "%s:" % self.scheme + if self.user: + s += self.user + if self.password: + s += "/%s" % self.password + s += "@" + if ':' not in self.host: + s += self.host + else: + s += "[%s]" % self.host + if self.port: + s += ":%s" % self.port + return s + import address, endpoints, message -- cgit v1.2.1