use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_8Test method testDataWithContentTypeJavaSerializedObject.
@Test
public void testDataWithContentTypeJavaSerializedObject() 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/x-java-serialized-object"));
Message_1_0 sourceMessage = createTestMessage(properties, value.createEncodingRetainingSection());
final AMQMessage 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.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_8Test method testNoBodyWithBytesMessageAnnotation.
@Test
public void testNoBodyWithBytesMessageAnnotation() throws Exception {
Message_1_0 sourceMessage = createTestMessage(BYTE_MESSAGE_MESSAGE_ANNOTATION, null);
final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", "application/octet-stream", convertedMessage.getMessageHeader().getMimeType());
assertEquals("Unexpected content size", (long) 0, (long) convertedMessage.getMessageMetaData().getContentSize());
}
use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_8Test method testNoBodyWithObjectMessageContentType.
@Test
public void testNoBodyWithObjectMessageContentType() throws Exception {
final Properties properties = new Properties();
properties.setContentType(Symbol.valueOf("application/x-java-serialized-object"));
final Message_1_0 sourceMessage = createTestMessage(properties, null);
final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", "application/java-object-stream", convertedMessage.getMessageHeader().getMimeType());
assertEquals("Unexpected content size", (long) getObjectBytes(null).length, (long) convertedMessage.getMessageMetaData().getContentSize());
}
use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_8Test method testDataWithContentTypeOther.
@Test
public void testDataWithContentTypeOther() throws Exception {
final byte[] expected = "helloworld".getBytes(UTF_8);
final Data value = new Data(new Binary(expected));
final Properties properties = new Properties();
properties.setContentType(Symbol.valueOf("application/bin"));
Message_1_0 sourceMessage = createTestMessage(properties, value.createEncodingRetainingSection());
final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", "application/octet-stream", convertedMessage.getMessageHeader().getMimeType());
final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
assertArrayEquals("Unexpected content", expected, getBytes(content));
}
use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_8Test method doTestConvertOfDataSectionForTextualType.
private void doTestConvertOfDataSectionForTextualType(final String contentType) throws Exception {
final String expected = "testContent";
final Data value = new Data(new Binary(expected.getBytes(UTF_8)));
final Properties properties = new Properties();
properties.setContentType(Symbol.valueOf(contentType));
Message_1_0 sourceMessage = createTestMessage(properties, value.createEncodingRetainingSection());
final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
assertEquals("Unexpected content", expected, new String(getBytes(content), UTF_8));
assertEquals("Unexpected mime type", "text/plain", convertedMessage.getMessageHeader().getMimeType());
}
Aggregations