Search in sources :

Example 1 with Footer

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Footer in project qpid-broker-j by apache.

the class PropertyConverter_v1_0_to_InternalTest method createTestMessage.

private Message_1_0 createTestMessage(final Header header, final DeliveryAnnotations deliveryAnnotations, final MessageAnnotations messageAnnotations, final Properties properties, final ApplicationProperties applicationProperties, final long arrivalTime, final byte[] content) {
    final StoredMessage<MessageMetaData_1_0> storedMessage = mock(StoredMessage.class);
    MessageMetaData_1_0 metaData = new MessageMetaData_1_0(header.createEncodingRetainingSection(), deliveryAnnotations.createEncodingRetainingSection(), messageAnnotations.createEncodingRetainingSection(), properties.createEncodingRetainingSection(), applicationProperties.createEncodingRetainingSection(), new Footer(Collections.emptyMap()).createEncodingRetainingSection(), arrivalTime, content == null ? 0 : content.length);
    when(storedMessage.getMetaData()).thenReturn(metaData);
    if (content != null) {
        Binary binary = new Binary(content);
        DataSection dataSection = new Data(binary).createEncodingRetainingSection();
        QpidByteBuffer qbb = dataSection.getEncodedForm();
        int length = qbb.remaining();
        when(storedMessage.getContentSize()).thenReturn(length);
        when(storedMessage.getContent(0, length)).thenReturn(qbb);
    } else {
        when(storedMessage.getContentSize()).thenReturn(0);
        when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
    }
    return new Message_1_0(storedMessage);
}
Also used : DataSection(org.apache.qpid.server.protocol.v1_0.type.messaging.DataSection) Footer(org.apache.qpid.server.protocol.v1_0.type.messaging.Footer) Data(org.apache.qpid.server.protocol.v1_0.type.messaging.Data) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary)

Example 2 with Footer

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Footer in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10Test method createTestMessage.

private Message_1_0 createTestMessage(final Header header, final DeliveryAnnotations deliveryAnnotations, final MessageAnnotations messageAnnotations, final Properties properties, final ApplicationProperties applicationProperties, final long arrivalTime, final EncodingRetainingSection section) {
    final StoredMessage<MessageMetaData_1_0> storedMessage = mock(StoredMessage.class);
    MessageMetaData_1_0 metaData = new MessageMetaData_1_0(header.createEncodingRetainingSection(), deliveryAnnotations.createEncodingRetainingSection(), messageAnnotations.createEncodingRetainingSection(), properties.createEncodingRetainingSection(), applicationProperties.createEncodingRetainingSection(), new Footer(Collections.emptyMap()).createEncodingRetainingSection(), arrivalTime, 0);
    when(storedMessage.getMetaData()).thenReturn(metaData);
    if (section != null) {
        // TODO this seems to leak QBBs
        final QpidByteBuffer combined = section.getEncodedForm();
        when(storedMessage.getContentSize()).thenReturn((int) section.getEncodedSize());
        final ArgumentCaptor<Integer> offsetCaptor = ArgumentCaptor.forClass(Integer.class);
        final ArgumentCaptor<Integer> sizeCaptor = ArgumentCaptor.forClass(Integer.class);
        when(storedMessage.getContent(offsetCaptor.capture(), sizeCaptor.capture())).then(invocation -> combined.view(offsetCaptor.getValue(), sizeCaptor.getValue()));
    } else {
        when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
    }
    return new Message_1_0(storedMessage);
}
Also used : Footer(org.apache.qpid.server.protocol.v1_0.type.messaging.Footer) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) MessageMetaData_1_0(org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer)

Example 3 with Footer

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Footer in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_8Test method createTestMessage.

private Message_1_0 createTestMessage(final Header header, final DeliveryAnnotations deliveryAnnotations, final MessageAnnotations messageAnnotations, final Properties properties, final ApplicationProperties applicationProperties, final long arrivalTime, final EncodingRetainingSection section) {
    final StoredMessage<MessageMetaData_1_0> storedMessage = mock(StoredMessage.class);
    MessageMetaData_1_0 metaData = new MessageMetaData_1_0(header.createEncodingRetainingSection(), deliveryAnnotations.createEncodingRetainingSection(), messageAnnotations.createEncodingRetainingSection(), properties.createEncodingRetainingSection(), applicationProperties.createEncodingRetainingSection(), new Footer(Collections.emptyMap()).createEncodingRetainingSection(), arrivalTime, 0);
    when(storedMessage.getMetaData()).thenReturn(metaData);
    if (section != null) {
        // TODO this seems to leak QBBs
        final QpidByteBuffer combined = section.getEncodedForm();
        when(storedMessage.getContentSize()).thenReturn((int) section.getEncodedSize());
        final ArgumentCaptor<Integer> offsetCaptor = ArgumentCaptor.forClass(Integer.class);
        final ArgumentCaptor<Integer> sizeCaptor = ArgumentCaptor.forClass(Integer.class);
        when(storedMessage.getContent(offsetCaptor.capture(), sizeCaptor.capture())).then(invocation -> combined.view(offsetCaptor.getValue(), sizeCaptor.getValue()));
    } else {
        when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
    }
    return new Message_1_0(storedMessage);
}
Also used : Footer(org.apache.qpid.server.protocol.v1_0.type.messaging.Footer) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) MessageMetaData_1_0(org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer)

