Search in sources :

Example 41 with AMQMessageHeader

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

the class SortedQueueEntryListTest method generateTestMessage.

private ServerMessage generateTestMessage(final long id, final String keyValue) {
    final ServerMessage message = mock(ServerMessage.class);
    AMQMessageHeader hdr = mock(AMQMessageHeader.class);
    when(message.getMessageHeader()).thenReturn(hdr);
    when(hdr.getHeader(eq("KEY"))).thenReturn(keyValue);
    when(hdr.containsHeader(eq("KEY"))).thenReturn(true);
    when(hdr.getHeaderNames()).thenReturn(Collections.singleton("KEY"));
    MessageReference ref = mock(MessageReference.class);
    when(ref.getMessage()).thenReturn(message);
    when(message.newReference()).thenReturn(ref);
    when(message.newReference(any(TransactionLogResource.class))).thenReturn(ref);
    when(message.getMessageNumber()).thenReturn(id);
    return message;
}
Also used : ServerMessage(org.apache.qpid.server.message.ServerMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) MessageReference(org.apache.qpid.server.message.MessageReference) TransactionLogResource(org.apache.qpid.server.store.TransactionLogResource)

Example 42 with AMQMessageHeader

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

the class SortedQueueEntryTest method getQueueEntryImpl.

@Override
public QueueEntryImpl getQueueEntryImpl(int msgId) {
    final ServerMessage message = mock(ServerMessage.class);
    AMQMessageHeader hdr = mock(AMQMessageHeader.class);
    when(message.getMessageHeader()).thenReturn(hdr);
    when(hdr.getHeader(eq("KEY"))).thenReturn(keys[msgId - 1]);
    when(hdr.containsHeader(eq("KEY"))).thenReturn(true);
    when(hdr.getHeaderNames()).thenReturn(Collections.singleton("KEY"));
    final MessageReference reference = mock(MessageReference.class);
    when(reference.getMessage()).thenReturn(message);
    when(message.newReference()).thenReturn(reference);
    when(message.newReference(any(TransactionLogResource.class))).thenReturn(reference);
    return _queueEntryList.add(message, null);
}
Also used : ServerMessage(org.apache.qpid.server.message.ServerMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) MessageReference(org.apache.qpid.server.message.MessageReference) TransactionLogResource(org.apache.qpid.server.store.TransactionLogResource)

Example 43 with AMQMessageHeader

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

the class MessageConverter_v1_0_to_Internal method convert.

@Override
public InternalMessage convert(Message_1_0 serverMessage, NamedAddressSpace addressSpace) {
    Object bodyObject = MessageConverter_from_1_0.convertBodyToObject(serverMessage);
    final AMQMessageHeader convertHeader = convertHeader(serverMessage, addressSpace, bodyObject);
    return InternalMessage.convert(serverMessage, convertHeader, bodyObject);
}
Also used : AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 44 with AMQMessageHeader

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

the class PropertyConverter_Internal_to_v1_0Test method testMessageIdUuidConversion.

public void testMessageIdUuidConversion() {
    final UUID messageId = UUID.randomUUID();
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getMessageId()).thenReturn(messageId.toString());
    InternalMessage originalMessage = createTestMessage(header);
    Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    Object convertedMessageId = MessageConverter_from_1_0.getMessageId(convertedMessage);
    assertEquals("Unexpected messageId", messageId, convertedMessageId);
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) UUID(java.util.UUID)

Example 45 with AMQMessageHeader

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

the class PropertyConverter_Internal_to_v1_0Test method testCorrelationIdUnsignedLongConversion.

public void testCorrelationIdUnsignedLongConversion() {
    final UnsignedLong correlationId = UnsignedLong.valueOf(-1L);
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getCorrelationId()).thenReturn(correlationId.toString());
    InternalMessage originalMessage = createTestMessage(header);
    Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    Object convertedCorrelationId = MessageConverter_from_1_0.getCorrelationId(convertedMessage);
    assertEquals("Unexpected correlationId", correlationId, convertedCorrelationId);
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) UnsignedLong(org.apache.qpid.server.protocol.v1_0.type.UnsignedLong) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Aggregations

AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)81 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)55 Matchers.anyString (org.mockito.Matchers.anyString)28 ServerMessage (org.apache.qpid.server.message.ServerMessage)16 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)15 TransactionLogResource (org.apache.qpid.server.store.TransactionLogResource)11 HashMap (java.util.HashMap)10 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)8 MessageReference (org.apache.qpid.server.message.MessageReference)5 Queue (org.apache.qpid.server.model.Queue)5 ReplyTo (org.apache.qpid.server.protocol.v0_10.transport.ReplyTo)5 Exchange (org.apache.qpid.server.model.Exchange)4 UUID (java.util.UUID)3 UnsignedLong (org.apache.qpid.server.protocol.v1_0.type.UnsignedLong)3 Date (java.util.Date)2 Set (java.util.Set)2 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)2 InternalMessageHeader (org.apache.qpid.server.message.internal.InternalMessageHeader)2 StoredMessage (org.apache.qpid.server.store.StoredMessage)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2