Search in sources :

Example 41 with ServerMessage

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

the class SimpleQueueEntryImplTest method getQueueEntryImpl.

@Override
public QueueEntryImpl getQueueEntryImpl(int msgId) {
    ServerMessage message = mock(ServerMessage.class);
    when(message.getMessageNumber()).thenReturn((long) msgId);
    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 (QueueEntryImpl) queueEntryList.add(message, null);
}
Also used : ServerMessage(org.apache.qpid.server.message.ServerMessage) MessageReference(org.apache.qpid.server.message.MessageReference) TransactionLogResource(org.apache.qpid.server.store.TransactionLogResource)

Example 42 with ServerMessage

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

the class SortedQueueEntryListTest method testAscendingSortKeys.

public void testAscendingSortKeys() throws Exception {
    _sqel = new SelfValidatingSortedQueueEntryList(_testQueue);
    // Build test list
    long messageId = 0L;
    for (String textKey : textkeys) {
        final ServerMessage msg = generateTestMessage(messageId, textKey);
        messageId++;
        _sqel.add(msg, null);
    }
    final QueueEntryIterator iter = getTestList().iterator();
    int count = 0;
    while (iter.advance()) {
        assertEquals("Sorted queue entry value is not as expected", textkeys[count], getSortedKeyValue(iter));
        assertEquals("Message id not as expected", Long.valueOf(count), getMessageId(iter));
        count++;
    }
}
Also used : ServerMessage(org.apache.qpid.server.message.ServerMessage)

Example 43 with ServerMessage

use of org.apache.qpid.server.message.ServerMessage 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 44 with ServerMessage

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

the class SortedQueueEntryListTest method testDescendingSortKeys.

public void testDescendingSortKeys() throws Exception {
    _sqel = new SelfValidatingSortedQueueEntryList(_testQueue);
    // Build test list
    long messageId = 0L;
    for (int i = textkeys.length - 1; i >= 0; i--) {
        final ServerMessage msg = generateTestMessage(messageId, textkeys[i]);
        messageId++;
        _sqel.add(msg, null);
    }
    final QueueEntryIterator iter = getTestList().iterator();
    int count = 0;
    while (iter.advance()) {
        assertEquals("Sorted queue entry value is not as expected", textkeys[count], getSortedKeyValue(iter));
        assertEquals("Message id not as expected", Long.valueOf(textkeys.length - count - 1), getMessageId(iter));
        count++;
    }
}
Also used : ServerMessage(org.apache.qpid.server.message.ServerMessage)

Example 45 with ServerMessage

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

the class SortedQueueEntryListTest method testInsertAfter.

public void testInsertAfter() throws Exception {
    _sqel = new SelfValidatingSortedQueueEntryList(_testQueue);
    ServerMessage msg = generateTestMessage(1, "A");
    _sqel.add(msg, null);
    SortedQueueEntry entry = _sqel.next(_sqel.getHead());
    validateEntry(entry, "A", 1);
    msg = generateTestMessage(2, "B");
    _sqel.add(msg, null);
    entry = _sqel.next(_sqel.getHead());
    validateEntry(entry, "A", 1);
    entry = _sqel.next(entry);
    validateEntry(entry, "B", 2);
}
Also used : ServerMessage(org.apache.qpid.server.message.ServerMessage)

Aggregations

ServerMessage (org.apache.qpid.server.message.ServerMessage)103 HashMap (java.util.HashMap)26 AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)16 TransactionLogResource (org.apache.qpid.server.store.TransactionLogResource)16 Exchange (org.apache.qpid.server.model.Exchange)14 MessageReference (org.apache.qpid.server.message.MessageReference)13 ArrayList (java.util.ArrayList)9 MessageInstance (org.apache.qpid.server.message.MessageInstance)8 InstanceProperties (org.apache.qpid.server.message.InstanceProperties)7 Queue (org.apache.qpid.server.model.Queue)7 StoredMessage (org.apache.qpid.server.store.StoredMessage)6 MessageEnqueueRecord (org.apache.qpid.server.store.MessageEnqueueRecord)4 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)3 TestConsumerTarget (org.apache.qpid.server.consumer.TestConsumerTarget)3 MessageDeletedException (org.apache.qpid.server.message.MessageDeletedException)3 PrivilegedAction (java.security.PrivilegedAction)2 UUID (java.util.UUID)2 MessageDestination (org.apache.qpid.server.message.MessageDestination)2 MessageInstanceConsumer (org.apache.qpid.server.message.MessageInstanceConsumer)2 RoutingResult (org.apache.qpid.server.message.RoutingResult)2