Example 4 with Footer

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Footer in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_10Test method createTestMessage.

private Message_1_0 createTestMessage(final Header header, final DeliveryAnnotations deliveryAnnotations, final MessageAnnotations messageAnnotations, final Properties properties, final ApplicationProperties applicationProperties, final long arrivalTime, final byte[] content) {
    final StoredMessage<MessageMetaData_1_0> storedMessage = mock(StoredMessage.class);
    MessageMetaData_1_0 metaData = new MessageMetaData_1_0(header.createEncodingRetainingSection(), deliveryAnnotations.createEncodingRetainingSection(), messageAnnotations.createEncodingRetainingSection(), properties.createEncodingRetainingSection(), applicationProperties.createEncodingRetainingSection(), new Footer(Collections.emptyMap()).createEncodingRetainingSection(), arrivalTime, content == null ? 0 : content.length);
    when(storedMessage.getMetaData()).thenReturn(metaData);
    if (content != null) {
        Binary binary = new Binary(content);
        DataSection dataSection = new Data(binary).createEncodingRetainingSection();
        QpidByteBuffer qbb = dataSection.getEncodedForm();
        int length = qbb.remaining();
        when(storedMessage.getContentSize()).thenReturn(length);
        when(storedMessage.getContent(0, length)).thenReturn(qbb);
    } else {
        when(storedMessage.getContentSize()).thenReturn(0);
        when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
    }
    return new Message_1_0(storedMessage);
}
Also used : DataSection(org.apache.qpid.server.protocol.v1_0.type.messaging.DataSection) Footer(org.apache.qpid.server.protocol.v1_0.type.messaging.Footer) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) MessageMetaData_1_0(org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0) Data(org.apache.qpid.server.protocol.v1_0.type.messaging.Data) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary)

Example 5 with Footer

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Footer in project qpid-broker-j by apache.

the class ConsumerTarget_1_0Test method createTestMessage.

private Message_1_0 createTestMessage(final Header header, long arrivalTime) {
    DeliveryAnnotationsSection deliveryAnnotations = new DeliveryAnnotations(Collections.emptyMap()).createEncodingRetainingSection();
    MessageAnnotationsSection messageAnnotations = new MessageAnnotations(Collections.emptyMap()).createEncodingRetainingSection();
    ApplicationPropertiesSection applicationProperties = new ApplicationProperties(Collections.emptyMap()).createEncodingRetainingSection();
    FooterSection footer = new Footer(Collections.emptyMap()).createEncodingRetainingSection();
    MessageMetaData_1_0 metaData = new MessageMetaData_1_0(header.createEncodingRetainingSection(), deliveryAnnotations, messageAnnotations, new Properties().createEncodingRetainingSection(), applicationProperties, footer, arrivalTime, 0);
    final StoredMessage<MessageMetaData_1_0> storedMessage = mock(StoredMessage.class);
    when(storedMessage.getContent(eq(0), anyInt())).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
    when(storedMessage.getMetaData()).thenReturn(metaData);
    return new Message_1_0(storedMessage);
}
Also used : DeliveryAnnotationsSection(org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotationsSection) FooterSection(org.apache.qpid.server.protocol.v1_0.type.messaging.FooterSection) MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) DeliveryAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations) Footer(org.apache.qpid.server.protocol.v1_0.type.messaging.Footer) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) MessageAnnotationsSection(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotationsSection) ApplicationPropertiesSection(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationPropertiesSection) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)

Aggregations

Footer (org.apache.qpid.server.protocol.v1_0.type.messaging.Footer)7 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)5 MessageMetaData_1_0 (org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0)4 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)4 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)2 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)2 DataSection (org.apache.qpid.server.protocol.v1_0.type.messaging.DataSection)2 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)1 ApplicationPropertiesSection (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationPropertiesSection)1 DeliveryAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations)1 DeliveryAnnotationsSection (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotationsSection)1 FooterSection (org.apache.qpid.server.protocol.v1_0.type.messaging.FooterSection)1 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)1 MessageAnnotationsSection (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotationsSection)1 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)1