use of org.apache.qpid.amqp_1_0.type.Binary in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_10Test method testDataWithContentTypeJavaObjectStream.
public void testDataWithContentTypeJavaObjectStream() 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/java-object-stream"));
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));
}
use of org.apache.qpid.amqp_1_0.type.Binary in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_8Test 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 AMQMessage 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));
}
use of org.apache.qpid.amqp_1_0.type.Binary in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_8Test method doTestDataWithAnnotation.
private void doTestDataWithAnnotation(final byte[] data, final MessageAnnotations messageAnnotations, final String expectedMimeType) throws Exception {
final Data value = new Data(new Binary(data));
Message_1_0 sourceMessage = createTestMessage(messageAnnotations, value.createEncodingRetainingSection());
final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", expectedMimeType, convertedMessage.getMessageHeader().getMimeType());
final QpidByteBuffer content = convertedMessage.getContent();
assertArrayEquals("Unexpected content", data, getBytes(content));
}
use of org.apache.qpid.amqp_1_0.type.Binary in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_8Test method testDataWithContentTypeJmsStreamMessage.
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));
}
use of org.apache.qpid.amqp_1_0.type.Binary in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testMessageIdBinaryConversion.
public void testMessageIdBinaryConversion() {
final String messageId = "testMessageId";
Properties properties = new Properties();
properties.setMessageId(new Binary(messageId.getBytes()));
Message_1_0 message = createTestMessage(properties);
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
assertEquals("Unexpected messageId", messageId, convertedProperties.getMessageId().toString());
}
Aggregations