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/30 21:34:38 UTC
[qpid-protonj2] branch main updated: PROTON-2593 Add some frame decoding tests with transfer and payload
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 1908f9a9 PROTON-2593 Add some frame decoding tests with transfer and payload
1908f9a9 is described below
commit 1908f9a964635f08df5d9807593e6dbe11924710
Author: Timothy Bish <ta...@gmail.com>
AuthorDate: Tue Aug 30 17:34:22 2022 -0400
PROTON-2593 Add some frame decoding tests with transfer and payload
Tests that exercise the handling of transfer frames with atteached
payloads
---
...LegacyCodecTransferFramesTestDataGenerator.java | 72 +++++++
.../driver/legacy/LegacyFrameDataGenerator.java | 32 ++-
.../impl/ProtonFrameDecodingHandlerTest.java | 225 +++++++++++++++++++++
3 files changed, 324 insertions(+), 5 deletions(-)
diff --git a/protonj2-test-driver/src/test/java/org/apache/qpid/protonj2/test/driver/legacy/LegacyCodecTransferFramesTestDataGenerator.java b/protonj2-test-driver/src/test/java/org/apache/qpid/protonj2/test/driver/legacy/LegacyCodecTransferFramesTestDataGenerator.java
new file mode 100644
index 00000000..67e0dc03
--- /dev/null
+++ b/protonj2-test-driver/src/test/java/org/apache/qpid/protonj2/test/driver/legacy/LegacyCodecTransferFramesTestDataGenerator.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.protonj2.test.driver.legacy;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.UUID;
+
+import org.apache.qpid.proton.amqp.Binary;
+import org.apache.qpid.proton.amqp.UnsignedInteger;
+import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
+import org.apache.qpid.proton.amqp.messaging.Data;
+import org.apache.qpid.proton.amqp.transport.Transfer;
+import org.apache.qpid.proton.codec.ReadableBuffer;
+import org.apache.qpid.proton.codec.WritableBuffer;
+import org.apache.qpid.proton.message.Message;
+
+/**
+ * Generates the test data used to create a tests for codec that read
+ * Frames encoded using the proton-j framework.
+ */
+public class LegacyCodecTransferFramesTestDataGenerator {
+
+ public static void main(String[] args) {
+ // 1: Transfer frame for complete delivery
+ Transfer completedTransfer = new Transfer();
+ completedTransfer.setAborted(false);
+ completedTransfer.setMore(false);
+ completedTransfer.setDeliveryId(UnsignedInteger.valueOf(1));
+ completedTransfer.setHandle(UnsignedInteger.valueOf(2));
+ completedTransfer.setDeliveryTag(new Binary(new byte[] { 0, 1 }));
+ completedTransfer.setMessageFormat(null);
+ completedTransfer.setSettled(true);
+
+ String emptyOpenFrameString = LegacyFrameDataGenerator.generateUnitTestVariable("completedTransfer", completedTransfer, encodeMessage());
+ System.out.println(emptyOpenFrameString);
+ }
+
+ private static ReadableBuffer encodeMessage() {
+ final WritableBuffer.ByteBufferWrapper buffer = WritableBuffer.ByteBufferWrapper.allocate(1024);
+ final byte[] body = new byte[100];
+ Arrays.fill(body, (byte) 'A');
+
+ Message message = Message.Factory.create();
+
+ ApplicationProperties properties = new ApplicationProperties(new HashMap<>());
+ properties.getValue().put("timestamp", "123456789");
+
+ message.setAddress("test");
+ message.setApplicationProperties(properties);
+ message.setBody(new Data(new Binary(body)));
+ message.setMessageId(UUID.randomUUID());
+
+ message.encode(buffer);
+
+ return buffer.toReadableBuffer();
+ }
+}
diff --git a/protonj2-test-driver/src/test/java/org/apache/qpid/protonj2/test/driver/legacy/LegacyFrameDataGenerator.java b/protonj2-test-driver/src/test/java/org/apache/qpid/protonj2/test/driver/legacy/LegacyFrameDataGenerator.java
index f9b1bd68..54b44d79 100644
--- a/protonj2-test-driver/src/test/java/org/apache/qpid/protonj2/test/driver/legacy/LegacyFrameDataGenerator.java
+++ b/protonj2-test-driver/src/test/java/org/apache/qpid/protonj2/test/driver/legacy/LegacyFrameDataGenerator.java
@@ -21,6 +21,7 @@ import java.nio.ByteBuffer;
import org.apache.qpid.proton.codec.AMQPDefinedTypes;
import org.apache.qpid.proton.codec.DecoderImpl;
import org.apache.qpid.proton.codec.EncoderImpl;
+import org.apache.qpid.proton.codec.ReadableBuffer;
/**
* Generates test data that can be used to drive comparability tests
@@ -50,23 +51,44 @@ public class LegacyFrameDataGenerator {
builder.append(" final byte[] ")
.append(varName)
.append(" = new byte[] {")
- .append(generateFrameEncoding(protonType))
+ .append(generateFrameEncoding(protonType, null))
.append("};");
return builder.toString();
}
- public static String generateFrameEncoding(Object protonType) {
+ public static String generateUnitTestVariable(String varName, Object protonType, ReadableBuffer payload) {
StringBuilder builder = new StringBuilder();
- generateFrameEncodingFromProtonType(protonType, builder);
+
+ builder.append(" // ").append("Frame data for: ")
+ .append(protonType.getClass().getSimpleName()).append("\n");
+ builder.append(" // ").append(" ").append(protonType.toString()).append("\n");
+
+ if (payload != null) {
+ builder.append(" // ").append(" payload of size: ").append(payload.remaining()).append("\n");
+ }
+
+ // Create variable for test
+ builder.append(" final byte[] ")
+ .append(varName)
+ .append(" = new byte[] {")
+ .append(generateFrameEncoding(protonType, payload))
+ .append("};");
+
+ return builder.toString();
+ }
+
+ public static String generateFrameEncoding(Object protonType, ReadableBuffer payload) {
+ StringBuilder builder = new StringBuilder();
+ generateFrameEncodingFromProtonType(protonType, builder, payload);
return builder.toString();
}
- private static void generateFrameEncodingFromProtonType(Object instance, StringBuilder builder) {
+ private static void generateFrameEncodingFromProtonType(Object instance, StringBuilder builder, ReadableBuffer payload) {
FrameWriter writer = new FrameWriter(encoder, DEFAULT_MAX_FRAME_SIZE, AMQP_FRAME);
ByteBuffer buffer = ByteBuffer.allocate(DEFAULT_MAX_FRAME_SIZE);
- writer.writeFrame(0, instance, null, null);
+ writer.writeFrame(0, instance, payload, null);
int frameSize = writer.readBytes(buffer);
for (int i = 0; i < frameSize; i++) {
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 895ec8b9..0299bd7f 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
@@ -18,11 +18,13 @@ package org.apache.qpid.protonj2.engine.impl;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
+import static org.mockito.Mockito.times;
import java.util.List;
@@ -39,6 +41,7 @@ import org.apache.qpid.protonj2.engine.util.FrameRecordingTransportHandler;
import org.apache.qpid.protonj2.engine.util.FrameWriteSinkTransportHandler;
import org.apache.qpid.protonj2.types.transport.AMQPHeader;
import org.apache.qpid.protonj2.types.transport.Open;
+import org.apache.qpid.protonj2.types.transport.Transfer;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
@@ -605,6 +608,228 @@ public class ProtonFrameDecodingHandlerTest {
Mockito.verifyNoMoreInteractions(context);
}
+ @Test
+ public void testDecodeTransferFrameWithAttachedPayload() {
+ // Frame data for: Transfer
+ // Transfer{handle=2, deliveryId=1, deliveryTag=\x00\x01, messageFormat=null, settled=true, more=false, rcvSettleMode=null, state=null, resume=false, aborted=false, batchable=false}
+ // payload of size: 169
+ final byte[] completedTransfer = new byte[] {
+ 0, 0, 0, -63, 2, 0, 0, 0, 0, 83, 20, -64, 11, 5, 82, 2, 82, 1, -96, 2, 0, 1, 64, 65, 0, 83, 115,
+ -48, 0, 0, 0, 28, 0, 0, 0, 3, -104, -107, -75, 19, 123, 103, 50, 77, 43, -73, 93, 29, 105, 64,
+ -84, 45, 110, 64, -95, 4, 116, 101, 115, 116, 0, 83, 116, -63, 23, 2, -95, 9, 116, 105, 109, 101,
+ 115, 116, 97, 109, 112, -95, 9, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 83, 117, -96, 100, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65};
+
+ ArgumentCaptor<IncomingAMQPEnvelope> argument = ArgumentCaptor.forClass(IncomingAMQPEnvelope.class);
+
+ ProtonFrameDecodingHandler handler = createFrameDecoder();
+ ProtonEngineHandlerContext context = Mockito.mock(ProtonEngineHandlerContext.class);
+
+ handler.handleRead(context, AMQPHeader.getAMQPHeader().getBuffer());
+ handler.handleRead(context, ProtonByteBufferAllocator.DEFAULT.wrap(completedTransfer));
+
+ 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 Transfer);
+ assertNotNull(argument.getValue().getPayload());
+ assertTrue(argument.getValue().getPayload().isReadable());
+ assertEquals(169, argument.getValue().getPayload().getReadableBytes());
+
+ Transfer decoded = (Transfer) argument.getValue().getBody();
+
+ assertEquals(2, decoded.getHandle());
+ assertEquals(1, decoded.getDeliveryId());
+ assertArrayEquals(new byte[] { 0, 1 }, decoded.getDeliveryTag().tagBytes());
+ }
+
+ @Test
+ public void testDecodeTransferFrameWithAttachedPayloadSplitAcrossBuffers() {
+ // Frame data for: Transfer
+ // Transfer{handle=2, deliveryId=1, deliveryTag=\x00\x01, messageFormat=null, settled=true, more=false, rcvSettleMode=null, state=null, resume=false, aborted=false, batchable=false}
+ // payload of size: 169
+ final byte[] completedTransfer1 = new byte[] {
+ 0, 0, 0, -63, 2, 0, 0, 0, 0, 83, 20, -64, 11, 5, 82, 2, 82, 1, -96, 2, 0, 1, 64, 65, 0, 83, 115,
+ -48, 0, 0, 0, 28, 0, 0, 0, 3, -104, -107, -75, 19, 123, 103, 50, 77, 43, -73, 93, 29, 105, 64};
+ final byte[] completedTransfer2 = new byte[] {
+ -84, 45, 110, 64, -95, 4, 116, 101, 115, 116, 0, 83, 116, -63, 23, 2, -95, 9, 116, 105, 109, 101,
+ 115, 116, 97, 109, 112, -95, 9, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 83, 117, -96, 100, 65, 65};
+ final byte[] completedTransfer3 = new byte[] {
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65};
+
+ ArgumentCaptor<IncomingAMQPEnvelope> argument = ArgumentCaptor.forClass(IncomingAMQPEnvelope.class);
+
+ ProtonFrameDecodingHandler handler = createFrameDecoder();
+ ProtonEngineHandlerContext context = Mockito.mock(ProtonEngineHandlerContext.class);
+
+ handler.handleRead(context, AMQPHeader.getAMQPHeader().getBuffer());
+
+ final ProtonBuffer buffer1 = ProtonByteBufferAllocator.DEFAULT.wrap(completedTransfer1);
+ final ProtonBuffer buffer2 = ProtonByteBufferAllocator.DEFAULT.wrap(completedTransfer2);
+ final ProtonBuffer buffer3 = ProtonByteBufferAllocator.DEFAULT.wrap(completedTransfer3);
+
+ handler.handleRead(context, buffer1);
+ handler.handleRead(context, buffer2);
+ handler.handleRead(context, buffer3);
+
+ 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 Transfer);
+ assertNotNull(argument.getValue().getPayload());
+ assertTrue(argument.getValue().getPayload().isReadable());
+ assertEquals(169, argument.getValue().getPayload().getReadableBytes());
+
+ Transfer decoded = (Transfer) argument.getValue().getBody();
+
+ assertEquals(2, decoded.getHandle());
+ assertEquals(1, decoded.getDeliveryId());
+ assertArrayEquals(new byte[] { 0, 1 }, decoded.getDeliveryTag().tagBytes());
+ }
+
+ @Test
+ public void testDecodeTransferFrameWithAttachedPayloadSplitAcrossBuffersAsContinuationOfPreviousProcessedRead() {
+ // Frame data for: Transfer
+ // Transfer{handle=2, deliveryId=1, deliveryTag=\x00\x01, messageFormat=null, settled=true, more=false, rcvSettleMode=null, state=null, resume=false, aborted=false, batchable=false}
+ // payload of size: 169
+ final byte[] completedTransfer1 = new byte[] {
+ 0, 0, 0, -63, 2, 0, 0, 0, 0, 83, 20, -64, 11, 5, 82, 2, 82, 1, -96, 2, 0, 1, 64, 65, 0, 83, 115,
+ -48, 0, 0, 0, 28, 0, 0, 0, 3, -104, -107, -75, 19, 123, 103, 50, 77, 43, -73, 93, 29, 105, 64};
+ final byte[] completedTransfer2 = new byte[] {
+ -84, 45, 110, 64, -95, 4, 116, 101, 115, 116, 0, 83, 116, -63, 23, 2, -95, 9, 116, 105, 109, 101,
+ 115, 116, 97, 109, 112, -95, 9, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 83, 117, -96, 100, 65, 65};
+ final byte[] completedTransfer3 = new byte[] {
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65};
+
+ ArgumentCaptor<IncomingAMQPEnvelope> argument = ArgumentCaptor.forClass(IncomingAMQPEnvelope.class);
+
+ ProtonFrameDecodingHandler handler = createFrameDecoder();
+ ProtonEngineHandlerContext context = Mockito.mock(ProtonEngineHandlerContext.class);
+
+ handler.handleRead(context, AMQPHeader.getAMQPHeader().getBuffer());
+
+ final ProtonBuffer buffer1 = ProtonByteBufferAllocator.DEFAULT.allocate(completedTransfer1.length + 100);
+ buffer1.setIndex(100, 100);
+ buffer1.writeBytes(completedTransfer1);
+
+ final ProtonBuffer buffer2 = ProtonByteBufferAllocator.DEFAULT.wrap(completedTransfer2);
+ final ProtonBuffer buffer3 = ProtonByteBufferAllocator.DEFAULT.wrap(completedTransfer3);
+
+ handler.handleRead(context, buffer1);
+ handler.handleRead(context, buffer2);
+ handler.handleRead(context, buffer3);
+
+ 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 Transfer);
+ assertNotNull(argument.getValue().getPayload());
+ assertTrue(argument.getValue().getPayload().isReadable());
+ assertEquals(169, argument.getValue().getPayload().getReadableBytes());
+
+ Transfer decoded = (Transfer) argument.getValue().getBody();
+
+ assertEquals(2, decoded.getHandle());
+ assertEquals(1, decoded.getDeliveryId());
+ assertArrayEquals(new byte[] { 0, 1 }, decoded.getDeliveryTag().tagBytes());
+ }
+
+ @Test
+ public void testDecodeTransferFrameWithAttachedPayloadSplitAcrossBuffersAsContinuationOfPreviousProcessedReadAndAnotherFrameFollowing() {
+ // Frame data for: Transfer
+ // Transfer{handle=2, deliveryId=1, deliveryTag=\x00\x01, messageFormat=null, settled=true, more=false, rcvSettleMode=null, state=null, resume=false, aborted=false, batchable=false}
+ // payload of size: 169
+ final byte[] completedTransfer1 = new byte[] {
+ 0, 0, 0, -63, 2, 0, 0, 0, 0, 83, 20, -64, 11, 5, 82, 2, 82, 1, -96, 2, 0, 1, 64, 65, 0, 83, 115,
+ -48, 0, 0, 0, 28, 0, 0, 0, 3, -104, -107, -75, 19, 123, 103, 50, 77, 43, -73, 93, 29, 105, 64};
+ final byte[] completedTransfer2 = new byte[] {
+ -84, 45, 110, 64, -95, 4, 116, 101, 115, 116, 0, 83, 116, -63, 23, 2, -95, 9, 116, 105, 109, 101,
+ 115, 116, 97, 109, 112, -95, 9, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 83, 117, -96, 100, 65, 65};
+ final byte[] completedTransfer3 = new byte[] {
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65};
+ // Frame data for: Open
+ // Open{ containerId="", hostname='null', maxFrameSize=4294967295, channelMax=65535,
+ // idleTimeOut=null, outgoingLocales=null, incomingLocales=null, offeredCapabilities=null,
+ // desiredCapabilities=null, properties=null}
+ final byte[] emptyOpen = new byte[] {0, 0, 0, 16, 2, 0, 0, 0, 0, 83, 16, -64, 3, 1, -95, 0};
+
+ ArgumentCaptor<IncomingAMQPEnvelope> argument = ArgumentCaptor.forClass(IncomingAMQPEnvelope.class);
+
+ ProtonFrameDecodingHandler handler = createFrameDecoder();
+ ProtonEngineHandlerContext context = Mockito.mock(ProtonEngineHandlerContext.class);
+
+ handler.handleRead(context, AMQPHeader.getAMQPHeader().getBuffer());
+
+ final ProtonBuffer buffer1 = ProtonByteBufferAllocator.DEFAULT.allocate(completedTransfer1.length + 100);
+ buffer1.setIndex(100, 100);
+ buffer1.writeBytes(completedTransfer1);
+
+ final ProtonBuffer buffer2 = ProtonByteBufferAllocator.DEFAULT.wrap(completedTransfer2);
+ final ProtonBuffer buffer3 = ProtonByteBufferAllocator.DEFAULT.allocate(completedTransfer3.length + emptyOpen.length);
+ buffer3.writeBytes(completedTransfer3);
+ buffer3.writeBytes(emptyOpen);
+
+ handler.handleRead(context, buffer1);
+ handler.handleRead(context, buffer2);
+ handler.handleRead(context, buffer3);
+
+ Mockito.verify(context).fireRead(Mockito.any(HeaderEnvelope.class));
+ Mockito.verify(context).interestMask(ProtonEngineHandlerContext.HANDLER_READS);
+ Mockito.verify(context, times(2)).fireRead(argument.capture());
+ Mockito.verifyNoMoreInteractions(context);
+
+ List<IncomingAMQPEnvelope> arguments = argument.getAllValues();
+
+ assertNotNull(arguments.get(0));
+ assertTrue(arguments.get(0).getBody() instanceof Transfer);
+ assertNotNull(arguments.get(0).getPayload());
+ assertTrue(arguments.get(0).getPayload().isReadable());
+ assertEquals(169, arguments.get(0).getPayload().getReadableBytes());
+
+ Transfer transfer = (Transfer) arguments.get(0).getBody();
+
+ assertEquals(2, transfer.getHandle());
+ assertEquals(1, transfer.getDeliveryId());
+ assertArrayEquals(new byte[] { 0, 1 }, transfer.getDeliveryTag().tagBytes());
+
+ assertNotNull(arguments.get(1));
+ assertTrue(arguments.get(1).getBody() instanceof Open);
+
+ Open open = (Open) arguments.get(1).getBody();
+
+ assertTrue(open.hasContainerId()); // Defaults to empty string from proton-j
+ assertFalse(open.hasHostname());
+ assertFalse(open.hasMaxFrameSize());
+ assertFalse(open.hasChannelMax());
+ assertFalse(open.hasIdleTimeout());
+ assertFalse(open.hasOutgoingLocales());
+ assertFalse(open.hasIncomingLocales());
+ assertFalse(open.hasOfferedCapabilities());
+ assertFalse(open.hasDesiredCapabilities());
+ assertFalse(open.hasProperties());
+ }
+
private ProtonFrameDecodingHandler createFrameDecoder() {
ProtonEngineConfiguration configuration = Mockito.mock(ProtonEngineConfiguration.class);
Mockito.when(configuration.getInboundMaxFrameSize()).thenReturn(Long.valueOf(65535));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org