use of org.apache.qpid.server.protocol.v0_10.MessageTransferMessage in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_1_0Test method testJmsTypeConversion.
public void testJmsTypeConversion() {
final String type = "test-type";
final Map<String, Object> headers = Collections.singletonMap("x-jms-type", type);
final MessageProperties messageProperties = new MessageProperties();
messageProperties.setApplicationHeaders(headers);
MessageTransferMessage message = createTestMessage(messageProperties);
final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
Properties properties = convertedMessage.getPropertiesSection().getValue();
assertEquals("Unexpected subject", type, properties.getSubject());
Map<String, Object> applicationProperties = convertedMessage.getApplicationPropertiesSection().getValue();
assertFalse("Unexpected x-jms-type in application properties", applicationProperties.containsKey("x-jms-type"));
}
use of org.apache.qpid.server.protocol.v0_10.MessageTransferMessage in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_1_0Test method testExpirationConversion.
public void testExpirationConversion() {
long timestamp = System.currentTimeMillis();
int ttl = 100000;
final long expiration = timestamp + ttl;
final DeliveryProperties deliveryProperties = new DeliveryProperties();
deliveryProperties.setExpiration(expiration);
MessageTransferMessage message = createTestMessage(deliveryProperties, new MessageProperties(), null, timestamp);
final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
Properties properties = convertedMessage.getPropertiesSection().getValue();
assertNull("Unexpected expiration", properties.getAbsoluteExpiryTime());
Header header = convertedMessage.getHeaderSection().getValue();
assertEquals("Unexpected TTL", ttl, header.getTtl().intValue());
}
use of org.apache.qpid.server.protocol.v0_10.MessageTransferMessage in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_1_0Test method testHeaderWithListValueConversionFails.
public void testHeaderWithListValueConversionFails() {
Map<String, Object> headers = Collections.singletonMap("listHeader", Collections.emptyList());
final MessageProperties messageProperties = new MessageProperties();
messageProperties.setApplicationHeaders(headers);
MessageTransferMessage message = createTestMessage(messageProperties);
try {
_messageConverter.convert(message, _namedAddressSpace);
fail("Exception is expected");
} catch (MessageConversionException e) {
// pass
}
}
use of org.apache.qpid.server.protocol.v0_10.MessageTransferMessage in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_10Test 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 MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
assertEquals("Unexpected exchange", "", deliveryProperties.getExchange());
assertEquals("Unexpected routing key", testQueue, deliveryProperties.getRoutingKey());
}
use of org.apache.qpid.server.protocol.v0_10.MessageTransferMessage in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_10Test method testCorrelationIdULongConversion.
public void testCorrelationIdULongConversion() {
final UnsignedLong correlationId = UnsignedLong.valueOf(-1);
Properties properties = new Properties();
properties.setCorrelationId(correlationId);
Message_1_0 message = createTestMessage(properties);
final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
assertTrue("Unexpected correlationId", Arrays.equals(longToBytes(correlationId.longValue()), messageProperties.getCorrelationId()));
}
Aggregations