Search in sources :

Example 96 with InternalMessage

use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.

the class MessageConverter_v1_0_to_InternalTest method testAmqpValueWithNullWithTextMessageAnnotation.

public void testAmqpValueWithNullWithTextMessageAnnotation() throws Exception {
    final Object expected = null;
    final AmqpValue amqpValue = new AmqpValue(expected);
    Message_1_0 sourceMessage = createTestMessage(TEXT_MESSAGE_MESSAGE_ANNOTATION, amqpValue.createEncodingRetainingSection());
    final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertNull("Unexpected content", convertedMessage.getMessageBody());
    assertEquals("Unexpected mime type", "text/plain", convertedMessage.getMessageHeader().getMimeType());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) AmqpValue(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)

Example 97 with InternalMessage

use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v1_0Test method testMessageIdUuidConversion.

public void testMessageIdUuidConversion() {
    final UUID messageId = UUID.randomUUID();
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getMessageId()).thenReturn(messageId.toString());
    InternalMessage originalMessage = createTestMessage(header);
    Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    Object convertedMessageId = MessageConverter_from_1_0.getMessageId(convertedMessage);
    assertEquals("Unexpected messageId", messageId, convertedMessageId);
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) UUID(java.util.UUID)

Example 98 with InternalMessage

use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v1_0Test method testCorrelationIdUnsignedLongConversion.

public void testCorrelationIdUnsignedLongConversion() {
    final UnsignedLong correlationId = UnsignedLong.valueOf(-1L);
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getCorrelationId()).thenReturn(correlationId.toString());
    InternalMessage originalMessage = createTestMessage(header);
    Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    Object convertedCorrelationId = MessageConverter_from_1_0.getCorrelationId(convertedMessage);
    assertEquals("Unexpected correlationId", correlationId, convertedCorrelationId);
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) UnsignedLong(org.apache.qpid.server.protocol.v1_0.type.UnsignedLong) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 99 with InternalMessage

use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v1_0Test method testMessageIdUnsignedLongConversion.

public void testMessageIdUnsignedLongConversion() {
    final UnsignedLong messageId = UnsignedLong.valueOf(-1L);
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getMessageId()).thenReturn(messageId.toString());
    InternalMessage originalMessage = createTestMessage(header);
    Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    Object convertedMessageId = MessageConverter_from_1_0.getMessageId(convertedMessage);
    assertEquals("Unexpected messageId", messageId, convertedMessageId);
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) UnsignedLong(org.apache.qpid.server.protocol.v1_0.type.UnsignedLong) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 100 with InternalMessage

use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v1_0Test method createTestMessage.

private InternalMessage createTestMessage(String to) {
    final InternalMessageHeader internalMessageHeader = new InternalMessageHeader(mock(AMQMessageHeader.class));
    final StoredMessage<InternalMessageMetaData> handle = createInternalStoredMessage(null, false, internalMessageHeader);
    return new InternalMessage(handle, internalMessageHeader, null, to);
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) InternalMessageMetaData(org.apache.qpid.server.message.internal.InternalMessageMetaData) InternalMessageHeader(org.apache.qpid.server.message.internal.InternalMessageHeader) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Aggregations

InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)185 AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)60 Matchers.anyString (org.mockito.Matchers.anyString)45 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)36 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)25 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)24 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)23 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)18 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)18 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)17 AmqpValue (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)15 HashMap (java.util.HashMap)13 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)12 ReplyTo (org.apache.qpid.server.protocol.v0_10.transport.ReplyTo)9 UUID (java.util.UUID)8 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)8 MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)7 Map (java.util.Map)6 Exchange (org.apache.qpid.server.model.Exchange)6 ArrayList (java.util.ArrayList)5