Repository: qpid-proton
Updated Branches:
  refs/heads/master 1505c3ddb -> f063ff1e7


PROTON-1190: add a test verifying Detach frames arent sent after End


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/f063ff1e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/f063ff1e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/f063ff1e

Branch: refs/heads/master
Commit: f063ff1e7af9500304d06878f5eaf9bdc7f5f063
Parents: 9c7bdbd
Author: Robert Gemmell <[email protected]>
Authored: Wed May 4 17:48:23 2016 +0100
Committer: Robert Gemmell <[email protected]>
Committed: Wed May 4 17:53:04 2016 +0100

----------------------------------------------------------------------
 .../proton/engine/impl/TransportImplTest.java   | 74 ++++++++++++++++++++
 1 file changed, 74 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f063ff1e/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportImplTest.java
----------------------------------------------------------------------
diff --git 
a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportImplTest.java
 
b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportImplTest.java
index d7cec11..2a9b2b6 100644
--- 
a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportImplTest.java
+++ 
b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportImplTest.java
@@ -606,6 +606,80 @@ public class TransportImplTest
     }
 
     /*
+     * Verify that no Attach frame is emitted by the Transport should a 
Receiver
+     * be closed after the session End frame was sent.
+     */
+    @Test
+    public void testReceiverCloseAfterEndSent()
+    {
+        doLinkDetachAfterEndSentTestImpl(true);
+    }
+
+    /*
+     * Verify that no Attach frame is emitted by the Transport should a Sender
+     * be closed after the session End frame was sent.
+     */
+    @Test
+    public void testSenderCloseAfterEndSent()
+    {
+        doLinkDetachAfterEndSentTestImpl(false);
+    }
+
+    void doLinkDetachAfterEndSentTestImpl(boolean receiverLink)
+    {
+        MockTransportImpl transport = new MockTransportImpl();
+        Connection connection = Proton.connection();
+        transport.bind(connection);
+
+        connection.open();
+
+        Session session = connection.session();
+        session.open();
+
+        Link link = null;
+        if(receiverLink)
+        {
+            link = session.receiver("myReceiver");
+        }
+        else
+        {
+            link = session.sender("mySender");
+        }
+        link.open();
+
+        pumpMockTransport(transport);
+
+        assertEquals("Unexpected frames written: " + 
getFrameTypesWritten(transport), 3, transport.writes.size());
+
+        assertTrue("Unexpected frame type", transport.writes.get(0) instanceof 
Open);
+        assertTrue("Unexpected frame type", transport.writes.get(1) instanceof 
Begin);
+        assertTrue("Unexpected frame type", transport.writes.get(2) instanceof 
Attach);
+
+        // Send the necessary responses to open/begin
+        transport.handleFrame(new TransportFrame(0, new Open(), null));
+
+        Begin begin = new Begin();
+        begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
+        transport.handleFrame(new TransportFrame(0, begin, null));
+
+        assertEquals("Unexpected frames written: " + 
getFrameTypesWritten(transport), 3, transport.writes.size());
+
+        // Cause an End frame to be sent
+        session.close();
+        pumpMockTransport(transport);
+
+        assertEquals("Unexpected frames written: " + 
getFrameTypesWritten(transport), 4, transport.writes.size());
+        assertTrue("Unexpected frame type", transport.writes.get(3) instanceof 
End);
+
+        // Close the link and verify the transport doesn't
+        // send any Detach frame, as an End frame was sent already.
+        link.close();
+        pumpMockTransport(transport);
+
+        assertEquals("Unexpected frames written: " + 
getFrameTypesWritten(transport), 4, transport.writes.size());
+    }
+
+    /*
      * No frames should be written until the Connection object is
      * opened, at which point the Open and Begin frames should
      * be pipelined together.


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

Reply via email to