Search in sources :

Example 11 with Properties

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10Test method testDataWithContentTypeAmqpMap.

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

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties 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 13 with Properties

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties 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 14 with Properties

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties 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 15 with Properties

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties 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

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