Search in sources :

Example 21 with Message_1_0

use of org.apache.qpid.server.protocol.v1_0.Message_1_0 in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10Test method testDataWithContentTypeJavaSerializedObject.

public void testDataWithContentTypeJavaSerializedObject() throws Exception {
    final byte[] expected = getObjectBytes("helloworld".getBytes(UTF_8));
    final Data value = new Data(new Binary(expected));
    Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf("application/x-java-serialized-object"));
    Message_1_0 sourceMessage = createTestMessage(properties, value.createEncodingRetainingSection());
    final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", "application/java-object-stream", convertedMessage.getMessageHeader().getMimeType());
    final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
    assertArrayEquals("Unexpected content", expected, getBytes(content));
}
Also used : MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) 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) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)

Example 22 with Message_1_0

use of org.apache.qpid.server.protocol.v1_0.Message_1_0 in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10Test method testAmqpValueWithNullWithBytesMessageAnnotation.

public void testAmqpValueWithNullWithBytesMessageAnnotation() throws Exception {
    final Object expected = null;
    final AmqpValue amqpValue = new AmqpValue(expected);
    Message_1_0 sourceMessage = createTestMessage(BYTE_MESSAGE_MESSAGE_ANNOTATION, amqpValue.createEncodingRetainingSection());
    final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", "application/octet-stream", convertedMessage.getMessageHeader().getMimeType());
    assertEquals("Unexpected content size", 0, convertedMessage.getSize());
}
Also used : MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) AmqpValue(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)

Example 23 with Message_1_0

use of org.apache.qpid.server.protocol.v1_0.Message_1_0 in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10Test method testNoBodyWithJmsMapContentType.

public void testNoBodyWithJmsMapContentType() throws Exception {
    final Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf("jms/map-message"));
    final Message_1_0 sourceMessage = createTestMessage(properties, null);
    final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
    assertEquals("Unexpected mime type", "jms/map-message", convertedMessage.getMessageHeader().getMimeType());
    assertArrayEquals("Unexpected content size", new MapToJmsMapMessage().toMimeContent(Collections.emptyMap()), getBytes(content));
}
Also used : MapToJmsMapMessage(org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)

Example 24 with Message_1_0

use of org.apache.qpid.server.protocol.v1_0.Message_1_0 in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10Test method testAmqpValueWithNullWithJmsMapContentType.

public void testAmqpValueWithNullWithJmsMapContentType() throws Exception {
    final Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf("jms/map-message"));
    final Object expected = null;
    final AmqpValue amqpValue = new AmqpValue(expected);
    Message_1_0 sourceMessage = createTestMessage(properties, amqpValue.createEncodingRetainingSection());
    final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
    assertEquals("Unexpected mime type", "jms/map-message", convertedMessage.getMessageHeader().getMimeType());
    assertArrayEquals("Unexpected content size", new MapToJmsMapMessage().toMimeContent(Collections.emptyMap()), getBytes(content));
}
Also used : MapToJmsMapMessage(org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) 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 25 with Message_1_0

use of org.apache.qpid.server.protocol.v1_0.Message_1_0 in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10Test method testDataWithMapMessageAnnotationAndContentTypeJmsMapMessage.

public void testDataWithMapMessageAnnotationAndContentTypeJmsMapMessage() throws Exception {
    Map<String, Object> originalMap = Collections.singletonMap("testKey", "testValue");
    byte[] data = new MapToJmsMapMessage().toMimeContent(originalMap);
    String expectedMimeType = "jms/map-message";
    final Data value = new Data(new Binary(data));
    Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf(expectedMimeType));
    Message_1_0 sourceMessage = createTestMessage(properties, MAP_MESSAGE_MESSAGE_ANNOTATION, value.createEncodingRetainingSection());
    final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", expectedMimeType, convertedMessage.getMessageHeader().getMimeType());
    final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
    assertArrayEquals("Unexpected content", data, getBytes(content));
}
Also used : MapToJmsMapMessage(org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) 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) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)

Aggregations

Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)254 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)199 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)153 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)125 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)116 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)112 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)75 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)73 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)69 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)68 Matchers.anyString (org.mockito.Matchers.anyString)67 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)58 AmqpValue (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)55 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)52 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)49 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)35 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)32 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)25 HashMap (java.util.HashMap)21 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)17