Search in sources :

Example 36 with MessagePublishInfo

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

the class PropertyConverter_Internal_to_v0_8Test method testToConversionWhenExchangeIsSpecified.

public void testToConversionWhenExchangeIsSpecified() {
    final String testExchange = "testExchange";
    InternalMessage message = createTestMessage(testExchange);
    final Exchange exchange = mock(Exchange.class);
    when(exchange.getName()).thenReturn(testExchange);
    when(_addressSpace.getAttainedMessageDestination(testExchange)).thenReturn(exchange);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _addressSpace);
    final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
    assertEquals("Unexpected exchange", testExchange, messagePublishInfo.getExchange().toString());
    assertEquals("Unexpected routing key", "", messagePublishInfo.getRoutingKey().toString());
}
Also used : Exchange(org.apache.qpid.server.model.Exchange) MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Matchers.anyString(org.mockito.Matchers.anyString)

Example 37 with MessagePublishInfo

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

the class PropertyConverter_Internal_to_v0_8Test method testToConversionWhenQueueIsSpecified.

public void testToConversionWhenQueueIsSpecified() {
    final String testQueue = "testQueue";
    InternalMessage message = createTestMessage(testQueue);
    final Queue queue = mock(Queue.class);
    when(queue.getName()).thenReturn(testQueue);
    when(_addressSpace.getAttainedMessageDestination(testQueue)).thenReturn(queue);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _addressSpace);
    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) InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Matchers.anyString(org.mockito.Matchers.anyString) Queue(org.apache.qpid.server.model.Queue)

Example 38 with MessagePublishInfo

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

the class PropertyConverter_Internal_to_v0_8Test method testToConversionWhenDestinationIsSpecifiedButDoesNotExists.

public void testToConversionWhenDestinationIsSpecifiedButDoesNotExists() {
    final String testDestination = "testDestination";
    InternalMessage message = createTestMessage(testDestination);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _addressSpace);
    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) InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Matchers.anyString(org.mockito.Matchers.anyString)

Example 39 with MessagePublishInfo

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

the class PropertyConverter_Internal_to_v0_8Test method testToConversionWhenGlobalAddressIsUnknown.

public void testToConversionWhenGlobalAddressIsUnknown() {
    final String globalPrefix = "/testPrefix";
    final String queueName = "testQueue";
    final String globalAddress = globalPrefix + "/" + queueName;
    InternalMessage message = createTestMessage(globalAddress);
    Queue<?> queue = mock(Queue.class);
    when(queue.getName()).thenReturn(queueName);
    when(_addressSpace.getAttainedMessageDestination(queueName)).thenReturn(queue);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _addressSpace);
    final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
    assertEquals("Unexpected exchange", "", messagePublishInfo.getExchange().toString());
    assertEquals("Unexpected routing key", globalAddress, messagePublishInfo.getRoutingKey().toString());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Matchers.anyString(org.mockito.Matchers.anyString)

Example 40 with MessagePublishInfo

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

the class PropertyConverter_Internal_to_v0_8Test method testConversionWhenToIsUnsetButInitialRoutingKeyIsSet.

public void testConversionWhenToIsUnsetButInitialRoutingKeyIsSet() {
    final String testExchange = "testExchange";
    final String testRoutingKey = "testRoutingKey";
    InternalMessage message = createTestMessage("");
    final String testInitialRoutingAddress = testExchange + "/" + testRoutingKey;
    message.setInitialRoutingAddress(testInitialRoutingAddress);
    final Exchange exchange = mock(Exchange.class);
    when(exchange.getName()).thenReturn(testExchange);
    when(_addressSpace.getAttainedMessageDestination(testExchange)).thenReturn(exchange);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _addressSpace);
    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) InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Matchers.anyString(org.mockito.Matchers.anyString)

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