You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kg...@apache.org on 2015/12/01 16:28:18 UTC
qpid-proton git commit: PROTON-1056: Fix the ApplicationEvent string
conversion
Repository: qpid-proton
Updated Branches:
refs/heads/master fdbba6973 -> 8117f18e3
PROTON-1056: Fix the ApplicationEvent string conversion
Also add test coverage of ApplicationEvents. There was no coverage,
and that made me feel sad.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/8117f18e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8117f18e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8117f18e
Branch: refs/heads/master
Commit: 8117f18e330acb0b34391e19fcc28ed85bbde166
Parents: fdbba69
Author: Ken Giusti <kg...@apache.org>
Authored: Tue Dec 1 10:24:31 2015 -0500
Committer: Ken Giusti <kg...@apache.org>
Committed: Tue Dec 1 10:24:31 2015 -0500
----------------------------------------------------------------------
proton-c/bindings/python/proton/reactor.py | 2 +-
tests/python/proton_tests/reactor.py | 58 ++++++++++++++++++++++++-
2 files changed, 57 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8117f18e/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
index 8eaee5c..0f59682 100644
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@ -275,7 +275,7 @@ class ApplicationEvent(EventBase):
def __repr__(self):
objects = [self.connection, self.session, self.link, self.delivery, self.subject]
- return "%s(%s)" % (typename, ", ".join([str(o) for o in objects if o is not None]))
+ return "%s(%s)" % (self.type, ", ".join([str(o) for o in objects if o is not None]))
class Transaction(object):
"""
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8117f18e/tests/python/proton_tests/reactor.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/reactor.py b/tests/python/proton_tests/reactor.py
index 890f4b0..c8cd894 100644
--- a/tests/python/proton_tests/reactor.py
+++ b/tests/python/proton_tests/reactor.py
@@ -18,9 +18,11 @@ from __future__ import absolute_import
# under the License.
#
-from .common import Test, SkipTest
-from proton.reactor import Reactor
+import time
+from .common import Test, SkipTest, TestServer
+from proton.reactor import Reactor, ApplicationEvent, EventInjector
from proton.handlers import CHandshaker
+from proton import Handler
class Barf(Exception):
pass
@@ -400,3 +402,55 @@ class HandlerDerivationTest(Test):
assert False, "expected to barf"
except:
assert h.init, "excpected the init"
+
+
+class ApplicationEventTest(Test):
+ """Test application defined events and handlers."""
+
+ class MyTestServer(TestServer):
+ def __init__(self):
+ super(ApplicationEventTest.MyTestServer, self).__init__()
+
+ class MyHandler(Handler):
+ def __init__(self, test):
+ super(ApplicationEventTest.MyHandler, self).__init__()
+ self._test = test
+
+ def on_hello(self, event):
+ # verify PROTON-1056
+ self._test.hello_rcvd = str(event)
+
+ def on_goodbye(self, event):
+ self._test.goodbye_rcvd = str(event)
+
+ def setUp(self):
+ import os
+ if not hasattr(os, 'pipe'):
+ # KAG: seems like Jython doesn't have an os.pipe() method
+ raise SkipTest()
+ self.server = ApplicationEventTest.MyTestServer()
+ self.server.reactor.handler.add(ApplicationEventTest.MyHandler(self))
+ self.event_injector = EventInjector()
+ self.hello_event = ApplicationEvent("hello")
+ self.goodbye_event = ApplicationEvent("goodbye")
+ self.server.reactor.selectable(self.event_injector)
+ self.hello_rcvd = None
+ self.goodbye_rcvd = None
+ self.server.start()
+
+ def tearDown(self):
+ self.server.stop()
+
+ def _wait_for(self, predicate, timeout=10.0):
+ deadline = time.time() + timeout
+ while time.time() < deadline:
+ if predicate():
+ break
+ time.sleep(0.1)
+ assert predicate()
+
+ def test_application_events(self):
+ self.event_injector.trigger(self.hello_event)
+ self._wait_for(lambda: self.hello_rcvd is not None)
+ self.event_injector.trigger(self.goodbye_event)
+ self._wait_for(lambda: self.goodbye_rcvd is not None)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org