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 testToConversionWhenGlobalAddressIsKnown.
public void testToConversionWhenGlobalAddressIsKnown() {
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);
when(_addressSpace.getLocalAddress(globalAddress)).thenReturn(queueName);
final AMQMessage convertedMessage = _messageConverter.convert(message, _addressSpace);
final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
assertEquals("Unexpected exchange", "", messagePublishInfo.getExchange().toString());
assertEquals("Unexpected routing key", queueName, messagePublishInfo.getRoutingKey().toString());
}
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 testToConversionWhenExchangeAndRoutingKeyIsSpecified.
public void testToConversionWhenExchangeAndRoutingKeyIsSpecified() {
final String testExchange = "testExchange";
final String testRoutingKey = "testRoutingKey";
String to = testExchange + "/" + testRoutingKey;
InternalMessage message = createTestMessage(to);
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());
}
use of org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo in project qpid-broker-j by apache.
the class PropertyConverter_0_8_to_1_0Test method createTestMessage.
private AMQMessage createTestMessage(final BasicContentHeaderProperties basicContentHeaderProperties, final byte[] content, final long arrivalTime) {
final ContentHeaderBody contentHeaderBody = mock(ContentHeaderBody.class);
when(contentHeaderBody.getProperties()).thenReturn(basicContentHeaderProperties);
final StoredMessage<MessageMetaData> storedMessage = mock(StoredMessage.class);
when(storedMessage.getMetaData()).thenReturn(new MessageMetaData(new MessagePublishInfo(), contentHeaderBody, arrivalTime));
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 AMQMessage(storedMessage);
}
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 testToConversionWhenGlobalAddressUnrecognized.
public void testToConversionWhenGlobalAddressUnrecognized() {
final String globalAddress = "/testQueue";
Properties properties = new Properties();
properties.setTo(globalAddress);
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", globalAddress, messagePublishInfo.getRoutingKey().toString());
}
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 testToConversionWhenExchangeIsSpecified.
public void testToConversionWhenExchangeIsSpecified() {
final String testExchange = "testExchange";
Properties properties = new Properties();
properties.setTo(testExchange);
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", "", messagePublishInfo.getRoutingKey().toString());
}
Aggregations