use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header 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.Header in project qpid-broker-j by apache.
the class Message_1_0_MutatorTest method createTestMessage.
private Message_1_0 createTestMessage() {
final QpidByteBuffer content = new AmqpValue(TEST_CONTENT).createEncodingRetainingSection().getEncodedForm();
final long contentSize = content.remaining();
final Header header = new Header();
header.setPriority(UnsignedByte.valueOf(TEST_PRIORITY));
final HeaderSection headerSection = header.createEncodingRetainingSection();
final Properties properties = new Properties();
properties.setContentType(Symbol.valueOf(TEST_CONTENT_TYPE));
final PropertiesSection propertiesSection = properties.createEncodingRetainingSection();
final ApplicationPropertiesSection applicationPropertiesSection = new ApplicationProperties(Collections.singletonMap(TEST_HEADER_NAME, TEST_HEADER_VALUE)).createEncodingRetainingSection();
final MessageMetaData_1_0 mmd = new MessageMetaData_1_0(headerSection, null, null, propertiesSection, applicationPropertiesSection, null, System.currentTimeMillis(), contentSize);
final MessageHandle<MessageMetaData_1_0> handle = _messageStore.addMessage(mmd);
handle.addContent(content);
return new Message_1_0(handle.allContentAdded());
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.
the class PropertyConverter_v1_0_to_InternalTest method testTTLConversion.
@Test
public void testTTLConversion() {
long ttl = 10000;
long arrivalTime = System.currentTimeMillis();
long expiryTime = arrivalTime + ttl;
final Header header = new Header();
header.setTtl(UnsignedInteger.valueOf(ttl));
Message_1_0 originalMessage = createTestMessage(header, arrivalTime);
InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected expiration", expiryTime, convertedMessage.getMessageHeader().getExpiration());
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.
the class PropertyConverter_v1_0_to_InternalTest method testDurableTrueConversion.
@Test
public void testDurableTrueConversion() {
final Header header = new Header();
header.setDurable(true);
final Message_1_0 originalMessage = createTestMessage(header);
InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertTrue("Unexpected persistence of message", convertedMessage.isPersistent());
assertTrue("Unexpected persistence of meta data", convertedMessage.getStoredMessage().getMetaData().isPersistent());
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.
the class PropertyConverter_v1_0_to_InternalTest method testPriorityConversion.
@Test
public void testPriorityConversion() {
final byte priority = 7;
final Header header = new Header();
header.setPriority(UnsignedByte.valueOf(priority));
final Message_1_0 originalMessage = createTestMessage(header);
InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected priority", (long) priority, (long) convertedMessage.getMessageHeader().getPriority());
}
Aggregations