You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2022/08/24 17:47:53 UTC
[qpid-protonj2] branch main updated: PROTON-2593 Add sine testing of parsing frame size when split
This is an automated email from the ASF dual-hosted git repository.
tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git
The following commit(s) were added to refs/heads/main by this push:
new 755d7bc8 PROTON-2593 Add sine testing of parsing frame size when split
755d7bc8 is described below
commit 755d7bc855a6ef669ec88c948152ce88b9d5776b
Author: Timothy Bish <ta...@gmail.com>
AuthorDate: Wed Aug 24 13:46:41 2022 -0400
PROTON-2593 Add sine testing of parsing frame size when split
Test that a frame size when split across buffer reads is handled
correctly.
---
.../impl/ProtonFrameDecodingHandlerTest.java | 55 ++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/ProtonFrameDecodingHandlerTest.java b/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/ProtonFrameDecodingHandlerTest.java
index 785b7fdc..895ec8b9 100644
--- a/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/ProtonFrameDecodingHandlerTest.java
+++ b/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/ProtonFrameDecodingHandlerTest.java
@@ -322,6 +322,61 @@ public class ProtonFrameDecodingHandlerTest {
assertFalse(decoded.hasProperties());
}
+ @Test
+ public void testDecodePipelinedHeaderAndOpenEncodedFrameSizeSplitAcrossTwoReads() throws Exception {
+ // Frame data for: Open
+ // Open{ containerId='container', hostname='localhost', maxFrameSize=16384, channelMax=65535,
+ // idleTimeOut=30000, outgoingLocales=null, incomingLocales=null, offeredCapabilities=null,
+ // desiredCapabilities=null, properties=null}
+ final byte[] basicOpen1 = new byte[] {
+ 'A', 'M', 'Q', 'P', 0, 1, 0, 0, 0 }; // HEADER + first frame byte
+ final byte[] basicOpen2 = new byte[] { 0 };
+ final byte[] basicOpen3 = new byte[] { 0, 49 };
+ final byte[] basicOpen4 = new byte[] {
+ 2, 0, 0, 0, 0, 83, 16, -64, 36, 5, -95, 9, 99, 111,
+ 110, 116, 97, 105, 110, 101, 114, -95, 9, 108, 111, 99, 97, 108,
+ 104, 111, 115, 116, 112, 0, 0, 64, 0, 96, -1, -1, 112, 0, 0, 117, 48 };
+ ArgumentCaptor<IncomingAMQPEnvelope> argument = ArgumentCaptor.forClass(IncomingAMQPEnvelope.class);
+
+ ProtonFrameDecodingHandler handler = createFrameDecoder();
+ ProtonEngineHandlerContext context = Mockito.mock(ProtonEngineHandlerContext.class);
+
+ final ProtonBuffer buffer1 = ProtonByteBufferAllocator.DEFAULT.wrap(basicOpen1);
+ final ProtonBuffer buffer2 = ProtonByteBufferAllocator.DEFAULT.wrap(basicOpen2);
+ final ProtonBuffer buffer3 = ProtonByteBufferAllocator.DEFAULT.wrap(basicOpen3);
+ final ProtonBuffer buffer4 = ProtonByteBufferAllocator.DEFAULT.wrap(basicOpen4);
+
+ handler.handleRead(context, buffer1);
+ handler.handleRead(context, buffer2);
+ handler.handleRead(context, buffer3);
+ handler.handleRead(context, buffer4);
+
+ Mockito.verify(context).fireRead(Mockito.any(HeaderEnvelope.class));
+ Mockito.verify(context).interestMask(ProtonEngineHandlerContext.HANDLER_READS);
+ Mockito.verify(context).fireRead(argument.capture());
+ Mockito.verifyNoMoreInteractions(context);
+
+ assertNotNull(argument.getValue());
+ assertTrue(argument.getValue().getBody() instanceof Open);
+
+ Open decoded = (Open) argument.getValue().getBody();
+
+ assertTrue(decoded.hasContainerId());
+ assertEquals("container", decoded.getContainerId());
+ assertTrue(decoded.hasHostname());
+ assertEquals("localhost", decoded.getHostname());
+ assertTrue(decoded.hasMaxFrameSize());
+ assertEquals(16384, decoded.getMaxFrameSize());
+ assertTrue(decoded.hasChannelMax());
+ assertTrue(decoded.hasIdleTimeout());
+ assertEquals(30000, decoded.getIdleTimeout());
+ assertFalse(decoded.hasOutgoingLocales());
+ assertFalse(decoded.hasIncomingLocales());
+ assertFalse(decoded.hasOfferedCapabilities());
+ assertFalse(decoded.hasDesiredCapabilities());
+ assertFalse(decoded.hasProperties());
+ }
+
@Test
public void testDecodePipelinedHeaderAndOpenEncodedFrameSplitAcrossThreeReads() throws Exception {
// Frame data for: Open
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org