Search in sources :

Example 51 with Header

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

the class MessageConverter_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 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 is leaking 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) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer)

Example 52 with Header

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

the class Message_1_0_MutatorTest method createTestMessage.

private Message_1_0 createTestMessage() {
    final QpidByteBuffer content = new AmqpValue(TEST_CONTENT).createEncodingRetainingSection().getEncodedForm();
    final long contentSize = content.remaining();
    final Header header = new Header();
    header.setPriority(UnsignedByte.valueOf(TEST_PRIORITY));
    final HeaderSection headerSection = header.createEncodingRetainingSection();
    final Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf(TEST_CONTENT_TYPE));
    final PropertiesSection propertiesSection = properties.createEncodingRetainingSection();
    final ApplicationPropertiesSection applicationPropertiesSection = new ApplicationProperties(Collections.singletonMap(TEST_HEADER_NAME, TEST_HEADER_VALUE)).createEncodingRetainingSection();
    final MessageMetaData_1_0 mmd = new MessageMetaData_1_0(headerSection, null, null, propertiesSection, applicationPropertiesSection, null, System.currentTimeMillis(), contentSize);
    final MessageHandle<MessageMetaData_1_0> handle = _messageStore.addMessage(mmd);
    handle.addContent(content);
    return new Message_1_0(handle.allContentAdded());
}
Also used : PropertiesSection(org.apache.qpid.server.protocol.v1_0.type.messaging.PropertiesSection) ApplicationPropertiesSection(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationPropertiesSection) Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) ApplicationPropertiesSection(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationPropertiesSection) HeaderSection(org.apache.qpid.server.protocol.v1_0.type.messaging.HeaderSection) AmqpValue(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)

Example 53 with Header

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

the class PropertyConverter_v1_0_to_InternalTest method testTTLConversion.

@Test
public void testTTLConversion() {
    long ttl = 10000;
    long arrivalTime = System.currentTimeMillis();
    long expiryTime = arrivalTime + ttl;
    final Header header = new Header();
    header.setTtl(UnsignedInteger.valueOf(ttl));
    Message_1_0 originalMessage = createTestMessage(header, arrivalTime);
    InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertEquals("Unexpected expiration", expiryTime, convertedMessage.getMessageHeader().getExpiration());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) Test(org.junit.Test)

Example 54 with Header

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

the class PropertyConverter_v1_0_to_InternalTest method testDurableTrueConversion.

@Test
public void testDurableTrueConversion() {
    final Header header = new Header();
    header.setDurable(true);
    final Message_1_0 originalMessage = createTestMessage(header);
    InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertTrue("Unexpected persistence of message", convertedMessage.isPersistent());
    assertTrue("Unexpected persistence of meta data", convertedMessage.getStoredMessage().getMetaData().isPersistent());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) Test(org.junit.Test)

Example 55 with Header

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

the class PropertyConverter_v1_0_to_InternalTest method testPriorityConversion.

@Test
public void testPriorityConversion() {
    final byte priority = 7;
    final Header header = new Header();
    header.setPriority(UnsignedByte.valueOf(priority));
    final Message_1_0 originalMessage = createTestMessage(header);
    InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertEquals("Unexpected priority", (long) priority, (long) convertedMessage.getMessageHeader().getPriority());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) Test(org.junit.Test)

Aggregations

Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)45 Test (org.junit.Test)44 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)32 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)19 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)18 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)17 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)16 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)14 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)13 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)13 DeliveryAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations)12 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)11 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)11 Date (java.util.Date)9 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)8 MessageMetaData_1_0 (org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0)8 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)8 Footer (org.apache.qpid.server.protocol.v1_0.type.messaging.Footer)7 ArrayList (java.util.ArrayList)6 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)6