Search in sources :

Example 91 with ServerMessage

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

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

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

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

the class QueueEntryListTestBase method testAddGenericMessage.

/**
 * Test to add a generic mock message.
 * @see QueueEntryListTestBase#getTestList()
 * @see QueueEntryListTestBase#getExpectedListLength()
 */
public void testAddGenericMessage() throws Exception {
    final QueueEntryList list = getTestList();
    final ServerMessage message = createServerMessage(666l);
    list.add(message, null);
    final QueueEntryIterator iter = list.iterator();
    int count = 0;
    while (iter.advance()) {
        iter.getNode();
        count++;
    }
    assertEquals("List did not grow by one entry after a generic message added", getExpectedListLength() + 1, count);
}
Also used : ServerMessage(org.apache.qpid.server.message.ServerMessage)

Example 95 with ServerMessage

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

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