Author: kgiusti
Date: Mon Oct 22 21:50:54 2012
New Revision: 1401096

URL: http://svn.apache.org/viewvc?rev=1401096&view=rev
Log:
PROTON-79: add some fancy tests.

Modified:
    qpid/proton/trunk/proton-c/bindings/python/proton.py
    qpid/proton/trunk/tests/proton_tests/engine.py

Modified: qpid/proton/trunk/proton-c/bindings/python/proton.py
URL: 
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/python/proton.py?rev=1401096&r1=1401095&r2=1401096&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/python/proton.py (original)
+++ qpid/proton/trunk/proton-c/bindings/python/proton.py Mon Oct 22 21:50:54 
2012
@@ -1892,6 +1892,20 @@ class Transport(object):
     else:
       return self._check(n)
 
+  def _get_max_frame_size(self):
+    return pn_transport_get_max_frame(self._trans)
+
+  def _set_max_frame_size(self, value):
+    pn_transport_set_max_frame(self._trans, value)
+
+  max_frame_size = property(_get_max_frame_size, _set_max_frame_size,
+                            doc="""
+Sets the maximum size for received frames (in bytes).
+""")
+
+  def peer_max_frame_size(self):
+    return pn_transport_get_peer_max_frame(self._trans)
+
 class SASLException(TransportException):
   pass
 

Modified: qpid/proton/trunk/tests/proton_tests/engine.py
URL: 
http://svn.apache.org/viewvc/qpid/proton/trunk/tests/proton_tests/engine.py?rev=1401096&r1=1401095&r2=1401096&view=diff
==============================================================================
--- qpid/proton/trunk/tests/proton_tests/engine.py (original)
+++ qpid/proton/trunk/tests/proton_tests/engine.py Mon Oct 22 21:50:54 2012
@@ -55,8 +55,10 @@ class Test(common.Test):
     c2 = Connection()
     t1 = Transport()
     t1.bind(c1)
+    c1._transport = t1
     t2 = Transport()
     t2.bind(c2)
+    c2._transport = t2
     self._wires.append((c1, t1, c2, t2))
     trc = os.environ.get("PN_TRACE_FRM")
     if trc and trc.lower() in ("1", "2", "yes", "true"):
@@ -65,8 +67,11 @@ class Test(common.Test):
       t2.trace(Transport.TRACE_FRM)
     return c1, c2
 
-  def link(self, name):
+  def link(self, name, max_frame=None):
     c1, c2 = self.connection()
+    if max_frame:
+      c1._transport.max_frame_size = max_frame[0]
+      c2._transport.max_frame_size = max_frame[1]
     c1.open()
     c2.open()
     ssn1 = c1.session()
@@ -559,6 +564,91 @@ class TransferTest(Test):
 
     assert sd.local_state == rd.remote_state == Delivery.ACCEPTED
 
+class MaxFrameTransferTest(Test):
+
+  def setup(self):
+    pass
+
+  def teardown(self):
+    self.cleanup()
+
+  def testMinFrame(self):
+    """
+    Configure receiver to support minimum max-frame as defined by AMQP-1.0.
+    Verify transfer of messages larger than 512.
+    """
+    self.snd, self.rcv = self.link("test-link", max_frame=[0,512])
+    self.c1 = self.snd.session.connection
+    self.c2 = self.rcv.session.connection
+    self.snd.open()
+    self.rcv.open()
+    self.pump()
+    assert self.rcv.session.connection._transport.max_frame_size == 512
+    assert self.snd.session.connection._transport.peer_max_frame_size() == 512
+
+    self.rcv.flow(1)
+    self.snd.delivery("tag")
+    msg = "X" * 513
+    n = self.snd.send(msg)
+    assert n == len(msg)
+    assert self.snd.advance()
+
+    self.pump()
+
+    bytes = self.rcv.recv(513)
+    assert bytes == msg
+
+    bytes = self.rcv.recv(1024)
+    assert bytes == None
+
+  def testOddFrame(self):
+    """
+    Test an odd sized max limit with data that will require multiple frames to
+    be transfered.
+    """
+    self.snd, self.rcv = self.link("test-link", max_frame=[0,521])
+    self.c1 = self.snd.session.connection
+    self.c2 = self.rcv.session.connection
+    self.snd.open()
+    self.rcv.open()
+    self.pump()
+    assert self.rcv.session.connection._transport.max_frame_size == 521
+    assert self.snd.session.connection._transport.peer_max_frame_size() == 521
+
+    self.rcv.flow(2)
+    self.snd.delivery("tag")
+    msg = "X" * 1699
+    n = self.snd.send(msg)
+    assert n == len(msg)
+    assert self.snd.advance()
+
+    self.pump()
+
+    bytes = self.rcv.recv(1699)
+    assert bytes == msg
+
+    bytes = self.rcv.recv(1024)
+    assert bytes == None
+
+    self.rcv.advance()
+
+    self.snd.delivery("gat")
+    msg = "Y" * 1426
+    n = self.snd.send(msg)
+    assert n == len(msg)
+    assert self.snd.advance()
+
+    self.pump()
+
+    bytes = self.rcv.recv(1426)
+    assert bytes == msg
+
+    self.pump()
+
+    bytes = self.rcv.recv(1024)
+    assert bytes == None
+
+
 class CreditTest(Test):
 
   def setup(self):



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to