Search in sources :

Example 1 with Binary

use of org.apache.qpid.server.protocol.v1_0.type.Binary in project qpid-broker-j by apache.

the class PropertyConverter_v1_0_to_InternalTest method createTestMessage.

private Message_1_0 createTestMessage(final Header header, final DeliveryAnnotations deliveryAnnotations, final MessageAnnotations messageAnnotations, final Properties properties, final ApplicationProperties applicationProperties, final long arrivalTime, final byte[] content) {
    final StoredMessage<MessageMetaData_1_0> storedMessage = mock(StoredMessage.class);
    MessageMetaData_1_0 metaData = new MessageMetaData_1_0(header.createEncodingRetainingSection(), deliveryAnnotations.createEncodingRetainingSection(), messageAnnotations.createEncodingRetainingSection(), properties.createEncodingRetainingSection(), applicationProperties.createEncodingRetainingSection(), new Footer(Collections.emptyMap()).createEncodingRetainingSection(), arrivalTime, content == null ? 0 : content.length);
    when(storedMessage.getMetaData()).thenReturn(metaData);
    if (content != null) {
        Binary binary = new Binary(content);
        DataSection dataSection = new Data(binary).createEncodingRetainingSection();
        QpidByteBuffer qbb = dataSection.getEncodedForm();
        int length = qbb.remaining();
        when(storedMessage.getContentSize()).thenReturn(length);
        when(storedMessage.getContent(0, length)).thenReturn(qbb);
    } else {
        when(storedMessage.getContentSize()).thenReturn(0);
        when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
    }
    return new Message_1_0(storedMessage);
}
Also used : DataSection(org.apache.qpid.server.protocol.v1_0.type.messaging.DataSection) Footer(org.apache.qpid.server.protocol.v1_0.type.messaging.Footer) 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)

Example 2 with Binary

use of org.apache.qpid.server.protocol.v1_0.type.Binary in project qpid-broker-j by apache.

the class PropertyConverter_v1_0_to_InternalTest method testUserIdConversion.

public void testUserIdConversion() {
    final byte[] data = new byte[] { (byte) 0xc3, 0x28 };
    final Binary userId = new Binary(data);
    Properties properties = new Properties();
    properties.setUserId(userId);
    Message_1_0 originalMessage = createTestMessage(properties);
    InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertEquals("Unexpected userId", new String(data, UTF_8), convertedMessage.getMessageHeader().getUserId());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) 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)

Example 3 with Binary

use of org.apache.qpid.server.protocol.v1_0.type.Binary in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10Test method testDataWithStreamMessageAnnotationAndContentTypeJmsStreamMessage.

public void testDataWithStreamMessageAnnotationAndContentTypeJmsStreamMessage() throws Exception {
    List<Object> originalList = Collections.singletonList("testValue");
    byte[] data = new ListToJmsStreamMessage().toMimeContent(originalList);
    String expectedMimeType = "jms/stream-message";
    final Data value = new Data(new Binary(data));
    Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf(expectedMimeType));
    Message_1_0 sourceMessage = createTestMessage(properties, STREAM_MESSAGE_MESSAGE_ANNOTATION, value.createEncodingRetainingSection());
    final MessageTransferMessage 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 : ListToJmsStreamMessage(org.apache.qpid.server.typedmessage.mimecontentconverter.ListToJmsStreamMessage) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) 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)

Example 4 with Binary

use of org.apache.qpid.server.protocol.v1_0.type.Binary in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10Test 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 MessageTransferMessage 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 : MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) 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)

Example 5 with Binary

use of org.apache.qpid.server.protocol.v1_0.type.Binary in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10Test method testDataWithContentTypeAmqpMap.

public void testDataWithContentTypeAmqpMap() throws Exception {
    Map<String, Object> originalMap = Collections.singletonMap("testKey", "testValue");
    byte[] bytes = new MapToAmqpMapConverter().toMimeContent(originalMap);
    final Data value = new Data(new Binary(bytes));
    Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf("amqp/map"));
    Message_1_0 sourceMessage = createTestMessage(properties, value.createEncodingRetainingSection());
    final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", "amqp/map", convertedMessage.getMessageHeader().getMimeType());
    final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
    assertArrayEquals("Unexpected content", bytes, getBytes(content));
}
Also used : MapToAmqpMapConverter(org.apache.qpid.server.protocol.v0_10.transport.mimecontentconverter.MapToAmqpMapConverter) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) 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)

Aggregations

Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)104 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)50 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)47 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)45 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)43 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)42 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)32 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)32 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)32 Test (org.junit.Test)32 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)31 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)25 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)24 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)23 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)22 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)17 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)16 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)14 HashMap (java.util.HashMap)13 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)13