use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties in project qpid-broker-j by apache.
the class MessageConverter_v1_0_to_InternalTest method testAmqpValueWithNullWithContentType.
public void testAmqpValueWithNullWithContentType() throws Exception {
Properties properties = new Properties();
final String mimeType = "foo/bar";
properties.setContentType(Symbol.valueOf(mimeType));
final Object expected = null;
final AmqpValue amqpValue = new AmqpValue(expected);
Message_1_0 sourceMessage = createTestMessage(properties, amqpValue.createEncodingRetainingSection());
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", mimeType, convertedMessage.getMessageHeader().getMimeType());
assertNull("Unexpected content", convertedMessage.getMessageBody());
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties in project qpid-broker-j by apache.
the class MessageConverter_v1_0_to_InternalTest method testNoBodyWithTextMessageAnnotationWithUnknownTextualContentType.
public void testNoBodyWithTextMessageAnnotationWithUnknownTextualContentType() throws Exception {
final String mimeType = "foo/bar";
Properties properties = new Properties();
properties.setContentType(Symbol.valueOf(mimeType));
Message_1_0 sourceMessage = createTestMessage(properties, TEXT_MESSAGE_MESSAGE_ANNOTATION, null);
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", "text/plain", convertedMessage.getMessageHeader().getMimeType());
assertEquals("Unexpected content", null, convertedMessage.getMessageBody());
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties in project qpid-broker-j by apache.
the class MessageConverter_v1_0_to_InternalTest method testMessageAnnotationTakesPrecedenceOverContentType.
public void testMessageAnnotationTakesPrecedenceOverContentType() throws Exception {
final Properties properties = new Properties();
properties.setContentType(Symbol.valueOf("application/octet-stream"));
final Message_1_0 sourceMessage = createTestMessage(OBJECT_MESSAGE_MESSAGE_ANNOTATION, null);
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", "application/x-java-serialized-object", convertedMessage.getMessageHeader().getMimeType());
assertEquals("Unexpected content", null, convertedMessage.getMessageBody());
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties in project qpid-broker-j by apache.
the class PropertyConverter_v1_0_to_InternalTest method testAbsoluteExpiryTimeConversion.
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 originalMessage = createTestMessage(properties, arrivalTime);
InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected expiration", 0, convertedMessage.getMessageHeader().getExpiration());
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties in project qpid-broker-j by apache.
the class PropertyConverter_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 byte[] content) {
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, content == null ? 0 : content.length);
when(storedMessage.getMetaData()).thenReturn(metaData);
if (content != null) {
Binary binary = new Binary(content);
DataSection dataSection = new Data(binary).createEncodingRetainingSection();
QpidByteBuffer qbb = dataSection.getEncodedForm();
int length = qbb.remaining();
when(storedMessage.getContentSize()).thenReturn(length);
when(storedMessage.getContent(0, length)).thenReturn(qbb);
} else {
when(storedMessage.getContentSize()).thenReturn(0);
when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
}
return new Message_1_0(storedMessage);
}
Aggregations