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 testCreationTimeConversion.
@Test
public void testCreationTimeConversion() {
final long timestamp = System.currentTimeMillis() - 10000;
final long arrivalTime = timestamp + 1;
Properties properties = new Properties();
properties.setCreationTime(new Date(timestamp));
Message_1_0 message = createTestMessage(new Header(), new DeliveryAnnotations(Collections.emptyMap()), new MessageAnnotations(Collections.emptyMap()), properties, new ApplicationProperties(Collections.emptyMap()), arrivalTime);
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
assertEquals("Unexpected timestamp", timestamp, convertedProperties.getTimestamp());
}
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 testToConversionWhenExchangeIsSpecifiedAndSubjectIsSet.
@Test
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);
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 testMessageIdUUIDConversion.
@Test
public void testMessageIdUUIDConversion() {
final UUID messageId = UUID.randomUUID();
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();
assertEquals("Unexpected messageId", messageId.toString(), convertedProperties.getMessageId().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 testNonDurableConversion.
@Test
public void testNonDurableConversion() {
final Header header = new Header();
header.setDurable(false);
Message_1_0 message = createTestMessage(header);
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
assertEquals("Unexpected deliveryMode", (long) BasicContentHeaderProperties.NON_PERSISTENT, (long) convertedProperties.getDeliveryMode());
}
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 testAbsoluteExpiryTimeConversion.
@Test
public void testAbsoluteExpiryTimeConversion() {
long ttl = 10000;
long arrivalTime = System.currentTimeMillis();
long expiryTime = arrivalTime + ttl;
Properties properties = new Properties();
properties.setAbsoluteExpiryTime(new Date(expiryTime));
Message_1_0 message = createTestMessage(properties);
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
assertEquals("Unexpected expiration", expiryTime, convertedProperties.getExpiration());
}
Aggregations