Search in sources :

Example 31 with MessageProperties

use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_0_8Test method createTestMessage.

private MessageTransferMessage createTestMessage(final DeliveryProperties deliveryProperties, final MessageProperties messageProperties, final byte[] content, final long arrivalTime) {
    int bodySize = content == null ? 0 : content.length;
    final org.apache.qpid.server.protocol.v0_10.transport.Header header = new org.apache.qpid.server.protocol.v0_10.transport.Header(deliveryProperties, messageProperties);
    final MessageMetaData_0_10 metaData = new MessageMetaData_0_10(header, bodySize, arrivalTime);
    final StoredMessage<MessageMetaData_0_10> storedMessage = mock(StoredMessage.class);
    when(storedMessage.getMetaData()).thenReturn(metaData);
    if (content != null) {
        when(storedMessage.getContentSize()).thenReturn(content.length);
        when(storedMessage.getContent(0, content.length)).thenReturn(QpidByteBuffer.wrap(content));
    } else {
        when(storedMessage.getContentSize()).thenReturn(0);
        when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
    }
    return new MessageTransferMessage(storedMessage, null);
}
Also used : MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageMetaData_0_10(org.apache.qpid.server.protocol.v0_10.MessageMetaData_0_10)

Example 32 with MessageProperties

use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_0_8Test method testReplyToConversionWhenExchangeAndRoutingKeySpecified.

public void testReplyToConversionWhenExchangeAndRoutingKeySpecified() {
    final String exchangeName = "amq.direct";
    final String routingKey = "test_routing_key";
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setReplyTo(new ReplyTo(exchangeName, routingKey));
    MessageTransferMessage message = createTestMessage(messageProperties);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    BasicContentHeaderProperties properties = convertedMessage.getContentHeaderBody().getProperties();
    String expectedReplyTo = String.format("direct://%s//?routingkey='%s'", exchangeName, routingKey);
    assertEquals("Unexpected reply-to", expectedReplyTo, properties.getReplyTo().toString());
}
Also used : ReplyTo(org.apache.qpid.server.protocol.v0_10.transport.ReplyTo) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 33 with MessageProperties

use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_0_8Test method testReplyToConversionWhenResultExceeds255.

public void testReplyToConversionWhenResultExceeds255() {
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setReplyTo(new ReplyTo(generateLongString(255), generateLongString(255)));
    MessageTransferMessage message = createTestMessage(messageProperties);
    try {
        _messageConverter.convert(message, _namedAddressSpace);
        fail("expected exception not thrown");
    } catch (MessageConversionException e) {
    // pass
    }
}
Also used : ReplyTo(org.apache.qpid.server.protocol.v0_10.transport.ReplyTo) MessageConversionException(org.apache.qpid.server.protocol.converter.MessageConversionException) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)

Example 34 with MessageProperties

use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.

the class PropertyConverter_0_8_to_0_10Test method testHeaderConversion.

public void testHeaderConversion() {
    Map<String, Object> headers = new HashMap<>();
    headers.put("testProperty1", "testProperty1Value");
    headers.put("intProperty", 1);
    BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
    basicContentHeaderProperties.setHeaders(FieldTable.convertToFieldTable(headers));
    AMQMessage message = createTestMessage(basicContentHeaderProperties);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
    Map<String, Object> applicationProperties = messageProperties.getApplicationHeaders();
    assertEquals("Unexpected applicationProperties", headers, new HashMap<>(applicationProperties));
}
Also used : HashMap(java.util.HashMap) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 35 with MessageProperties

use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.

the class PropertyConverter_0_8_to_0_10Test method testContentTypeConversion.

public void testContentTypeConversion() {
    String contentType = "test-content-type";
    BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
    basicContentHeaderProperties.setContentType(contentType);
    AMQMessage message = createTestMessage(basicContentHeaderProperties);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
    assertEquals("Unexpected content type", contentType, messageProperties.getContentType());
}
Also used : MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Aggregations

MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)121 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)90 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)63 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)45 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)44 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)39 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)37 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)31 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)24 ReplyTo (org.apache.qpid.server.protocol.v0_10.transport.ReplyTo)20 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)18 Matchers.anyString (org.mockito.Matchers.anyString)15 HashMap (java.util.HashMap)10 UUID (java.util.UUID)10 Header (org.apache.qpid.server.protocol.v0_10.transport.Header)10 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)9 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)8 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)7 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)6 DeliveryAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations)5