Search in sources :

Example 36 with AMQMessage

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));
}
Also used : NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Data(org.apache.qpid.server.protocol.v1_0.type.messaging.Data) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage) Test(org.junit.Test)

Example 37 with AMQMessage

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());
}
Also used : NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage) Test(org.junit.Test)

Example 38 with AMQMessage

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());
}
Also used : NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage) Test(org.junit.Test)

Example 39 with AMQMessage

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));
}
Also used : NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Data(org.apache.qpid.server.protocol.v1_0.type.messaging.Data) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage) Test(org.junit.Test)

Example 40 with AMQMessage

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());
}
Also used : NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Data(org.apache.qpid.server.protocol.v1_0.type.messaging.Data) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Aggregations

Test (org.junit.Test)198 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)176 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)143 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)114 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)78 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)76 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)58 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)57 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)46 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)38 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)33 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)32 MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)32 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)26 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)25 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)24 AmqpValue (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)17 HashMap (java.util.HashMap)15 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)14 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)12