Search in sources :

Example 1 with ListToJmsStreamMessage

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

the class MessageConverter_1_0_to_v0_10Test method testDataWithStreamMessageAnnotationAndContentTypeJmsStreamMessage.

@Test
public void testDataWithStreamMessageAnnotationAndContentTypeJmsStreamMessage() throws Exception {
    List<Object> originalList = Collections.singletonList("testValue");
    byte[] data = new ListToJmsStreamMessage().toMimeContent(originalList);
    String expectedMimeType = "jms/stream-message";
    final Data value = new Data(new Binary(data));
    Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf(expectedMimeType));
    Message_1_0 sourceMessage = createTestMessage(properties, STREAM_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 : ListToJmsStreamMessage(org.apache.qpid.server.typedmessage.mimecontentconverter.ListToJmsStreamMessage) 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) Test(org.junit.Test)

Example 2 with ListToJmsStreamMessage

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

the class MessageConverter_1_0_to_v0_10Test method testDataWithContentTypeJmsStreamMessage.

@Test
public void testDataWithContentTypeJmsStreamMessage() throws Exception {
    List<Object> originalMap = Collections.singletonList("testValue");
    byte[] bytes = new ListToJmsStreamMessage().toMimeContent(originalMap);
    final Data value = new Data(new Binary(bytes));
    Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf("jms/stream-message"));
    Message_1_0 sourceMessage = createTestMessage(properties, value.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());
    assertArrayEquals("Unexpected content", bytes, getBytes(content));
}
Also used : ListToJmsStreamMessage(org.apache.qpid.server.typedmessage.mimecontentconverter.ListToJmsStreamMessage) 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) Test(org.junit.Test)

Example 3 with ListToJmsStreamMessage

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

the class MessageConverter_1_0_to_v0_8Test method testDataWithContentTypeJmsStreamMessage.

@Test
public void testDataWithContentTypeJmsStreamMessage() throws Exception {
    List<Object> originalMap = Collections.singletonList("testValue");
    byte[] bytes = new ListToJmsStreamMessage().toMimeContent(originalMap);
    final Data value = new Data(new Binary(bytes));
    Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf("jms/stream-message"));
    Message_1_0 sourceMessage = createTestMessage(properties, value.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());
    assertArrayEquals("Unexpected content", bytes, getBytes(content));
}
Also used : ListToJmsStreamMessage(org.apache.qpid.server.typedmessage.mimecontentconverter.ListToJmsStreamMessage) 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) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage) Test(org.junit.Test)

Example 4 with ListToJmsStreamMessage

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

the class MessageConverter_Internal_to_0_8Test method testListMessageWithMimeType.

@Test
public void testListMessageWithMimeType() throws Exception {
    ArrayList<?> content = Lists.newArrayList("testItem", 37.5, 42);
    final ListToJmsStreamMessage listToJmsStreamMessage = new ListToJmsStreamMessage();
    final byte[] expectedContent = listToJmsStreamMessage.toMimeContent(content);
    doTest(content, "foo/bar", expectedContent, listToJmsStreamMessage.getMimeType());
}
Also used : ListToJmsStreamMessage(org.apache.qpid.server.typedmessage.mimecontentconverter.ListToJmsStreamMessage) Test(org.junit.Test)

Example 5 with ListToJmsStreamMessage

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

the class MessageConverter_Internal_to_0_8Test method testListMessageWithoutMimeType.

@Test
public void testListMessageWithoutMimeType() throws Exception {
    ArrayList<?> content = Lists.newArrayList("testItem", 37.5, 42);
    final ListToJmsStreamMessage listToJmsStreamMessage = new ListToJmsStreamMessage();
    final byte[] expectedContent = listToJmsStreamMessage.toMimeContent(content);
    doTest(content, null, expectedContent, listToJmsStreamMessage.getMimeType());
}
Also used : ListToJmsStreamMessage(org.apache.qpid.server.typedmessage.mimecontentconverter.ListToJmsStreamMessage) Test(org.junit.Test)

Aggregations

ListToJmsStreamMessage (org.apache.qpid.server.typedmessage.mimecontentconverter.ListToJmsStreamMessage)8 Test (org.junit.Test)8 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 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)4 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)4 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)4 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)4 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)2 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)2