You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2015/01/26 22:22:31 UTC
[1/2] qpid-proton git commit: PROTON-805: Improved integration
between proton python test harness and unittest.
Repository: qpid-proton
Updated Branches:
refs/heads/master 24bae3789 -> 270607f7f
PROTON-805: Improved integration between proton python test harness and unittest.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3d418391
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3d418391
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3d418391
Branch: refs/heads/master
Commit: 3d4183913b8408569cbb881adf07f3c3b98dc15d
Parents: 24bae37
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Jan 26 15:55:31 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Jan 26 16:17:12 2015 -0500
----------------------------------------------------------------------
tests/python/proton-test | 6 +++---
tests/python/proton_tests/common.py | 5 ++++-
2 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d418391/tests/python/proton-test
----------------------------------------------------------------------
diff --git a/tests/python/proton-test b/tests/python/proton-test
index c31f5d9..5efabfd 100755
--- a/tests/python/proton-test
+++ b/tests/python/proton-test
@@ -492,16 +492,16 @@ class MethodTest:
if hasattr(inst, "setUp"):
runner.run("setup", inst.setUp)
if runner.halt(): return runner
- elif hasattr(inst, "setup"):
+ if hasattr(inst, "setup"):
runner.run("setup", inst.setup)
if runner.halt(): return runner
runner.run("test", test)
+ if hasattr(inst, "teardown"):
+ runner.run("teardown", inst.teardown)
if hasattr(inst, "tearDown"):
runner.run("teardown", inst.tearDown)
- elif hasattr(inst, "teardown"):
- runner.run("teardown", inst.teardown)
return runner
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d418391/tests/python/proton_tests/common.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/common.py b/tests/python/proton_tests/common.py
index d159214..dcebe1f 100644
--- a/tests/python/proton_tests/common.py
+++ b/tests/python/proton_tests/common.py
@@ -17,6 +17,7 @@
# under the License.
#
+from unittest import TestCase
from random import randint
from threading import Thread
from socket import socket, AF_INET, SOCK_STREAM
@@ -80,9 +81,10 @@ def pump(transport1, transport2, buffer_size=1024):
def isSSLPresent():
return SSL.present()
-class Test(object):
+class Test(TestCase):
def __init__(self, name):
+ super(Test, self).__init__(name)
self.name = name
def configure(self, config):
@@ -107,6 +109,7 @@ class Test(object):
def verbose(self):
return int(self.default("verbose", 0))
+
class Skipped(Exception):
skipped = True
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/2] qpid-proton git commit: PROTON-805: Add tests and examples for
utils.SyncRequestResponse.
Posted by ac...@apache.org.
PROTON-805: Add tests and examples for utils.SyncRequestResponse.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/270607f7
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/270607f7
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/270607f7
Branch: refs/heads/master
Commit: 270607f7f078d0efc334ee83bd1e7594c8e8204c
Parents: 3d41839
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Jan 26 16:16:12 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Jan 26 16:20:40 2015 -0500
----------------------------------------------------------------------
tests/python/proton_tests/__init__.py | 1 +
tests/python/proton_tests/common.py | 3 ++
tests/python/proton_tests/utils.py | 86 ++++++++++++++++++++++++++++++
3 files changed, 90 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/270607f7/tests/python/proton_tests/__init__.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/__init__.py b/tests/python/proton_tests/__init__.py
index 1cecf38..b0f164a 100644
--- a/tests/python/proton_tests/__init__.py
+++ b/tests/python/proton_tests/__init__.py
@@ -27,3 +27,4 @@ import proton_tests.ssl
import proton_tests.interop
import proton_tests.soak
import proton_tests.url
+import proton_tests.utils
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/270607f7/tests/python/proton_tests/common.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/common.py b/tests/python/proton_tests/common.py
index dcebe1f..e164cc3 100644
--- a/tests/python/proton_tests/common.py
+++ b/tests/python/proton_tests/common.py
@@ -46,6 +46,9 @@ def free_tcp_ports(count=1):
s.close()
return ports
+def free_tcp_port():
+ return free_tcp_ports(1)[0]
+
def pump_uni(src, dst, buffer_size=1024):
p = src.pending()
c = dst.capacity()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/270607f7/tests/python/proton_tests/utils.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/utils.py b/tests/python/proton_tests/utils.py
new file mode 100644
index 0000000..41a7e71
--- /dev/null
+++ b/tests/python/proton_tests/utils.py
@@ -0,0 +1,86 @@
+#
+# 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.
+#
+
+import os
+from threading import Thread
+from unittest import TestCase
+from .common import Test, free_tcp_port
+from copy import copy
+from proton import Message, Url, generate_uuid
+from proton.handlers import MessagingHandler
+from proton.reactors import Container, send_msg, delivery_tags
+from proton.utils import SyncRequestResponse, BlockingConnection
+
+
+class EchoServer(MessagingHandler, Thread):
+ """
+ Simple echo server that echos messages to their reply-to. Runs in a thread.
+ Will only accept a single connection and shut down when that connection closes.
+ """
+
+ def __init__(self, url):
+ MessagingHandler.__init__(self)
+ Thread.__init__(self)
+ self.url = url
+ self.senders = {}
+ self.container = None
+
+ def on_start(self, event):
+ self.acceptor = event.container.listen(self.url)
+ self.container = event.container
+
+ def on_link_opening(self, event):
+ if event.link.is_sender:
+ if event.link.remote_source and event.link.remote_source.dynamic:
+ event.link.source.address = str(generate_uuid())
+ self.senders[event.link.source.address] = event.link
+ event.link.tags = delivery_tags()
+
+ def on_message(self, event):
+ m = event.message
+ sender = self.senders.get(m.reply_to)
+ if sender:
+ reply = Message(address=m.reply_to, body=m.body, correlation_id=m.correlation_id)
+ send_msg(sender, reply)
+
+ def on_connection_closing(self, event):
+ self.acceptor.close()
+
+ def run(self):
+ Container(self).run()
+
+
+class SyncRequestResponseTest(Test):
+ """Test SyncRequestResponse"""
+
+ def test_request_response(self):
+ def test(name, address="x"):
+ for i in xrange(5):
+ body="%s%s" % (name, i)
+ response = client.call(Message(address=address, body=body))
+ self.assertEquals(response.address, client.reply_to)
+ self.assertEquals(response.body, body)
+
+ server = EchoServer(Url(port=free_tcp_port()))
+ server.start()
+ client = SyncRequestResponse(BlockingConnection(server.url))
+ try:
+ test("foo") # Simple request/resposne
+ finally:
+ client.connection.close()
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org