qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject svn commit: r732778 - in /qpid/trunk/qpid/python: qpid/delegates.py tests/connection.py
Date Thu, 08 Jan 2009 18:27:40 GMT
Author: rhs
Date: Thu Jan  8 10:27:39 2009
New Revision: 732778

URL: http://svn.apache.org/viewvc?rev=732778&view=rev
Log:
ignore hearbeat controls rather than barfing on them, also permit the heartbeat to be specified
on connection creation

Modified:
    qpid/trunk/qpid/python/qpid/delegates.py
    qpid/trunk/qpid/python/tests/connection.py

Modified: qpid/trunk/qpid/python/qpid/delegates.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/delegates.py?rev=732778&r1=732777&r2=732778&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/delegates.py (original)
+++ qpid/trunk/qpid/python/qpid/delegates.py Thu Jan  8 10:27:39 2009
@@ -61,6 +61,9 @@
     self.connection.opened = False
     notify(self.connection.condition)
 
+  def connection_heartbeat(self, ch, hrt):
+    pass
+
   def session_attach(self, ch, a):
     try:
       self.connection.attach(a.name, ch, self.delegate, a.force)
@@ -139,11 +142,13 @@
                 "version": "development",
                 "platform": os.name}
 
-  def __init__(self, connection, username="guest", password="guest", mechanism="PLAIN"):
+  def __init__(self, connection, username="guest", password="guest",
+               mechanism="PLAIN", heartbeat=None):
     Delegate.__init__(self, connection)
     self.username = username
     self.password = password
     self.mechanism = mechanism
+    self.heartbeat = heartbeat
 
   def start(self):
     self.connection.write_header(self.spec.major, self.spec.minor)
@@ -154,7 +159,7 @@
     ch.connection_start_ok(client_properties=Client.PROPERTIES, mechanism=self.mechanism,
response=r)
 
   def connection_tune(self, ch, tune):
-    ch.connection_tune_ok()
+    ch.connection_tune_ok(heartbeat=self.heartbeat)
     ch.connection_open()
 
   def connection_open_ok(self, ch, open_ok):

Modified: qpid/trunk/qpid/python/tests/connection.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/tests/connection.py?rev=732778&r1=732777&r2=732778&view=diff
==============================================================================
--- qpid/trunk/qpid/python/tests/connection.py (original)
+++ qpid/trunk/qpid/python/tests/connection.py Thu Jan  8 10:27:39 2009
@@ -25,7 +25,6 @@
 from qpid.testlib import testrunner
 from qpid.delegates import Server
 from qpid.queue import Queue
-from qpid.spec010 import load
 from qpid.session import Delegate
 
 PORT = 1234
@@ -62,13 +61,14 @@
                                     cmd.acquire_mode, m)
     elif cmd.destination == "abort":
       self.session.channel.connection.sock.close()
+    elif cmd.destination == "heartbeat":
+      self.session.channel.connection_heartbeat()
     else:
       self.queue.put((cmd, headers, body))
 
 class ConnectionTest(TestCase):
 
   def setUp(self):
-    self.spec = load(testrunner.get_spec_file("amqp.0-10.xml"))
     self.queue = Queue()
     self.running = True
     started = Event()
@@ -76,7 +76,7 @@
     def run():
       ts = TestServer(self.queue)
       for s in listen("0.0.0.0", PORT, lambda: self.running, lambda: started.set()):
-        conn = Connection(s, self.spec, ts.connection)
+        conn = Connection(s, delegate=ts.connection)
         try:
           conn.start(5)
         except Closed:
@@ -94,8 +94,8 @@
     connect("0.0.0.0", PORT).close()
     self.server.join(3)
 
-  def connect(self):
-    return Connection(connect("0.0.0.0", PORT), self.spec)
+  def connect(self, **kwargs):
+    return Connection(connect("0.0.0.0", PORT), **kwargs)
 
   def test(self):
     c = self.connect()
@@ -213,3 +213,10 @@
     s.auto_sync = False
     s.message_transfer("echo", message=Message("test"))
     s.sync(10)
+
+  def testHeartbeat(self):
+    c = self.connect(heartbeat=10)
+    c.start(10)
+    s = c.session("test")
+    s.channel.connection_heartbeat()
+    s.message_transfer("heartbeat")



Mime
View raw message