Search in sources :

Example 76 with AMQMessageHeader

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

the class LastValueQueueListTest method createTestServerMessage.

private ServerMessage createTestServerMessage(String conflationKeyValue) {
    ServerMessage mockMessage = mock(ServerMessage.class);
    AMQMessageHeader messageHeader = mock(AMQMessageHeader.class);
    when(messageHeader.getHeader(CONFLATION_KEY)).thenReturn(conflationKeyValue);
    when(mockMessage.getMessageHeader()).thenReturn(messageHeader);
    MessageReference messageReference = mock(MessageReference.class);
    when(mockMessage.newReference()).thenReturn(messageReference);
    when(mockMessage.newReference(any(TransactionLogResource.class))).thenReturn(messageReference);
    when(messageReference.getMessage()).thenReturn(mockMessage);
    return mockMessage;
}
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 77 with AMQMessageHeader

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

the class PriorityQueueListTest method testGetLeastSignificantOldestEntry.

public void testGetLeastSignificantOldestEntry() {
    assertEquals("Unexpected last entry", _priority4message1, _list.getLeastSignificantOldestEntry());
    ServerMessage<?> message = mock(ServerMessage.class);
    AMQMessageHeader header = mock(AMQMessageHeader.class);
    @SuppressWarnings({ "rawtypes", "unchecked" }) MessageReference<ServerMessage> ref = mock(MessageReference.class);
    when(message.getMessageHeader()).thenReturn(header);
    when(message.newReference()).thenReturn(ref);
    when(message.newReference(any(TransactionLogResource.class))).thenReturn(ref);
    when(ref.getMessage()).thenReturn(message);
    when(header.getPriority()).thenReturn((byte) 3);
    QueueEntry newEntry = _list.add(message, null);
    assertEquals("Unexpected last entry", newEntry, _list.getLeastSignificantOldestEntry());
}
Also used : ServerMessage(org.apache.qpid.server.message.ServerMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) TransactionLogResource(org.apache.qpid.server.store.TransactionLogResource)

Example 78 with AMQMessageHeader

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

the class PriorityQueueListTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    BrokerTestHelper.setUp();
    QueueEntry[] entries = new QueueEntry[PRIORITIES.length];
    Map<String, Object> queueAttributes = new HashMap<String, Object>();
    queueAttributes.put(Queue.ID, UUID.randomUUID());
    queueAttributes.put(Queue.NAME, getName());
    queueAttributes.put(PriorityQueue.PRIORITIES, 10);
    final QueueManagingVirtualHost<?> virtualHost = BrokerTestHelper.createVirtualHost("testVH");
    PriorityQueueImpl queue = new PriorityQueueImpl(queueAttributes, virtualHost);
    queue.open();
    _list = queue.getEntries();
    for (int i = 0; i < PRIORITIES.length; i++) {
        ServerMessage<?> message = mock(ServerMessage.class);
        AMQMessageHeader header = mock(AMQMessageHeader.class);
        @SuppressWarnings({ "rawtypes", "unchecked" }) MessageReference<ServerMessage> ref = mock(MessageReference.class);
        when(message.getMessageHeader()).thenReturn(header);
        when(message.newReference()).thenReturn(ref);
        when(message.newReference(any(TransactionLogResource.class))).thenReturn(ref);
        when(ref.getMessage()).thenReturn(message);
        when(header.getPriority()).thenReturn(PRIORITIES[i]);
        entries[i] = _list.add(message, null);
    }
    _priority4message1 = entries[0];
    _priority4message2 = entries[3];
    _priority5message1 = entries[1];
    _priority5message2 = entries[2];
}
Also used : HashMap(java.util.HashMap) ServerMessage(org.apache.qpid.server.message.ServerMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) TransactionLogResource(org.apache.qpid.server.store.TransactionLogResource)

Example 79 with AMQMessageHeader

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

the class PriorityQueueTest method createMessage.

protected ServerMessage createMessage(Long id, byte i) {
    ServerMessage msg = super.createMessage(id);
    AMQMessageHeader hdr = msg.getMessageHeader();
    when(hdr.getPriority()).thenReturn(i);
    return msg;
}
Also used : ServerMessage(org.apache.qpid.server.message.ServerMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 80 with AMQMessageHeader

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

the class QueueEntryListTestBase method createServerMessage.

private ServerMessage createServerMessage(long number) {
    final ServerMessage message = mock(ServerMessage.class);
    when(message.getMessageNumber()).thenReturn(number);
    MessageReference ref = mock(MessageReference.class);
    AMQMessageHeader hdr = mock(AMQMessageHeader.class);
    when(ref.getMessage()).thenReturn(message);
    when(message.newReference()).thenReturn(ref);
    when(message.newReference(any(TransactionLogResource.class))).thenReturn(ref);
    when(message.getMessageHeader()).thenReturn(hdr);
    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)

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