use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class MessageConverter_v1_0_to_InternalTest method testData.
public void testData() throws Exception {
final byte[] expected = getObjectBytes("helloworld".getBytes(UTF_8));
final Data value = new Data(new Binary(expected));
final Message_1_0 sourceMessage = createTestMessage(value.createEncodingRetainingSection());
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", "application/octet-stream", convertedMessage.getMessageHeader().getMimeType());
assertArrayEquals("Unexpected content", expected, ((byte[]) convertedMessage.getMessageBody()));
}
use of org.apache.qpid.server.message.internal.InternalMessage 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.message.internal.InternalMessage in project qpid-broker-j by apache.
the class MessageConverter_v1_0_to_InternalTest method testNoBodyWithTextMessageAnnotation.
public void testNoBodyWithTextMessageAnnotation() throws Exception {
Message_1_0 sourceMessage = createTestMessage(TEXT_MESSAGE_MESSAGE_ANNOTATION, null);
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", "text/plain", convertedMessage.getMessageHeader().getMimeType());
assertEquals("Unexpected content", null, convertedMessage.getMessageBody());
}
use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class MessageConverter_v1_0_to_InternalTest method testNoBodyWithTextMessageAnnotationWithKnownTextualContentType.
public void testNoBodyWithTextMessageAnnotationWithKnownTextualContentType() throws Exception {
final String mimeType = "text/foo";
Properties properties = new Properties();
properties.setContentType(Symbol.valueOf(mimeType));
Message_1_0 sourceMessage = createTestMessage(properties, TEXT_MESSAGE_MESSAGE_ANNOTATION, null);
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", mimeType, convertedMessage.getMessageHeader().getMimeType());
assertEquals("Unexpected content", null, convertedMessage.getMessageBody());
}
use of org.apache.qpid.server.message.internal.InternalMessage 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")));
}
Aggregations