Search in sources :

Example 91 with QpidByteBuffer

use of org.apache.qpid.server.bytebuffer.QpidByteBuffer in project qpid-broker-j by apache.

the class MessageConverter_0_8_to_InternalTest method configureMessageContent.

private void configureMessageContent(byte[] section) {
    if (section == null) {
        section = new byte[0];
    }
    final QpidByteBuffer combined = QpidByteBuffer.wrap(section);
    when(_handle.getContentSize()).thenReturn(section.length);
    final ArgumentCaptor<Integer> offsetCaptor = ArgumentCaptor.forClass(Integer.class);
    final ArgumentCaptor<Integer> sizeCaptor = ArgumentCaptor.forClass(Integer.class);
    when(_handle.getContent(offsetCaptor.capture(), sizeCaptor.capture())).then(invocation -> combined.view(offsetCaptor.getValue(), sizeCaptor.getValue()));
}
Also used : QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer)

Example 92 with QpidByteBuffer

use of org.apache.qpid.server.bytebuffer.QpidByteBuffer in project qpid-broker-j by apache.

the class MessageConverter_Internal_to_0_8Test method doTest.

private void doTest(final Serializable messageBytes, final String mimeType, final byte[] expectedContent, final String expectedContentType) throws Exception {
    final InternalMessage sourceMessage = getAmqMessage(messageBytes, mimeType);
    final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    final QpidByteBuffer content = convertedMessage.getContent();
    assertArrayEquals("Unexpected content", expectedContent != null ? expectedContent : new byte[0], getBytes(content));
    assertEquals("Unexpected content type", expectedContentType, convertedMessage.getMessageHeader().getMimeType());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer)

Example 93 with QpidByteBuffer

use of org.apache.qpid.server.bytebuffer.QpidByteBuffer in project qpid-broker-j by apache.

the class MessageMetaDataFactoryTest method testUnmarshalFromSingleBuffer.

public void testUnmarshalFromSingleBuffer() throws Exception {
    try (QpidByteBuffer qpidByteBuffer = QpidByteBuffer.allocateDirect(_mmd.getStorableSize())) {
        _mmd.writeToBuffer(qpidByteBuffer);
        qpidByteBuffer.flip();
        MessageMetaData recreated = MessageMetaData.FACTORY.createMetaData(qpidByteBuffer);
        assertEquals("Unexpected arrival time", _arrivalTime, recreated.getArrivalTime());
        assertEquals("Unexpected routing key", _routingKey, recreated.getMessagePublishInfo().getRoutingKey());
        assertEquals("Unexpected content type", CONTENT_TYPE, recreated.getContentHeaderBody().getProperties().getContentTypeAsString());
        recreated.dispose();
    }
}
Also used : QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer)

Example 94 with QpidByteBuffer

use of org.apache.qpid.server.bytebuffer.QpidByteBuffer in project qpid-broker-j by apache.

the class AMQTypeTest method doTest.

private <T> void doTest(final AMQType type, final T value) {
    final QpidByteBuffer buf = QpidByteBuffer.allocate(false, SIZE);
    AMQTypedValue.createAMQTypedValue(type, value).writeToBuffer(buf);
    buf.flip();
    T read = (T) AMQTypedValue.readFromBuffer(buf).getValue();
    assertEquals("Unexpected round trip value", value, read);
    buf.dispose();
}
Also used : QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer)

Example 95 with QpidByteBuffer

use of org.apache.qpid.server.bytebuffer.QpidByteBuffer in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_8Test method testAmqpSequenceWithSimpleTypes.

public void testAmqpSequenceWithSimpleTypes() throws Exception {
    final List<Integer> expected = new ArrayList<>();
    expected.add(37);
    expected.add(42);
    final AmqpSequence amqpSequence = new AmqpSequence(expected);
    Message_1_0 sourceMessage = createTestMessage(amqpSequence.createEncodingRetainingSection());
    final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", "jms/stream-message", convertedMessage.getMessageHeader().getMimeType());
    final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
    assertEquals("Unexpected content", expected, new JmsStreamMessageToList().toObject(getBytes(content)));
}
Also used : JmsStreamMessageToList(org.apache.qpid.server.typedmessage.mimecontentconverter.JmsStreamMessageToList) ArrayList(java.util.ArrayList) 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) AmqpSequence(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpSequence) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Aggregations

QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)185 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)61 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)61 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)42 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)30 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)29 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)29 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)29 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)28 ArrayList (java.util.ArrayList)22 AmqpValue (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)20 Test (org.junit.Test)13 MapToJmsMapMessage (org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage)12 EncodingRetainingSection (org.apache.qpid.server.protocol.v1_0.type.messaging.EncodingRetainingSection)10 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)9 Transfer (org.apache.qpid.server.protocol.v1_0.type.transport.Transfer)9 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)9 ByteBuffer (java.nio.ByteBuffer)8 LinkedHashMap (java.util.LinkedHashMap)8 JmsMapMessageToMap (org.apache.qpid.server.typedmessage.mimecontentconverter.JmsMapMessageToMap)8