use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class MessageConverter_v1_0_to_InternalTest 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 InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", "application/x-java-serialized-object", 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 testAmqpValueWithNull.
public void testAmqpValueWithNull() throws Exception {
final Object expected = null;
final AmqpValue amqpValue = new AmqpValue(expected);
Message_1_0 sourceMessage = createTestMessage(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 testAmqpValueWithString.
public void testAmqpValueWithString() throws Exception {
final String expected = "testContent";
final AmqpValue amqpValue = new AmqpValue(expected);
Message_1_0 sourceMessage = createTestMessage(amqpValue.createEncodingRetainingSection());
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", "text/plain", convertedMessage.getMessageHeader().getMimeType());
assertEquals("Unexpected content", expected, 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 testNoBodyWithMapMessageAnnotation.
public void testNoBodyWithMapMessageAnnotation() throws Exception {
Message_1_0 sourceMessage = createTestMessage(MAP_MESSAGE_MESSAGE_ANNOTATION, null);
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", null, 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_0_10_to_InternalTest method doTest.
private void doTest(final byte[] messageBytes, final String mimeType, final Object expectedContent, final String expectedMimeType) throws Exception {
final MessageTransferMessage sourceMessage = getAmqMessage(messageBytes, mimeType);
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
if (expectedContent instanceof byte[]) {
assertArrayEquals("Unexpected content", ((byte[]) expectedContent), ((byte[]) convertedMessage.getMessageBody()));
} else if (expectedContent instanceof List) {
assertEquals("Unexpected content", new ArrayList<Object>((Collection) expectedContent), new ArrayList<Object>((Collection) convertedMessage.getMessageBody()));
} else if (expectedContent instanceof Map) {
assertEquals("Unexpected content", new HashMap<Object, Object>((Map) expectedContent), new HashMap<Object, Object>((Map) convertedMessage.getMessageBody()));
} else {
assertEquals("Unexpected content", expectedContent, convertedMessage.getMessageBody());
}
String convertedMimeType = convertedMessage.getMessageHeader().getMimeType();
assertEquals("Unexpected content type", expectedMimeType, convertedMimeType);
}
Aggregations