Search in sources :

Example 56 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 testAmqpValueWithNullWithUnknownMessageAnnotation.

@Test
public void testAmqpValueWithNullWithUnknownMessageAnnotation() throws Exception {
    final Object expected = null;
    final AmqpValue amqpValue = new AmqpValue(expected);
    Message_1_0 sourceMessage = createTestMessage(new MessageAnnotations(Collections.singletonMap(Symbol.valueOf("x-opt-jms-msg-type"), (byte) 11)), amqpValue.createEncodingRetainingSection());
    final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", null, convertedMessage.getMessageHeader().getMimeType());
    assertEquals("Unexpected content size", (long) 0, (long) convertedMessage.getMessageMetaData().getContentSize());
}
Also used : MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) AmqpValue(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage) Test(org.junit.Test)

Example 57 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 testAmqpValueWithMap.

@Test
public void testAmqpValueWithMap() throws Exception {
    final Map<String, Object> originalMap = new LinkedHashMap<>();
    originalMap.put("binaryEntry", new Binary(new byte[] { 0x00, (byte) 0xFF }));
    originalMap.put("intEntry", 42);
    originalMap.put("nullEntry", null);
    final AmqpValue amqpValue = new AmqpValue(originalMap);
    Message_1_0 sourceMessage = createTestMessage(amqpValue.createEncodingRetainingSection());
    final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", "jms/map-message", convertedMessage.getMessageHeader().getMimeType());
    final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
    Map<String, Object> convertedMap = new JmsMapMessageToMap().toObject(getBytes(content));
    assertEquals("Unexpected size", (long) originalMap.size(), (long) 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"));
}
Also used : JmsMapMessageToMap(org.apache.qpid.server.typedmessage.mimecontentconverter.JmsMapMessageToMap) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) AmqpValue(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue) LinkedHashMap(java.util.LinkedHashMap) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage) Test(org.junit.Test)

Example 58 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 doTestDataWithAnnotation.

private void doTestDataWithAnnotation(final byte[] data, final MessageAnnotations messageAnnotations, final String expectedMimeType) throws Exception {
    final Data value = new Data(new Binary(data));
    Message_1_0 sourceMessage = createTestMessage(messageAnnotations, value.createEncodingRetainingSection());
    final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", expectedMimeType, convertedMessage.getMessageHeader().getMimeType());
    final QpidByteBuffer content = convertedMessage.getContent();
    assertArrayEquals("Unexpected content", data, 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) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 59 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 testDataWithMapMessageAnnotationAndContentTypeJmsMapMessage.

@Test
public void testDataWithMapMessageAnnotationAndContentTypeJmsMapMessage() throws Exception {
    Map<String, Object> originalMap = Collections.singletonMap("testKey", "testValue");
    byte[] data = new MapToJmsMapMessage().toMimeContent(originalMap);
    String expectedMimeType = "jms/map-message";
    final Data value = new Data(new Binary(data));
    Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf(expectedMimeType));
    Message_1_0 sourceMessage = createTestMessage(properties, MAP_MESSAGE_MESSAGE_ANNOTATION, value.createEncodingRetainingSection());
    final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", expectedMimeType, convertedMessage.getMessageHeader().getMimeType());
    final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
    assertArrayEquals("Unexpected content", data, getBytes(content));
}
Also used : MapToJmsMapMessage(org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage) 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 60 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 testNoBodyWithContentTypeApplicationOctetStream.

@Test
public void testNoBodyWithContentTypeApplicationOctetStream() throws Exception {
    Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf("application/octet-stream"));
    final Message_1_0 sourceMessage = createTestMessage(properties, 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) 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)

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