Search in sources :

Example 46 with Data

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

the class MessageConverter_1_0_to_v0_10Test method testDataWithMapMessageAnnotationAndContentTypeAmqpMap.

public void testDataWithMapMessageAnnotationAndContentTypeAmqpMap() throws Exception {
    Map<String, Object> originalMap = Collections.singletonMap("testKey", "testValue");
    byte[] data = new MapToAmqpMapConverter().toMimeContent(originalMap);
    String expectedMimeType = "amqp/map";
    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 : 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 47 with Data

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

the class MessageConverter_1_0_to_v0_10Test method testDataWithContentTypeOther.

public void testDataWithContentTypeOther() throws Exception {
    final byte[] expected = "helloworld".getBytes(UTF_8);
    final Data value = new Data(new Binary(expected));
    final Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf("application/bin"));
    Message_1_0 sourceMessage = createTestMessage(properties, 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) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)

Example 48 with Data

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

the class MessageConverter_1_0_to_v0_10Test method doTestConvertOfDataSectionForTextualType.

private void doTestConvertOfDataSectionForTextualType(final String contentType) throws Exception {
    final String expected = "testContent";
    final Data value = new Data(new Binary(expected.getBytes(UTF_8)));
    final Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf(contentType));
    Message_1_0 sourceMessage = createTestMessage(properties, value.createEncodingRetainingSection());
    final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
    assertEquals("Unexpected content", expected, new String(getBytes(content), UTF_8));
    assertEquals("Unexpected mime type", "text/plain", convertedMessage.getMessageHeader().getMimeType());
}
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 49 with Data

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

the class MessageConverter_1_0_to_v0_10Test method testDataWithStreamMessageAnnotationAndContentTypeAmqpList.

public void testDataWithStreamMessageAnnotationAndContentTypeAmqpList() throws Exception {
    List<Object> originalList = Collections.singletonList("testValue");
    byte[] data = new ListToAmqpListConverter().toMimeContent(originalList);
    String expectedMimeType = "amqp/list";
    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 : MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) ListToAmqpListConverter(org.apache.qpid.server.protocol.v0_10.transport.mimecontentconverter.ListToAmqpListConverter) 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 50 with Data

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

the class MessageConverter_1_0_to_v0_10Test method testDataWithContentTypeAmqpList.

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

Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)42 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)39 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)32 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)30 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)29 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)29 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)28 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)19 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)19 Test (org.junit.Test)19 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)18 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)14 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)14 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)13 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)12 ArrayList (java.util.ArrayList)9 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)9 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)9 Transfer (org.apache.qpid.server.protocol.v1_0.type.transport.Transfer)8 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)8