use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testApplicationPropertiesConversion.
@Test
public void testApplicationPropertiesConversion() {
Map<String, Object> properties = new HashMap<>();
properties.put("testProperty1", "testProperty1Value");
properties.put("intProperty", 1);
ApplicationProperties applicationProperties = new ApplicationProperties(properties);
Message_1_0 message = createTestMessage(applicationProperties);
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
final Map<String, Object> headers = convertedProperties.getHeadersAsMap();
assertEquals("Unexpected headers", properties, new HashMap<>(headers));
}
use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testToConversionWhenExchangeAndRoutingKeyIsSpecified.
@Test
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);
doReturn(exchange).when(_namedAddressSpace).getAttainedMessageDestination(eq(testExchange), anyBoolean());
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());
}
use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testToConversionWhenQueueIsSpecified.
@Test
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);
doReturn(queue).when(_namedAddressSpace).getAttainedMessageDestination(eq(testQueue), anyBoolean());
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());
}
use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testMessageIdLongStringConversion.
@Test
public void testMessageIdLongStringConversion() {
final String messageId = generateLongString();
Properties properties = new Properties();
properties.setMessageId(messageId);
Message_1_0 message = createTestMessage(properties);
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
assertNull("Unexpected messageId", convertedProperties.getMessageId());
}
use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testToConversionWhenDestinationIsSpecifiedButDoesNotExists.
@Test
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());
}
Aggregations