Search in sources :

Example 1 with MessagePublishInfo

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

the class PropertyConverter_1_0_to_0_8Test method testToConversionWhenExchangeIsSpecifiedAndSubjectIsSet.

public void testToConversionWhenExchangeIsSpecifiedAndSubjectIsSet() {
    final String testExchange = "testExchange";
    final String testRoutingKey = "testRoutingKey";
    Properties properties = new Properties();
    properties.setTo(testExchange);
    properties.setSubject(testRoutingKey);
    Message_1_0 message = createTestMessage(properties);
    final Exchange exchange = mock(Exchange.class);
    when(exchange.getName()).thenReturn(testExchange);
    when(_namedAddressSpace.getAttainedMessageDestination(testExchange)).thenReturn(exchange);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
    assertEquals("Unexpected exchange", testExchange, messagePublishInfo.getExchange().toString());
    assertEquals("Unexpected routing key", testRoutingKey, messagePublishInfo.getRoutingKey().toString());
}
Also used : Exchange(org.apache.qpid.server.model.Exchange) MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 2 with MessagePublishInfo

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

the class PropertyConverter_1_0_to_0_8Test method testToConversionWhenExchangeAndRoutingKeyIsSpecified.

public void testToConversionWhenExchangeAndRoutingKeyIsSpecified() {
    final String testExchange = "testExchange";
    final String testRoutingKey = "testRoutingKey";
    String to = testExchange + "/" + testRoutingKey;
    Properties properties = new Properties();
    properties.setTo(to);
    Message_1_0 message = createTestMessage(properties);
    Exchange<?> exchange = mock(Exchange.class);
    when(exchange.getName()).thenReturn(testExchange);
    when(_namedAddressSpace.getAttainedMessageDestination(testExchange)).thenReturn(exchange);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
    assertEquals("Unexpected exchange", testExchange, messagePublishInfo.getExchange().toString());
    assertEquals("Unexpected routing key", testRoutingKey, messagePublishInfo.getRoutingKey().toString());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 3 with MessagePublishInfo

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

the class PropertyConverter_1_0_to_0_8Test method testToConversionWhenQueueIsSpecified.

public void testToConversionWhenQueueIsSpecified() {
    final String testQueue = "testQueue";
    Properties properties = new Properties();
    properties.setTo(testQueue);
    Message_1_0 message = createTestMessage(properties);
    final Queue queue = mock(Queue.class);
    when(queue.getName()).thenReturn(testQueue);
    when(_namedAddressSpace.getAttainedMessageDestination(testQueue)).thenReturn(queue);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
    assertEquals("Unexpected exchange", "", messagePublishInfo.getExchange().toString());
    assertEquals("Unexpected routing key", testQueue, messagePublishInfo.getRoutingKey().toString());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) Queue(org.apache.qpid.server.model.Queue) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 4 with MessagePublishInfo

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

the class PropertyConverter_1_0_to_0_8Test method testSubjectConversion.

public void testSubjectConversion() {
    final String subject = "testSubject";
    Properties properties = new Properties();
    properties.setSubject(subject);
    Message_1_0 message = createTestMessage(properties);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
    final Map<String, Object> headers = FieldTable.convertToMap(convertedProperties.getHeaders());
    assertEquals("Unexpected qpid.subject is missing from headers", subject, headers.get("qpid.subject"));
    assertEquals("Unexpected type", subject, convertedProperties.getType().toString());
    final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
    assertEquals("Unexpected routing-key", subject, messagePublishInfo.getRoutingKey().toString());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 5 with MessagePublishInfo

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

the class PropertyConverter_1_0_to_0_8Test method testToConversionWhenDestinationIsSpecifiedButDoesNotExists.

public void testToConversionWhenDestinationIsSpecifiedButDoesNotExists() {
    final String testDestination = "testDestination";
    Properties properties = new Properties();
    properties.setTo(testDestination);
    Message_1_0 message = createTestMessage(properties);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
    assertEquals("Unexpected exchange", "", messagePublishInfo.getExchange().toString());
    assertEquals("Unexpected routing key", testDestination, messagePublishInfo.getRoutingKey().toString());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Aggregations

MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)40 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)16 Matchers.anyString (org.mockito.Matchers.anyString)15 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)14 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)13 ContentHeaderBody (org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)11 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)9 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)9 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)8 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)7 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)7 Exchange (org.apache.qpid.server.model.Exchange)6 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)6 Queue (org.apache.qpid.server.model.Queue)4 MessageMetaData (org.apache.qpid.server.protocol.v0_8.MessageMetaData)4 LinkedHashMap (java.util.LinkedHashMap)3 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)3 Date (java.util.Date)2 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)2 MessageDestination (org.apache.qpid.server.message.MessageDestination)2