Search in sources :

Example 6 with HeaderSection

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)));
    }
}
Also used : DeliveryAnnotationsSection(org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotationsSection) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) ArrayList(java.util.ArrayList) DeliveryAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations) HeaderSection(org.apache.qpid.server.protocol.v1_0.type.messaging.HeaderSection) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) StringWriter(org.apache.qpid.server.protocol.v1_0.codec.StringWriter) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

HeaderSection (org.apache.qpid.server.protocol.v1_0.type.messaging.HeaderSection)6 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)4 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)4 DeliveryAnnotationsSection (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotationsSection)3 EncodingRetainingSection (org.apache.qpid.server.protocol.v1_0.type.messaging.EncodingRetainingSection)3 ArrayList (java.util.ArrayList)2 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)2 AmqpSequenceSection (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpSequenceSection)2 AmqpValueSection (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValueSection)2 ApplicationPropertiesSection (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationPropertiesSection)2 DataSection (org.apache.qpid.server.protocol.v1_0.type.messaging.DataSection)2 FooterSection (org.apache.qpid.server.protocol.v1_0.type.messaging.FooterSection)2 MessageAnnotationsSection (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotationsSection)2 PropertiesSection (org.apache.qpid.server.protocol.v1_0.type.messaging.PropertiesSection)2 Transfer (org.apache.qpid.server.protocol.v1_0.type.transport.Transfer)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 MessageInstance (org.apache.qpid.server.message.MessageInstance)1 MessageInstanceConsumer (org.apache.qpid.server.message.MessageInstanceConsumer)1 ServerMessage (org.apache.qpid.server.message.ServerMessage)1 StringWriter (org.apache.qpid.server.protocol.v1_0.codec.StringWriter)1