Search in sources :

Example 16 with AMQMessage

use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_0_8Test method testReplyToConversionWhenRoutingKeySpecified.

@Test
public void testReplyToConversionWhenRoutingKeySpecified() {
    final String routingKey = "test_routing_key";
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setReplyTo(new ReplyTo(null, routingKey));
    MessageTransferMessage message = createTestMessage(messageProperties);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    BasicContentHeaderProperties properties = convertedMessage.getContentHeaderBody().getProperties();
    String expectedReplyTo = String.format("direct:////?routingkey='%s'", 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) Test(org.junit.Test)

Example 17 with AMQMessage

use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_0_8Test method testCorrelationIdConversion.

@Test
public void testCorrelationIdConversion() {
    final String correlationId = "testCorrelationId";
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setCorrelationId(correlationId.getBytes());
    MessageTransferMessage message = createTestMessage(messageProperties);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    BasicContentHeaderProperties properties = convertedMessage.getContentHeaderBody().getProperties();
    assertEquals("Unexpected correlationId", correlationId, properties.getCorrelationId().toString());
}
Also used : 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) Test(org.junit.Test)

Example 18 with AMQMessage

use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_0_8Test method testReplyToConversionWhenExchangeAndRoutingKeyAreNull.

@Test
public void testReplyToConversionWhenExchangeAndRoutingKeyAreNull() {
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setReplyTo(new ReplyTo(null, null));
    MessageTransferMessage message = createTestMessage(messageProperties);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    BasicContentHeaderProperties properties = convertedMessage.getContentHeaderBody().getProperties();
    assertNull("Unexpected reply-to", properties.getReplyTo());
}
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) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage) Test(org.junit.Test)

Example 19 with AMQMessage

use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_0_8Test method testApplicationHeadersConversion.

@Test
public void testApplicationHeadersConversion() {
    Map<String, Object> headers = new HashMap<>();
    headers.put("testProperty1", "testProperty1Value");
    headers.put("intProperty", 1);
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setApplicationHeaders(headers);
    MessageTransferMessage message = createTestMessage(messageProperties);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    BasicContentHeaderProperties properties = convertedMessage.getContentHeaderBody().getProperties();
    Map<String, Object> applicationProperties = properties.getHeadersAsMap();
    assertEquals("Unexpected headers", headers, new HashMap<>(applicationProperties));
}
Also used : HashMap(java.util.HashMap) 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) Test(org.junit.Test)

Example 20 with AMQMessage

use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_0_8Test method testMessageIdConversion.

@Test
public void testMessageIdConversion() {
    UUID messageId = UUID.randomUUID();
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setMessageId(messageId);
    MessageTransferMessage message = createTestMessage(messageProperties);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    BasicContentHeaderProperties properties = convertedMessage.getContentHeaderBody().getProperties();
    assertEquals("Unexpected messageId", "ID:" + messageId, properties.getMessageId().toString());
}
Also used : MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) UUID(java.util.UUID) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)198 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)176 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)143 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)114 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)78 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)76 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)58 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)57 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)46 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)38 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)33 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)32 MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)32 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)26 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)25 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)24 AmqpValue (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)17 HashMap (java.util.HashMap)15 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)14 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)12