Search in sources :

Example 96 with ServerMessage

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

the class QueueMessageRecoveryTest method createMockMessage.

private ServerMessage createMockMessage(final long i) {
    ServerMessage msg = mock(ServerMessage.class);
    when(msg.getMessageNumber()).thenReturn(i);
    MessageReference ref = mock(MessageReference.class);
    when(ref.getMessage()).thenReturn(msg);
    when(msg.newReference()).thenReturn(ref);
    when(msg.newReference(any(TransactionLogResource.class))).thenReturn(ref);
    when(msg.getStoredMessage()).thenReturn(mock(StoredMessage.class));
    return msg;
}
Also used : StoredMessage(org.apache.qpid.server.store.StoredMessage) ServerMessage(org.apache.qpid.server.message.ServerMessage) MessageReference(org.apache.qpid.server.message.MessageReference) TransactionLogResource(org.apache.qpid.server.store.TransactionLogResource)

Example 97 with ServerMessage

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

the class RejectPolicyHandlerTest method testNotOverfullBytes.

public void testNotOverfullBytes() throws Exception {
    when(_queue.getMaximumQueueDepthBytes()).thenReturn(9L);
    ServerMessage incomingMessage1 = createIncomingMessage(5);
    MessageInstance messageInstance1 = mock(MessageInstance.class);
    when(messageInstance1.getMessage()).thenReturn(incomingMessage1);
    ServerMessage incomingMessage2 = createIncomingMessage(5);
    _rejectOverflowPolicyHandler.checkReject(incomingMessage1);
    _rejectOverflowPolicyHandler.postEnqueue(messageInstance1);
    _rejectOverflowPolicyHandler.checkReject(incomingMessage2);
}
Also used : MessageInstance(org.apache.qpid.server.message.MessageInstance) ServerMessage(org.apache.qpid.server.message.ServerMessage)

Example 98 with ServerMessage

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

the class RejectPolicyHandlerTest method createIncomingMessage.

private ServerMessage createIncomingMessage(final long size) {
    AMQMessageHeader incomingMessageHeader = mock(AMQMessageHeader.class);
    ServerMessage incomingMessage = mock(ServerMessage.class);
    when(incomingMessage.getMessageHeader()).thenReturn(incomingMessageHeader);
    when(incomingMessage.getSizeIncludingHeader()).thenReturn(size);
    when(incomingMessage.getStoredMessage()).thenReturn(mock(StoredMessage.class));
    return incomingMessage;
}
Also used : StoredMessage(org.apache.qpid.server.store.StoredMessage) ServerMessage(org.apache.qpid.server.message.ServerMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 99 with ServerMessage

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

the class RejectPolicyHandlerTest method testNotOverfullMessages.

public void testNotOverfullMessages() throws Exception {
    when(_queue.getMaximumQueueDepthMessages()).thenReturn(1L);
    ServerMessage incomingMessage1 = createIncomingMessage(2);
    MessageInstance messageInstance1 = mock(MessageInstance.class);
    when(messageInstance1.getMessage()).thenReturn(incomingMessage1);
    ServerMessage incomingMessage2 = createIncomingMessage(2);
    _rejectOverflowPolicyHandler.checkReject(incomingMessage1);
    _rejectOverflowPolicyHandler.postEnqueue(messageInstance1);
    _rejectOverflowPolicyHandler.checkReject(incomingMessage2);
}
Also used : MessageInstance(org.apache.qpid.server.message.MessageInstance) ServerMessage(org.apache.qpid.server.message.ServerMessage)

Example 100 with ServerMessage

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

the class SortedQueueEntryListTest method setUp.

@Override
protected void setUp() throws Exception {
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put(Queue.ID, UUID.randomUUID());
    attributes.put(Queue.NAME, getName());
    attributes.put(Queue.DURABLE, false);
    attributes.put(Queue.LIFETIME_POLICY, LifetimePolicy.PERMANENT);
    attributes.put(SortedQueue.SORT_KEY, "KEY");
    // Create test list
    final QueueManagingVirtualHost virtualHost = BrokerTestHelper.createVirtualHost("testVH");
    _testQueue = new SortedQueueImpl(attributes, virtualHost) {

        SelfValidatingSortedQueueEntryList _entries;

        @Override
        protected void onOpen() {
            super.onOpen();
            _entries = new SelfValidatingSortedQueueEntryList(this);
        }

        @Override
        SelfValidatingSortedQueueEntryList getEntries() {
            return _entries;
        }
    };
    _testQueue.open();
    _sqel = (SelfValidatingSortedQueueEntryList) _testQueue.getEntries();
    super.setUp();
    // Create result array
    Arrays.sort(keysSorted);
    // Build test list
    long messageId = 0L;
    for (final String key : keys) {
        final ServerMessage msg = generateTestMessage(messageId++, key);
        _sqel.add(msg, null);
    }
}
Also used : QueueManagingVirtualHost(org.apache.qpid.server.virtualhost.QueueManagingVirtualHost) HashMap(java.util.HashMap) 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