Package org.activemq.io.util

Source Code of org.activemq.io.util.MemoryBoundedPrioritizedQueueTest

/**
*
* Copyright 2004 Protique Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**/

package org.activemq.io.util;

import org.activemq.message.ActiveMQMessage;

/**
* @author Ramzi Saba
*
* @version $Revision: 1.1.1.1 $
*/
public class MemoryBoundedPrioritizedQueueTest extends MemoryBoundedQueueTest {

  public void setUp() throws Exception {
    supportJMSPriority = true;
    super.setUp();
  }

    public void testMessagePriority() throws Exception {
        MemoryBoundedQueue queue = getQueueManager().getMemoryBoundedQueue(QUEUE_NAME);
        getMemoryManager().setValueLimit(TEST_INSTANCE_SIZE*3);
        ActiveMQMessage msg1 = new ActiveMQMessage()// default priority is 4
        ActiveMQMessage msg2 = new ActiveMQMessage();
        msg2.setJMSPriority(2)// low priority message
        ActiveMQMessage msg3 = new ActiveMQMessage();
        msg3.setJMSPriority(9)// high priority message

        queue.enqueueNoBlock(msg1);
        queue.enqueueNoBlock(msg2);
        queue.enqueueNoBlock(msg3);
       
        Object result1 = queue.dequeue();
        Object result2 = queue.dequeue();
        Object result3 = queue.dequeue();
               
        assertTrue(result1 == msg3);
        assertTrue(result2 == msg1);
        assertTrue(result3 == msg2);
       
        queue.close();     
    }

}
TOP

Related Classes of org.activemq.io.util.MemoryBoundedPrioritizedQueueTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.