Search in sources :

Example 1 with Properties

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());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) AmqpValue(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)

Example 2 with Properties

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());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)

Example 3 with Properties

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());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)

Example 4 with Properties

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());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) Date(java.util.Date)

Example 5 with Properties

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);
}
Also used : DataSection(org.apache.qpid.server.protocol.v1_0.type.messaging.DataSection) Footer(org.apache.qpid.server.protocol.v1_0.type.messaging.Footer) Data(org.apache.qpid.server.protocol.v1_0.type.messaging.Data) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary)

Aggregations

Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)203 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)174 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)156 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)80 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)76 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)68 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)67 Matchers.anyString (org.mockito.Matchers.anyString)67 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)65 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)51 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)50 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)48 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)33 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)27 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)25 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)18 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)15 Date (java.util.Date)14 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)14 HashMap (java.util.HashMap)12