use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_1_0Test method testTTLConversion.
@Test
public void testTTLConversion() {
long timestamp = System.currentTimeMillis();
int ttl = 100000;
final DeliveryProperties deliveryProperties = new DeliveryProperties();
deliveryProperties.setTtl(ttl);
MessageTransferMessage message = createTestMessage(deliveryProperties, new MessageProperties(), null, timestamp);
final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
Header header = convertedMessage.getHeaderSection().getValue();
assertEquals("Unexpected TTL", (long) ttl, header.getTtl().longValue());
Properties properties = convertedMessage.getPropertiesSection().getValue();
assertNull("Unexpected expiration", properties.getAbsoluteExpiryTime());
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_1_0Test method testPriorityConversion.
@Test
public void testPriorityConversion() {
final byte priority = 5;
final DeliveryProperties deliveryProperties = new DeliveryProperties();
deliveryProperties.setPriority(MessageDeliveryPriority.get(priority));
MessageTransferMessage message = createTestMessage(deliveryProperties);
final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
Header header = convertedMessage.getHeaderSection().getValue();
assertEquals("Unexpected priority", (long) priority, (long) header.getPriority().byteValue());
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_10Test method testSubjectDoesNoReplaceApplicationPropertyXJMSType.
@Test
public void testSubjectDoesNoReplaceApplicationPropertyXJMSType() {
final String subject = "testSubject";
Properties properties = new Properties();
properties.setSubject(subject);
final String jmsType = "testJmsType";
Map<String, Object> applicationPropertiesMap = Collections.singletonMap("x-jms-type", jmsType);
ApplicationProperties applicationProperties = new ApplicationProperties(applicationPropertiesMap);
Message_1_0 message = createTestMessage(new Header(), new DeliveryAnnotations(Collections.emptyMap()), new MessageAnnotations(Collections.emptyMap()), properties, applicationProperties, 0, null);
final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
final Map<String, Object> headers = messageProperties.getApplicationHeaders();
assertEquals("Unexpected qpid.subject is missing from headers", subject, headers.get("qpid.subject"));
assertEquals("Unexpected type", jmsType, headers.get("x-jms-type"));
final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
assertEquals("Unexpected routing-key", subject, deliveryProperties.getRoutingKey());
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_10Test method testGroupSequenceDoesNotReplaceApplicationPropertiesJMSXGroupSeq.
@Test
public void testGroupSequenceDoesNotReplaceApplicationPropertiesJMSXGroupSeq() {
int testGroupSequence = 1;
Properties properties = new Properties();
properties.setGroupSequence(UnsignedInteger.valueOf(testGroupSequence));
final int JMSXGroupSeq = 2;
Map<String, Object> applicationPropertiesMap = Collections.singletonMap("JMSXGroupSeq", JMSXGroupSeq);
ApplicationProperties applicationProperties = new ApplicationProperties(applicationPropertiesMap);
Message_1_0 message = createTestMessage(new Header(), new DeliveryAnnotations(Collections.emptyMap()), new MessageAnnotations(Collections.emptyMap()), properties, applicationProperties, 0, null);
final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
final Map<String, Object> applicationHeaders = messageProperties.getApplicationHeaders();
assertEquals("Unexpected JMSXGroupSeq", JMSXGroupSeq, applicationHeaders.get("JMSXGroupSeq"));
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_10Test method testConversionOfTtlTakesPrecedenceOverAbsoluteExpiryTime.
@Test
public void testConversionOfTtlTakesPrecedenceOverAbsoluteExpiryTime() {
long ttl = 10000;
final long time = System.currentTimeMillis();
long absoluteExpiryTime = time + ttl;
long arrivalTime = time + 1;
Header header = new Header();
header.setTtl(UnsignedInteger.valueOf(ttl));
Properties properties = new Properties();
properties.setAbsoluteExpiryTime(new Date(absoluteExpiryTime));
Message_1_0 message = createTestMessage(header, new DeliveryAnnotations(Collections.emptyMap()), new MessageAnnotations(Collections.emptyMap()), properties, new ApplicationProperties(Collections.emptyMap()), arrivalTime, null);
final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
assertEquals("Unexpected ttl", ttl, deliveryProperties.getTtl());
assertEquals("Unexpected expiration", arrivalTime + ttl, deliveryProperties.getExpiration());
}
Aggregations