Search in sources :

Example 6 with InternalMessageMetaData

use of org.apache.qpid.server.message.internal.InternalMessageMetaData in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v1_0Test method createTestMessage.

private InternalMessage createTestMessage(final AMQMessageHeader header, byte[] content, final boolean persistent) {
    final InternalMessageHeader internalMessageHeader = new InternalMessageHeader(header);
    final StoredMessage<InternalMessageMetaData> storedMessage = createInternalStoredMessage(content, persistent, internalMessageHeader);
    return ((InternalMessage) InternalMessageMetaDataType.INSTANCE.createMessage(storedMessage));
}
Also used : InternalMessageMetaData(org.apache.qpid.server.message.internal.InternalMessageMetaData) InternalMessageHeader(org.apache.qpid.server.message.internal.InternalMessageHeader)

Example 7 with InternalMessageMetaData

use of org.apache.qpid.server.message.internal.InternalMessageMetaData in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v0_10Test method createInternalStoredMessage.

private StoredMessage<InternalMessageMetaData> createInternalStoredMessage(final byte[] content, final boolean persistent, final InternalMessageHeader internalMessageHeader) throws IOException {
    final StoredMessage<InternalMessageMetaData> storedMessage = mock(StoredMessage.class);
    int contentSize = content == null ? 0 : content.length;
    if (contentSize > 0) {
        try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(baos)) {
            oos.writeObject(content);
            when(storedMessage.getContent(0, contentSize)).thenReturn(QpidByteBuffer.wrap(baos.toByteArray()));
        }
    }
    when(storedMessage.getContentSize()).thenReturn(contentSize);
    final InternalMessageMetaData metaData = new InternalMessageMetaData(persistent, internalMessageHeader, contentSize);
    when(storedMessage.getMetaData()).thenReturn(metaData);
    return storedMessage;
}
Also used : InternalMessageMetaData(org.apache.qpid.server.message.internal.InternalMessageMetaData) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream)

Example 8 with InternalMessageMetaData

use of org.apache.qpid.server.message.internal.InternalMessageMetaData in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v0_10Test method createTestMessage.

private InternalMessage createTestMessage(final AMQMessageHeader header, byte[] content, final boolean persistent, final long arrivalTime) throws IOException {
    final InternalMessageHeader internalMessageHeader = new InternalMessageHeader(header, arrivalTime);
    final StoredMessage<InternalMessageMetaData> storedMessage = createInternalStoredMessage(content, persistent, internalMessageHeader);
    return ((InternalMessage) InternalMessageMetaDataType.INSTANCE.createMessage(storedMessage));
}
Also used : InternalMessageMetaData(org.apache.qpid.server.message.internal.InternalMessageMetaData) InternalMessageHeader(org.apache.qpid.server.message.internal.InternalMessageHeader)

Example 9 with InternalMessageMetaData

use of org.apache.qpid.server.message.internal.InternalMessageMetaData in project qpid-broker-j by apache.

the class MessageConverter_Internal_to_1_0Test method getAmqMessage.

protected InternalMessage getAmqMessage(final Serializable content, final String mimeType) throws Exception {
    final byte[] serializedContent = getObjectStreamMessageBytes(content);
    configureMessageContent(serializedContent);
    configureMessageHeader(mimeType);
    final InternalMessageHeader internalMessageHeader = new InternalMessageHeader(_amqpHeader);
    final int contentSize = serializedContent == null ? 0 : serializedContent.length;
    final InternalMessageMetaData metaData = new InternalMessageMetaData(false, internalMessageHeader, contentSize);
    when(_handle.getMetaData()).thenReturn(metaData);
    return ((InternalMessage) InternalMessageMetaDataType.INSTANCE.createMessage(_handle));
}
Also used : InternalMessageMetaData(org.apache.qpid.server.message.internal.InternalMessageMetaData) InternalMessageHeader(org.apache.qpid.server.message.internal.InternalMessageHeader)

Example 10 with InternalMessageMetaData

use of org.apache.qpid.server.message.internal.InternalMessageMetaData in project qpid-broker-j by apache.

the class MessageConverter_Internal_to_0_8Test method getAmqMessage.

protected InternalMessage getAmqMessage(final Serializable content, final String mimeType) throws Exception {
    final byte[] serializedContent = getObjectStreamMessageBytes(content);
    configureMessageContent(serializedContent);
    configureMessageHeader(mimeType);
    final InternalMessageHeader internalMessageHeader = new InternalMessageHeader(_amqpHeader);
    final int contentSize = serializedContent == null ? 0 : serializedContent.length;
    final InternalMessageMetaData metaData = new InternalMessageMetaData(false, internalMessageHeader, contentSize);
    when(_handle.getMetaData()).thenReturn(metaData);
    return ((InternalMessage) InternalMessageMetaDataType.INSTANCE.createMessage(_handle));
}
Also used : InternalMessageMetaData(org.apache.qpid.server.message.internal.InternalMessageMetaData) InternalMessageHeader(org.apache.qpid.server.message.internal.InternalMessageHeader)

Aggregations

InternalMessageMetaData (org.apache.qpid.server.message.internal.InternalMessageMetaData)12 InternalMessageHeader (org.apache.qpid.server.message.internal.InternalMessageHeader)9 AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)3 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1