Search in sources :

Example 1 with JmsStreamMessageToList

use of org.apache.qpid.server.typedmessage.mimecontentconverter.JmsStreamMessageToList in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10Test method testAmqpSequenceWithSimpleTypes.

public void testAmqpSequenceWithSimpleTypes() throws Exception {
    final List<Integer> expected = new ArrayList<>();
    expected.add(37);
    expected.add(42);
    final AmqpSequence amqpSequence = new AmqpSequence(expected);
    Message_1_0 sourceMessage = createTestMessage(amqpSequence.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());
    assertEquals("Unexpected content", expected, new JmsStreamMessageToList().toObject(getBytes(content)));
}
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) AmqpSequence(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpSequence)

Example 2 with JmsStreamMessageToList

use of org.apache.qpid.server.typedmessage.mimecontentconverter.JmsStreamMessageToList 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 3 with JmsStreamMessageToList

use of org.apache.qpid.server.typedmessage.mimecontentconverter.JmsStreamMessageToList in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_8Test 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 AMQMessage 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) 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) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 4 with JmsStreamMessageToList

use of org.apache.qpid.server.typedmessage.mimecontentconverter.JmsStreamMessageToList in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_8Test method testAmqpSequenceWithSimpleTypes.

public void testAmqpSequenceWithSimpleTypes() throws Exception {
    final List<Integer> expected = new ArrayList<>();
    expected.add(37);
    expected.add(42);
    final AmqpSequence amqpSequence = new AmqpSequence(expected);
    Message_1_0 sourceMessage = createTestMessage(amqpSequence.createEncodingRetainingSection());
    final AMQMessage 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());
    assertEquals("Unexpected content", expected, new JmsStreamMessageToList().toObject(getBytes(content)));
}
Also used : JmsStreamMessageToList(org.apache.qpid.server.typedmessage.mimecontentconverter.JmsStreamMessageToList) 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) AmqpSequence(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpSequence) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Aggregations

ArrayList (java.util.ArrayList)4 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)4 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)4 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)4 JmsStreamMessageToList (org.apache.qpid.server.typedmessage.mimecontentconverter.JmsStreamMessageToList)4 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)2 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)2 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)2 AmqpSequence (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpSequence)2 AmqpValue (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)2