use of org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue in project qpid-broker-j by apache.
the class MessageConverter_v1_0_to_InternalTest method testAmqpValueWithNullWithMapMessageAnnotation.
public void testAmqpValueWithNullWithMapMessageAnnotation() throws Exception {
final Object expected = null;
final AmqpValue amqpValue = new AmqpValue(expected);
Message_1_0 sourceMessage = createTestMessage(MAP_MESSAGE_MESSAGE_ANNOTATION, amqpValue.createEncodingRetainingSection());
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", null, convertedMessage.getMessageHeader().getMimeType());
assertNull("Unexpected content", convertedMessage.getMessageBody());
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue in project qpid-broker-j by apache.
the class MessageConverter_v1_0_to_InternalTest method testAmqpValueWithMap.
public void testAmqpValueWithMap() throws Exception {
final Map<Object, Object> originalMap = new LinkedHashMap<>();
originalMap.put("binaryEntry", new Binary(new byte[] { 0x00, (byte) 0xFF }));
originalMap.put("intEntry", 42);
originalMap.put("uuidEntry", UUID.randomUUID());
originalMap.put("nullEntry", null);
originalMap.put(43, "nonstringkey");
originalMap.put("mapEntry", Collections.singletonMap("foo", "bar"));
final AmqpValue amqpValue = new AmqpValue(originalMap);
Message_1_0 sourceMessage = createTestMessage(amqpValue.createEncodingRetainingSection());
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", null, convertedMessage.getMessageHeader().getMimeType());
Map<Object, Object> convertedMap = (Map<Object, Object>) convertedMessage.getMessageBody();
assertEquals("Unexpected size", originalMap.size(), convertedMap.size());
assertArrayEquals("Unexpected binary entry", ((Binary) originalMap.get("binaryEntry")).getArray(), (byte[]) convertedMap.get("binaryEntry"));
assertEquals("Unexpected int entry", originalMap.get("intEntry"), convertedMap.get("intEntry"));
assertEquals("Unexpected null entry", originalMap.get("nullEntry"), convertedMap.get("nullEntry"));
assertEquals("Unexpected uuid entry", originalMap.get("uuidEntry"), convertedMap.get("uuidEntry"));
assertEquals("Unexpected nonstringkey entry", originalMap.get(43), convertedMap.get(43));
assertEquals("Unexpected map entry", new HashMap((Map) originalMap.get("mapEntry")), new HashMap((Map) convertedMap.get("mapEntry")));
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue in project qpid-broker-j by apache.
the class MessageConverter_v1_0_to_InternalTest method testAmqpValueWithNullWithTextMessageAnnotation.
public void testAmqpValueWithNullWithTextMessageAnnotation() throws Exception {
final Object expected = null;
final AmqpValue amqpValue = new AmqpValue(expected);
Message_1_0 sourceMessage = createTestMessage(TEXT_MESSAGE_MESSAGE_ANNOTATION, amqpValue.createEncodingRetainingSection());
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertNull("Unexpected content", convertedMessage.getMessageBody());
assertEquals("Unexpected mime type", "text/plain", convertedMessage.getMessageHeader().getMimeType());
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_10Test method testAmqpValueWithNullWithStreamMessageAnnotation.
public void testAmqpValueWithNullWithStreamMessageAnnotation() throws Exception {
final Object expected = null;
final AmqpValue amqpValue = new AmqpValue(expected);
Message_1_0 sourceMessage = createTestMessage(STREAM_MESSAGE_MESSAGE_ANNOTATION, amqpValue.createEncodingRetainingSection());
final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", "jms/stream-message", convertedMessage.getMessageHeader().getMimeType());
assertEquals("Unexpected content size", 0, convertedMessage.getSize());
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_10Test 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 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());
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)));
}
Aggregations