use of org.apache.qpid.server.bytebuffer.QpidByteBuffer in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_10Test method testNoBodyWithObjectMessageAnnotation.
public void testNoBodyWithObjectMessageAnnotation() throws Exception {
Message_1_0 sourceMessage = createTestMessage(OBJECT_MESSAGE_MESSAGE_ANNOTATION, null);
final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
assertEquals("Unexpected mime type", "application/java-object-stream", convertedMessage.getMessageHeader().getMimeType());
assertArrayEquals("Unexpected content size", getObjectBytes(null), getBytes(content));
}
use of org.apache.qpid.server.bytebuffer.QpidByteBuffer in project qpid-broker-j by apache.
the class ReportRunner method convertMessage.
private static ReportableMessage convertMessage(QueueEntry entry) {
final MessageInfoImpl messageInfo = new MessageInfoImpl(entry, true);
ServerMessage message = entry.getMessage();
byte[] content;
try (QpidByteBuffer contentBuffer = message.getContent()) {
content = new byte[contentBuffer.remaining()];
contentBuffer.get(content);
}
return new ReportableMessage() {
@Override
public String getInitialRoutingAddress() {
return messageInfo.getInitialRoutingAddress();
}
@Override
public ReportableMessageHeader getMessageHeader() {
return convertMessageHeader(messageInfo);
}
@Override
public ByteBuffer getContent() {
return ByteBuffer.wrap(content).asReadOnlyBuffer();
}
@Override
public boolean isPersistent() {
return messageInfo.isPersistent();
}
@Override
public long getSize() {
return messageInfo.getSize();
}
@Override
public Date getExpiration() {
return messageInfo.getExpirationTime();
}
@Override
public long getMessageNumber() {
return messageInfo.getId();
}
@Override
public Date getArrivalTime() {
return messageInfo.getArrivalTime();
}
};
}
use of org.apache.qpid.server.bytebuffer.QpidByteBuffer in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_8Test method testAmqpValueWithListContainingMap.
public void testAmqpValueWithListContainingMap() throws Exception {
final List<Object> originalList = Collections.singletonList(Collections.singletonMap("testKey", "testValue"));
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", "amqp/list", convertedMessage.getMessageHeader().getMimeType());
final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
List<Object> convertedList = new AmqpListToListConverter().toObject(getBytes(content));
assertEquals("Unexpected size", originalList.size(), convertedList.size());
assertEquals("Unexpected map item", new HashMap<String, Object>((Map) originalList.get(0)), new HashMap<String, Object>((Map) convertedList.get(0)));
}
use of org.apache.qpid.server.bytebuffer.QpidByteBuffer 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.server.bytebuffer.QpidByteBuffer in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_8Test method testAmqpValueWithNullWithObjectMessageAnnotation.
public void testAmqpValueWithNullWithObjectMessageAnnotation() throws Exception {
final Object expected = null;
final AmqpValue amqpValue = new AmqpValue(expected);
Message_1_0 sourceMessage = createTestMessage(OBJECT_MESSAGE_MESSAGE_ANNOTATION, amqpValue.createEncodingRetainingSection());
final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
assertEquals("Unexpected mime type", "application/java-object-stream", convertedMessage.getMessageHeader().getMimeType());
assertArrayEquals("Unexpected content size", getObjectBytes(null), getBytes(content));
}
Aggregations