Search in sources :

Example 51 with InternalMessage

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

the class PropertyConverter_Internal_to_v0_10Test method testPriorityConversion.

public void testPriorityConversion() throws IOException {
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    byte priority = (byte) 7;
    when(header.getPriority()).thenReturn(priority);
    InternalMessage originalMessage = createTestMessage(header);
    MessageTransferMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertEquals("Unexpected priority", priority, convertedMessage.getHeader().getDeliveryProperties().getPriority().getValue());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 52 with InternalMessage

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

the class PropertyConverter_v0_8_to_InternalTest method testReplyToNonBurl.

public void testReplyToNonBurl() {
    final String replyTo = "test/routing";
    BasicContentHeaderProperties header = new BasicContentHeaderProperties();
    header.setReplyTo(replyTo);
    final AMQMessage originalMessage = createTestMessage(header);
    InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertEquals("Unexpected replyTo", replyTo, convertedMessage.getMessageHeader().getReplyTo());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)

Example 53 with InternalMessage

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

the class MessageConverter_Internal_to_1_0Test method doTest.

private void doTest(final Serializable messageBytes, final String mimeType, final Class<? extends EncodingRetainingSection<?>> expectedBodySection, final Object expectedContent, final Symbol expectedContentType, final Byte expectedJmsTypeAnnotation) throws Exception {
    final InternalMessage sourceMessage = getAmqMessage(messageBytes, mimeType);
    final Message_1_0 convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    final QpidByteBuffer content = convertedMessage.getContent();
    List<EncodingRetainingSection<?>> sections = getEncodingRetainingSections(content, 1);
    EncodingRetainingSection<?> encodingRetainingSection = sections.get(0);
    assertEquals("Unexpected section type", expectedBodySection, encodingRetainingSection.getClass());
    if (expectedContent instanceof byte[]) {
        assertArrayEquals("Unexpected content", ((byte[]) expectedContent), ((Binary) encodingRetainingSection.getValue()).getArray());
    } else {
        assertEquals("Unexpected content", expectedContent, encodingRetainingSection.getValue());
    }
    Symbol contentType = getContentType(convertedMessage);
    if (expectedContentType == null) {
        assertNull("Content type should be null", contentType);
    } else {
        assertEquals("Unexpected content type", expectedContentType, contentType);
    }
    Byte jmsMessageTypeAnnotation = getJmsMessageTypeAnnotation(convertedMessage);
    if (expectedJmsTypeAnnotation == null) {
        assertEquals("Unexpected annotation 'x-opt-jms-msg-type'", null, jmsMessageTypeAnnotation);
    } else {
        assertEquals("Unexpected annotation 'x-opt-jms-msg-type'", expectedJmsTypeAnnotation, jmsMessageTypeAnnotation);
    }
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) EncodingRetainingSection(org.apache.qpid.server.protocol.v1_0.type.messaging.EncodingRetainingSection) Symbol(org.apache.qpid.server.protocol.v1_0.type.Symbol) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer)

Example 54 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 testNoBody.

public void testNoBody() throws Exception {
    final Message_1_0 sourceMessage = createTestMessage(null);
    final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", null, 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)

Example 55 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 doTestDataWithAnnotation.

private void doTestDataWithAnnotation(final byte[] data, final MessageAnnotations messageAnnotations, final String mimeType, final String expectedMimeType) {
    final Data value = new Data(new Binary(data));
    Message_1_0 sourceMessage;
    if (mimeType != null) {
        Properties properties = new Properties();
        properties.setContentType(Symbol.valueOf(mimeType));
        sourceMessage = createTestMessage(properties, messageAnnotations, value.createEncodingRetainingSection());
    } else {
        sourceMessage = createTestMessage(messageAnnotations, value.createEncodingRetainingSection());
    }
    final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", expectedMimeType, convertedMessage.getMessageHeader().getMimeType());
    assertArrayEquals("Unexpected content", data, ((byte[]) convertedMessage.getMessageBody()));
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Data(org.apache.qpid.server.protocol.v1_0.type.messaging.Data) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)

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