Search in sources :

Example 26 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 testData.

public void testData() throws Exception {
    final byte[] expected = getObjectBytes("helloworld".getBytes(UTF_8));
    final Data value = new Data(new Binary(expected));
    final Message_1_0 sourceMessage = createTestMessage(value.createEncodingRetainingSection());
    final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", "application/octet-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)

Example 27 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 testAmqpValueWithNullWithObjectMessageContentType.

public void testAmqpValueWithNullWithObjectMessageContentType() throws Exception {
    final Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf("application/x-java-serialized-object"));
    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));
    assertEquals("Unexpected mime type", "application/java-object-stream", convertedMessage.getMessageHeader().getMimeType());
    assertEquals("Unexpected content size", getObjectBytes(null).length, 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) 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 28 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 testAmqpValueWithList.

public void testAmqpValueWithList() throws Exception {
    final List<Object> originalList = new ArrayList<>();
    originalList.add(new Binary(new byte[] { 0x00, (byte) 0xFF }));
    originalList.add(42);
    originalList.add(null);
    final AmqpValue amqpValue = new AmqpValue(originalList);
    Message_1_0 sourceMessage = createTestMessage(amqpValue.createEncodingRetainingSection());
    final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", "jms/stream-message", convertedMessage.getMessageHeader().getMimeType());
    final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
    List<Object> convertedList = new JmsStreamMessageToList().toObject(getBytes(content));
    assertEquals("Unexpected size", originalList.size(), convertedList.size());
    assertArrayEquals("Unexpected binary item", ((Binary) originalList.get(0)).getArray(), (byte[]) convertedList.get(0));
    assertEquals("Unexpected int item", originalList.get(1), convertedList.get(1));
    assertEquals("Unexpected null item", originalList.get(2), convertedList.get(2));
}
Also used : JmsStreamMessageToList(org.apache.qpid.server.typedmessage.mimecontentconverter.JmsStreamMessageToList) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) ArrayList(java.util.ArrayList) 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) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) AmqpValue(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)

Example 29 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 testAmqpValueWithNullWithUnknownMessageAnnotation.

public void testAmqpValueWithNullWithUnknownMessageAnnotation() throws Exception {
    final Object expected = null;
    final AmqpValue amqpValue = new AmqpValue(expected);
    Message_1_0 sourceMessage = createTestMessage(new MessageAnnotations(Collections.singletonMap(Symbol.valueOf("x-opt-jms-msg-type"), (byte) 11)), amqpValue.createEncodingRetainingSection());
    final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", null, convertedMessage.getMessageHeader().getMimeType());
    assertEquals("Unexpected content size", 0, convertedMessage.getSize());
}
Also used : MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) 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 30 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 testAmqpValueWithMapContainingMap.

public void testAmqpValueWithMapContainingMap() throws Exception {
    final Map<String, Object> originalMap = Collections.singletonMap("testMap", Collections.singletonMap("innerKey", "testValue"));
    final AmqpValue amqpValue = new AmqpValue(originalMap);
    Message_1_0 sourceMessage = createTestMessage(amqpValue.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());
    Map<String, Object> convertedMap = new AmqpMapToMapConverter().toObject(getBytes(content));
    assertEquals("Unexpected size", originalMap.size(), convertedMap.size());
    assertEquals("Unexpected binary entry", new HashMap((Map<String, Object>) originalMap.get("testMap")), new HashMap((Map<String, Object>) convertedMap.get("testMap")));
}
Also used : MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) AmqpMapToMapConverter(org.apache.qpid.server.protocol.v0_10.transport.mimecontentconverter.AmqpMapToMapConverter) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) HashMap(java.util.HashMap) JmsMapMessageToMap(org.apache.qpid.server.typedmessage.mimecontentconverter.JmsMapMessageToMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) AmqpValue(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)

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