use of org.apache.qpid.server.protocol.v1_0.type.messaging.HeaderSection in project qpid-broker-j by apache.
the class DecodeErrorTest method illegalMessageFormatPayload.
@Test
@SpecificationTest(section = "3.2", description = "Altogether a message consists of the following sections: Zero or one header," + " Zero or one delivery-annotations, [...]")
public void illegalMessageFormatPayload() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
List<QpidByteBuffer> payloads = new ArrayList<>();
final HeaderSection headerSection = new Header().createEncodingRetainingSection();
payloads.add(headerSection.getEncodedForm());
headerSection.dispose();
final StringWriter stringWriter = new StringWriter("string in between annotation sections");
QpidByteBuffer encodedString = QpidByteBuffer.allocate(stringWriter.getEncodedSize());
stringWriter.writeToBuffer(encodedString);
encodedString.flip();
payloads.add(encodedString);
final DeliveryAnnotationsSection deliveryAnnotationsSection = new DeliveryAnnotations(Collections.emptyMap()).createEncodingRetainingSection();
payloads.add(deliveryAnnotationsSection.getEncodedForm());
deliveryAnnotationsSection.dispose();
final Detach detachResponse;
try (QpidByteBuffer combinedPayload = QpidByteBuffer.concatenate(payloads)) {
detachResponse = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferMessageFormat(UnsignedInteger.ZERO).transferPayload(combinedPayload).transfer().consumeResponse().getLatestResponse(Detach.class);
}
payloads.forEach(QpidByteBuffer::dispose);
assertThat(detachResponse.getError(), is(notNullValue()));
assertThat(detachResponse.getError().getCondition(), is(equalTo(DECODE_ERROR)));
}
}
Aggregations