use of org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method createTestMessage.
private Message_1_0 createTestMessage(final Header header, final DeliveryAnnotations deliveryAnnotations, final MessageAnnotations messageAnnotations, final Properties properties, final ApplicationProperties applicationProperties, final long arrivalTime) {
final StoredMessage<MessageMetaData_1_0> storedMessage = mock(StoredMessage.class);
when(storedMessage.getContentSize()).thenReturn(0);
when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
MessageMetaData_1_0 metaData = new MessageMetaData_1_0(header.createEncodingRetainingSection(), deliveryAnnotations.createEncodingRetainingSection(), messageAnnotations.createEncodingRetainingSection(), properties.createEncodingRetainingSection(), applicationProperties.createEncodingRetainingSection(), new Footer(Collections.emptyMap()).createEncodingRetainingSection(), arrivalTime, 0);
when(storedMessage.getMetaData()).thenReturn(metaData);
return new Message_1_0(storedMessage);
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testConversionOfAbsoluteExpiryTimeTakesPrecedenceOverTTL.
public void testConversionOfAbsoluteExpiryTimeTakesPrecedenceOverTTL() {
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);
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
assertEquals("Unexpected expiration", absoluteExpiryTime, convertedProperties.getExpiration());
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations in project qpid-broker-j by apache.
the class MessageConverter_v1_0_to_InternalTest method createTestMessage.
private Message_1_0 createTestMessage(final Header header, final DeliveryAnnotations deliveryAnnotations, final MessageAnnotations messageAnnotations, final Properties properties, final ApplicationProperties applicationProperties, final long arrivalTime, final EncodingRetainingSection section) {
final StoredMessage<MessageMetaData_1_0> storedMessage = mock(StoredMessage.class);
MessageMetaData_1_0 metaData = new MessageMetaData_1_0(header.createEncodingRetainingSection(), deliveryAnnotations.createEncodingRetainingSection(), messageAnnotations.createEncodingRetainingSection(), properties.createEncodingRetainingSection(), applicationProperties.createEncodingRetainingSection(), new Footer(Collections.emptyMap()).createEncodingRetainingSection(), arrivalTime, 0);
when(storedMessage.getMetaData()).thenReturn(metaData);
if (section != null) {
// TODO this is leaking QBBs
final QpidByteBuffer combined = section.getEncodedForm();
when(storedMessage.getContentSize()).thenReturn((int) section.getEncodedSize());
final ArgumentCaptor<Integer> offsetCaptor = ArgumentCaptor.forClass(Integer.class);
final ArgumentCaptor<Integer> sizeCaptor = ArgumentCaptor.forClass(Integer.class);
when(storedMessage.getContent(offsetCaptor.capture(), sizeCaptor.capture())).then(invocation -> combined.view(offsetCaptor.getValue(), sizeCaptor.getValue()));
} else {
when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
}
return new Message_1_0(storedMessage);
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_10Test method testGroupSequenceDoesNotReplaceApplicationPropertiesJMSXGroupSeq.
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.DeliveryAnnotations in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_10Test method testSubjectDoesNoReplaceApplicationPropertyXJMSType.
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());
}
Aggregations